Understanding Computer Programming

Osher Lifelong Learning Institute
University of Illinois, Urbana-Champaign

Scott Badman, Instructor


Topic: Unstructured Programming - using JMP (jump) and labels, instead of IF and WHILE

March 17, 2016


The computer actually implements all decisions using the JMP commands.
Early programming languages (such as Assembly Languages, original FORTRAN, and original BASIC) all had JMP commands, sometimes called GO TO.
Edsger Dijkstra, one of the most important early Computer Scientists revolutionized programming by advocating getting rid of JMP in all higher computer languages.

From Edsger Dijkstra's Wikipedia article:
In 1968, computer programming was in a state of crisis. Dijkstra was one of a small group of academics and industrial programmers who advocated a new programming style to improve the quality of programs. Dijkstra coined the phrase "structured programming" and during the 1970s this became the new programming orthodoxy. Dijkstra's ideas about structured programming helped lay the foundations for the birth and development of the professional discipline of software engineering, enabling programmers to organize and manage increasingly complex software projects.

The crisis mentioned was that as programs got larger they became so complex that humans could not possibly understand and debug them. Bugs could appear anywhere, instead of being isolated within a specific module or object, because the program was jumping all over the place.


Standard IF-ELSE-ENDIF statements:

    IF comparison(s)

        Code done if the comparison is true.

    ELSE

        Code done if the comparison is false.

    END IF

    The program continues here after the IF-ELSE-ENDIF completes.



IF-ELSE-ENDIF implemented using JMP's:

    JMP to false label if the comparison(s) are false

        Code done if the comparison is true.

    JMP to continue label

    false:                       **** false is a label here, not a command in the language ****

        Code done if the comparison is false.

    continue:                **** continue is a label here, not a command in the language ****

    In either case the program continues here after the JMP's are complete



Repetition - WHILE loops:

    WHILE comparison(s) are true

        One or more lines of code that is done if the comparison is true.

    END WHILE

    The computer automatically jumps back to the beginning of the while loop to test the comparison(s) again.

    The program continues here after the WHILE loop comparison(s) test false.



WHILE loop implemented using JMP's:

    again: JMP to continue label if the comparison(s) are false

        Code done if the comparison is true.

    JMP to again label

    continue:                **** continue is a label here, not a command in the language ****

    The program continues here after the JMP's are complete



Understanding Computer Programming

Osher Lifelong Learning Institute
University of Illinois, Urbana-Champaign

Scott Badman, Instructor