Assembly Language for Beginners

(nextflipdebug2) #1

1.13 GOTO operator


f1()completes:


Figure 1.31:OllyDbg:f1()completes execution

We now find0xDB18and0x243at addresses0x2EF854and0x2EF858. These values are thef1()results.


Conclusion


f1()could return pointers to any place in memory, located anywhere.


This is in essence the usefulness of the pointers.


By the way, C++referenceswork exactly the same way. Read more about them: (3.18.3 on page 558).


1.13 GOTO operator


The GOTO operator is generally considered as anti-pattern, see [Edgar Dijkstra,Go To Statement Con-
sidered Harmful(1968)^88 ]. Nevertheless, it can be used reasonably, see [Donald E. Knuth,Structured
Programming with go to Statements(1974)^89 ]^90.


Here is a very simple example:


#include <stdio.h>


int main()
{
printf ("begin\n");
goto exit;
printf ("skip me!\n");
exit:
printf ("end\n");
};


Here is what we have got in MSVC 2012:


Listing 1.103: MSVC 2012

$SG2934 DB 'begin', 0aH, 00H


(^88) http://yurichev.com/mirrors/Dijkstra68.pdf
(^89) http://yurichev.com/mirrors/KnuthStructuredProgrammingGoTo.pdf
(^90) [Dennis Yurichev,C/C++ programming language notes] also has some examples.

Free download pdf