Valdemar W. Setzer
Dept. of Computer Science, University of São Paulo, Brazil
Version 2.2, May 15, 2018.

1. Introduction

The first computer installed at the University of São Paulo in 1962 was an IBM-1620, a decimal, variable-length machine. Its machine language (ML) was simple enough to be taught in a couple of lectures. Thus, our courses on introduction to programming began with that language, and then went into FORTRAN as a so-called "high-level" programming language. Our experience was that through ML the students got a very good idea of the internal structure of a computer, as seen from the programming perspective. A "high-level" language such as FORTRAN, ALGOL, Pascal, C, Python etc. does not give this knowledge: the way the computer processes data and how it interprets the "high-level" commands remain a mystery. When we began our studies of compiling theory and construction in 1966, we began to show the students how the "high-level" commands could be translated into machine language, so the students could get an understanding of how the machine executed their programs. In 1974 we began to teach a course on impacts of computers on individuals and society. We realized how important it was to have that understanding to grasp the main impact of computers upon individuals, that is, the fact that it forces quantified, logical-symbolic, algorithmic, atomistic thinking. In 1968 the IBM-1620 was replaced by other computers, whose machine language was not so simple, if not binary. In the latter case, it is impossible to program in or teach machine language. So on that year, inspired by an example of the University of Waterloo, we devised the HIPO virtual machine. Its name derived from "Computador Hipotético," in Portuguese. Our intention was to use it both as an educational tool for teaching introduction to programming, as well as a target ("object") language for courses on compilers. Thus, we designed HIPO as a 10-digit, fixed-word decimal machine. An instruction contained a 4-digit address, indirect addressing and an index register (to show how to implement indexed - matrix - variables in the compiler course). The machine contained also floating-point, mask, alphanumeric input/output, call and return instructions. We also designed an assembly language and an assembler was implemented. This way, the first programming homework assigned to students was a program in ML for the HIPO computer, which they had to test using the simulator running in a mainframe, and the second was a program in its assembly language. The subsequent homeworks were all done in a "high-level" language.

In 1976 we made another educational step: we invented the "Paper Computer," a kind of theater play performed by about 20 students in front of the class. With that play we were able to go deeper into the way a computer executes the program instructions, providing the educational tool to introduce the notions of CPU, instruction pointer, jumps, stored program, etc. HIPO was our basic model, but it was not necessary to have such a relatively complex ML for the Paper Computer play. So we designed a simplified HIPO as a 4-digit, fixed-word machine with a restricted set of basic instructions.

With the appearance of microcomputers, we decided that it would be good to have an IBM-PC implementation of HIPO, so that the students could also experiment with the machine language. This was motivated mainly by an activity we designed for introducing the basic notions of computers, programming and general application software to senior high-school students, as well as college students and adults that had no knowledge on computers and computing. This activity, called "The Computer Day," was realized in a Saturday taking a total of 8 hours, alternating class lectures and labs using microcomputers. The first lab class was dedicated to HIPO, and the second to the use of a simple text editor that we designed and was implemented to show the principles of text editing (this was a time when almost nobody had computers at home).

When computers began to be used in elementary and high schools for educational purposes, we got involved in this problem. From the beginning, we were against the use of computers before puberty. We published books in Brazil, England, Germany and Finland, showing that the type of thinking and attitude forced by computers were damaging to young users. We proposed that computers be used in high school for teaching what they are, how to use them through general application software (advanced features of text editors, spreadsheets, and the Internet), and the individual and social problems they cause. Our reasoning was inspired by Waldorf Education, where the gradual development of inner abilities such as willing, feeling and thinking (in this order) takes a definite role. In particular, purely abstract thinking is left for high school.

Waldorf Schools around the world began to give notions of computers to their high school students. In general, they begin with digital circuits, using relays or transistors, showing the internal principles of logical gates and how to use them in simple applications, up to building a simple binary adder. Then they go into basic notions of "high level" programming languages. Here is where the Paper Computer and HIPO fit best: they provide a bridge between logical circuits and basic computer structures and programming languages, as well as application software. For instance, when teaching the principles of a text editor, it is essential that the students know what an address is, so that the text lines may be represented through a linked list. Otherwise a text editor will be always a mystery.

The usefulness of the Paper Computer and HIPO as educational tools are obviously not restricted to Waldorf Schools, as we demonstrated through their extensive use at my university. We think that any introductory course on computers should begin with them – even for those students that know already how to use a PC.

