This program has both a while loop and an if/then/else. Actually, there are no while loops or if statements in assembler, only jumps, which are sometimes called branches because flow of control lines probably look like branches of a tree, especially when a complicated set of nested if/then/elses occurs. But then why aren't loops called snakes? Another term for jumps or branches is goto. In the 1960s an influential paper by Edsgar Dijkstra was published called "Go To Statement Considered Harmful." It spurred great controversy but ultimately most computer science educators and many practitioners were won over to the goto-less style of programming. A new methodology emerged, called structured programming, which eschewed the spaghetti code of earlier years for a cleaner, clearer style using only whiles and if/then/elses. Today we still use this methodology, though gotos are useful in a few exceptional cases. Since in assembler, there are only jumps, all other control structures are built out of them. It is possible for an assembler programmer to carefully and consistently use a labeling discipline which mimics the kind of code a C compiler would produce for whiles and if/then/elses. This method is shown in the gcd program above alongside the C code which might have generated this code is shown as comments off to the side. |