Motivated by a request from Charles Tolman, who was invited by a British Waldorf school to teach classes on computers, asking for educational material for these classes, we decided to translate the HIPO simulator into English. We also wrote a paper on the Paper Computer, as well as translated another paper which describes how to introduce the notion of algorithms and their analysis, also through a hands-on, practical activity (we just can't avoid the excellent Waldorf principle of directing classes not just to the intellect…).

Here we describe HIPO and its most recent simulator, which can be run in any browser, and be dowloaded producing a local copy.

2. The HIPO structure

HIPO is a 4-digit, "fixed-word," decimal, single-address machine. It has 100 storage positions. Along this paper, we are going to use the excellent English word "storage," used in the beginning of computers, instead of "memory." We don't like the latter because it downgrades our memory and upgrades the computer storage. The fact is that nobody knows how our memory functions: to begin with, it – and our brain – lacks a fundamental characteristic that every logical circuit must have: synchronized pulses, provided by the computer's central "clock," which is in fact a central pulse generator. Furthermore, everybody may have the inner experience that our memory and thinking have capacities not found in a computer storage and CPU - see our papers on our web site. We have also used the expression "storage position" instead of the common expression "word." Again, we don't want to degrade one of the highest manifestations of humanness.

Each storage position has the format


where s is a "+" or "–"sign, and N is a digit between 0 and 9. So it is possible to represent numbers from –9999 up to +9999. Instructions use the same representation, with the format


where I and A are decimal digits. II represents the instruction code, and AA a storage address (from 00 to 99). An example of an instruction code is 21, which adds two numbers (old-timers will recognize it as the IBM-1620 correspondent code…).

As it may be seen, each instruction references a single address in storage. To add two numbers, it is necessary to store one of them in a special register, the accumulator. Old-timers will also recognize the structure of the first binary computers, which used one single register. The name "accumulator" derived from the fact that it was part of the computer's arithmetic unit, and where results of arithmetic operations would be stored, as in a display of a modern hand calculator.

One other register was common in the first binary computers: the index register, used for the efficient implementation of indexed variables ("arrays"). As we said, the original, 10-digit HIPO had an index register, which was very important for its use as a target language for the compiler construction projects we gave our students. But the pedagogical principle here is that one should have the simplest machine possible. In section 7 we expound some extensions of HIPO that may be described at the blackboard, after the students have understood the most basic principles of a computer's external logical structure.

Obviously, a single-address machine has a simpler structure than multiple-address machines. Since the IBM-360 and the Burroughs 5000 (beginning of the 60's) computers have had multiple registers, but our purpose was to introduce the simplest structure that could illustrate the basic concepts of computers.

There are no floating-point instructions. Neither are there instructions dealing with alphanumeric characters, that is, representing in storage characters, including letters, other than decimal digits. In section 7 we describe how they may be introduced at the blackboard, providing for the essential understanding on how the computer handles these structures.

3. Instruction set

In this section we give the instruction codes and describe their functioning, adding some educational observations. We are not suggesting that the instructor should describe each of them as below. We give their descriptions just to orient him/her. Probably a good occasion for describing one of them is when a student has some doubt about it. It is advisable to handout the students a sheet with a brief description of how to use of HIPO and its instructions. We also give abbreviations that could be used in an assembly language, or during classes when one wishes to refer to the HIPO instructions; they are represented in curled brackets {…}. Old-timers will again recognize old assembly language instructions.

3.1 Load/store

11  {LDA} Load the contents of the storage position with address AA into the accumulator.
12 {STA} Store the contents of the accumulator into the storage position with address AA.

Obviously, the contents of the storage position and of the accumulator are not changed by each instruction, respectively.

3.2 Arithmetic

21 {ADD} Add the contents of storage position AA to the accumulator, and leave the result in the accumulator.
22 {SUB} Idem, subtract.
23 {MUL} Idem, multiply.
24 {DIV} Divide the contents of the accumulator by the contents of storage position AA, and leave the quotient in the accumulator.
25 {REM} Idem, leaving the remainder of the (integer) division in the accumulator.
29 {REV} Reverts the sign of the contents of the accumulator, that is, + is turned to - and vice-versa.

When talking about these instructions, the instructor could refer to the fact that, as HIPO has only one address referenced in each instruction, it is necessary to load one of the terms into the accumulator. The interpretation of the instruction by the CPU makes automatic use of this term.

In the first 3 instructions, there is the problem of overflow, that is, when the result is greater than 9999 (independently of the sign). When this happens, the HIPO simulator displays an error message, showing the instruction, its address, the storage position referred to by it, the two terms that lead to the overflow, and stops. Execution has to be reinitiated.

In the divide and remainder instructions, there is the problem of a null divisor. If this happens, an error message is displayed, similar to the overflow message.

If the accumulator or the storage position contains the value "empty" (see 5.3), then there is also an error message.

3.3 Input/output

31 {INN} Input a number from the keyboard, and store into in the position AA.
41 {PRN} Print numerically the contents of the position AA.

During execution, the simulator displays an input/output window with two parts. The left-hand side has the title <INPUT> and the right-hand side <PRINTER>.

When an INN instruction is executed, the following message appears in the <INPUT> part:

Input a number in HIPO fomat
Examples of formats: +0010 –5000
Type a number:

A blinking cursor is then displayed to the right of the last line. The input must be given in the HIPO word format, that is, sNNNN followed by the Enter key. The simulator does not accept any other format. If the user tries to type a digit instead of a sign, a letter instead of a digit or anything other then Enter and BackSpace (for correcting previous digits or sign) in the respective places, nothing happens, that is, the cursor remains blinking. This is tricky: in general, the instructor has to call the attention to this fact.

There is an educational flaw in the present implementation: the input numbers remain in the input area after being used by the INN instruction. We consider it more faithful to a real computer if they disappear under normal execution. As we will see later, there is a "tracing" execution, where it would be all right if the input numbers would remain until scrolling makes them disappear.

The instructor should tell the students that in real computers the keyboard is not coupled to the display. The user sees what he is typing because print (or, better, display) instructions are executed for each input character, as we have done (for whole input numbers) in the demonstration programs (see section 5).

When a PRN instruction is executed, the number is displayed in HIPO format at the right-hand side of the window. Notice how there is a colored area representing the printing paper. It was drawn representing continuous paper with holes, as used in matrix printers (at the time of the HIPO implementations, there were no laser or ink jet printers…). When the printing "page" is full, it is scrolled upwards.

One educational observation. Old-timers have certainly found it strange that we didn't use the abbreviation RDN, meaning "read numerically…", instead of INN. The fact is that machines - and computers in particular - don't "read." They don't have eyes (or fingers, for Braille) as we do and use when we read. Again, we refuse to confuse what a machine does to our own activities. To begin with, nobody knows how we are able to form an inner image of what we see, but we know precisely how a machine detects something in its exterior.

3.4 Jump

50 {NOP} No operation.

This instruction is very important when programming in ML. Sometimes it is necessary to eliminate an instruction of a program that is being modified. Changing it to a NOP solves this problem. (We have included it in this section because it may be interpreted as an unconditional jump to the next storage position.)

51 {JMP} Unconditional jump to the instruction at address AA.
52 {JLE} Jump to the instruction at AA if the contents of the accumulator is less than or equal to zero.
53 {JDZ} Idem, different than zero.
54 {JGT} Idem, greater than zero.
55 {JEQ} Idem, equal to zero.
56 {JLT} Idem, less than zero.
57 {JGE} Idem, greater than or equal to zero.

If the Paper Computer play has been performed before as recommended, the instructor may tell the students that jump instructions in fact load the instruction pointer ("counter," for old-timers) with AA. It would also be nice to call the attention that, as HIPO has only one address referenced in each instruction, the value to be tested has to be loaded beforehand into the accumulator. Furthermore, we find it important to emphasize the difference between unconditional and conditional jumps.

3.5 Miscelaneous

70 {STP} Stop. When executing this instruction, HIPO stops and waits for any keyboard key to be pressed, returning to the command options menu (see section 5).

4. A HIPO simulator/interpreter

See a HIPO simulator (temporary version), programmed by Vitor Seiji Hariki in javascript; can be run in any browser. See the instructions on how to use it (idem).

5. A test program

The followin HIPO program, to be loaded starting at storage position 01, reads a sequence of positive numbers and calculates its sum. The sequence is ended by a negative number, not included in the sum:

01 +1130 [Initializes...]
02 +1240 [...sum with 0]
03 +3145 [Inputs a number]
04 +4145 [Outputs it]
05 +1145 [Loads the input into the accumulator]
06 +5611 [Tests it; if negative, jumps to position 11]
07 +1140 [Adds the...]
08 +2145 [...input...]
09 +1240 [ the sum]
10 +5103 [Returns to the input instruction]
11 +4140 [Outputs the sum]
12 +7000 [Stops]
30 +0000 [Used for the initialization of the sum]

6. Exercise

Modify the program of last section to calculate the product of a list of positive and negative numbers. The list is ended with a 0.