THE HIPO COMPUTER - A TOOL FOR TEACHING BASIC COMPUTER PRINCIPLES THROUGH MACHINE LANGUAGE

Valdemar W. Setzer
Dept. of Computer Science, University of São Paulo, Brazil
vwsetzer@ime.usp.br - www.ime.usp.br/~vwsetzer

Version 1.1 of Nov. 7, 2000. Refers to HIPO, English version 1.0

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 or C 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 the teaching of 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 (see the correspondent paper on our web site). 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 (text editors, spreadsheets, and more recently 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 our 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…). Both are also available on our web site.

Here we describe HIPO and its simulator, which is available in our web site (please use the links at the end of this paper to download its executable code, as well as the 2 demonstration programs described in section 6).

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

sNNNN

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

+IIAA

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 {JGT} Idem, greater than zero.
58 {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. Activating HIPO

Suppose the HIPO executable code (hipo.exe) is on directory c:\XYZ. To activate HIPO, use any of the following options:

a) Double click the entry hipo.exe on directory XYZ from Windows Explorer. A DOS window will be opened. If the Auto font option is active, then the window will open precisely in the correct size to fit the HIPO text windows. It is possible to maximize the DOS windows to obtain an enlarged font. The HIPO version thus activated is a restricted version (in fact, there is only one version, but what the user sees is a restricted one), with the last 3 main menu commands missing (see section 5).

b) Activate DOS from the Windows menu MS-DOS Prompt using the Start button (leftmost button at the bottom bar). In general, a DOS window with the prompt c:\WINDOWS> will appear. Change directory typing cd c:\XYZ Enter. Then type

hipo

or

hipo /t

The first option activates the HIPO restricted version. The second activates full HIPO, that is, with the full command options menu (see section 5).

c) Restart Windows (Start button then Shut Down option), using the option "Restart the computer in MS-DOS mode?" When the computer is restarted, the screen will be in DOS, without windows. Recipe (b) above should then be followed.

When using HIPO as an educational tool, we recommend using procedure (c), activating the restricted version before students come to the computers. There are 2 reasons for this recommendation:

i) If a DOS window is activated from Windows, students will have the possibility of playing with the mouse and other programs. For a while, we thought of implementing a Windows version of HIPO. But if we want the students to learn a specific subject, we should help them concentrating on that subject and not having to fight against their own desire of playing with the computer for other purposes. Restarting the computer in DOS mode prevents the simultaneous use of other programs (unless they restart the computer or issue an exit command; but then the instructor will notice the change at a first glance). We see here a fundamental pedagogical attitude: we think the instructor is not what is called in "progressive" educational circles a "facilitator." We consider a correct attitude for the instructor the role of orienting the students in their learning process, and not keep waiting for questions and letting them do whatever they wish at any time. Later on, the students will have the chance of playing with the HIPO instructions and programs, and there they should have the freedom which leads to (in this case, restricted) creativeness.

ii) The activation of the restricted version was developed because there were many problems created by the use of the 3 last command options described in section 5. They permitted storing into disk the program and data which are in storage, activating the automatic address generation during instruction and data loading into storage, and exiting HIPO. Many educational sessions using HIPO have demonstrated that students make a mess with these commands. For instance, they would (eventually inadvertently) store into disk a modified version of the demonstration programs, overriding the original file, they would not know how to revert the activation of automatic addressing during load (see 5.9) and would exit HIPO losing everything they had loaded into storage and without knowing how to activate the simulator again, besides falling into Windows attractive paws.

The restricted version permits exiting from HIPO in the following manner. In the main (command options) menu, press Ctrl+backspace. A message will appear asking for the confirmation of the wish to exit HIPO. Having confirmed it, a message will appear asking if the user wants to save the storage into disk, and then another message requesting the name of the file. We emphasize that the best educational procedure seems to be the instructor issuing Ctrl+backspace and deciding if storage should be stored into disk, under what file name.

5. The command (main) menu

When HIPO is activated, a first window appears, with a brief description and credits for its development and implementation. The next window is the main or command options menu. Commands are directives given to the simulator, which modify some parameters or activate different states of the machine, and should not be confused with program instructions. The up and down arrows may be used to move along the various commands. The one that is selected may be activated with the Enter key or a description (help) may be obtained pressing F10, as indicated on the lines below the commands.

In the sequel, we describe what each command does. We will have to repeat some of the contents of the help, but our reason for describing them is to call the attention to some educational aspects, and giving a more detailed picture of the simulator.

5.1 Input instructions and data into storage

When activated, HIPO enters a state of loading instructions and data into storage. If the automatic address generation is not active (see 5.9), the user has to type a 2-digit address (a mask prevents typing any other characters than digits), followed by a number in the HIPO format (idem, preceded by the sign). This number may be interpreted as an instruction or data (a number). It is very important that at some point the instructor ask the students how HIPO interprets (please don't use the expression "knows"; computers know absolutely nothing, they just store data and interpret instructions…) the contents of a storage position as an instruction or as a number. This depends on the state of the machine. If it is executing an instruction that uses data in a certain address, for instance in an arithmetic operation, then the contents of this address is interpreted as data. If the machine is reaching a certain storage position looking for the next instruction to be executed (coming from the previous one or having executed a jump), then its contents is interpreted as an instruction. It is a good occasion to tell the students that the idea of representing data and instructions in the same numerical (or symbolic) format represented a major advance in computers, and was due to John von Neumann; this type of computers are called "von Neumann machines." When students make or modify programs, sometimes the machine will reach a storage position containing data such as, e.g. +1000, which when interpreted as an instruction gives an invalid instruction code (10). HIPO will then display a message that the instruction is invalid. It is a good occasion to tell the students what we have just described.

When choosing this command, a special window is displayed. On the left appears an "L: " (for "Load"); on the right a list of all instructions with brief explanations on what they do. Below this list, indications on how to input addresses, data and instructions, or create an empty storage position (see 5.3 for an explanation on "empty") are displayed.

If the automatic addressing is activated (this is only possible in the full HIPO version), then an initial address will be asked for. Suppose the user gives 24 as the initial address. The same input window is then displayed but now with "L: 24 " and the user has to type a number representing an instruction or data (or space for "empty") that will be stored at position 24 as soon as Enter s pressed. After this, HIPO will automatically move to the next line and display "L: 25 ", again waiting again for a number or empty, and so on. As indicated in the last line of this window, the user has to press Esc to leave this load instructions/data window, returning to the main menu.

Now it may become clear why the option to turn automatic addressing on and off was eliminated from the restricted version. When students used automatic addressing, they had big difficulties re-entering some instruction or data that was wrongly typed, because the automatic address generation would not return to the desired address. The same problem arises if some piece of data should be loaded into an arbitrary address, which is far in the sequence of automatically generated addresses. Obviously, the option of imputing instructions and data could be repeatedly selected, giving each time an arbitrary desired initial address, but this is clearly a nuisance.

5.2 Execute the program which is in storage.

When selected, this command displays a message asking for the address of the initial instruction to be executed in the program. It would be interesting to call the students' attention to the fact that the first instruction to be executed may not coincide with the first instruction in storage (considering increasing addresses).

Given the initial address, HIPO enters a state of interpreting and executing instructions.

A "time limit" has been set to prevent the indefinite execution of loops: internally, there is a counter of number of executed instructions. When this counter reaches 2000, an error window is displayed. It would be interesting to suggest the students to create a loop, say with two instructions: a NOP and a JMP jumping to the NOP to see what happens. It would be also interesting to show that unfortunately CPUs don't have this feature (this shows how advanced HIPO is…). It was a standard feature of old mainframe operating systems; in fact, in the activation of each "task" or "job" (a collection of tasks), the user could specify a reasonable duration time. There were two possibilities: "true" time - the time it would take for the job or task to be executed, irrespectively of other programs being executed in a multiprogramming fashion. Or "wall" time, that is, using a normal clock (this would not discount the time the CPU would allocate to other programs). Unfortunately, recent operating systems are in certain aspects poorer than old ones…

The smallest loop is an unconditional jump instruction jumping to the address of that instruction. Unfortunately, the present version has a bug in this case, and the screen keeps flickering.

5.3 Clear storage.

When HIPO is activated, its storage positions are set to empty values. These are different from nulls such as +0000 and –0000, which are valid numbers. Whenever an instruction would operate with an empty value (such as load, arithmetic, print) there should be an error message. Unfortunately, there is a bug in the present version: the error message does not correspond to what it should (but the rest of the message window is fine and indicates that the contents of the addressed position is empty).

An empty value is indicated by the simulator through a special value, outside the permitted range (–9999 through +9999).

The clear storage command inserts empty values in all storage positions. If the students have played with the HIPO for a while and want to manually load a program and data, they should first clear the storage with this command.

5.4 List storage on screen.

This command produces, on the left, a vertical display of a section of storage positions and their contents (18 positions in each page). Empty contents are displayed as blanks. Scrolling may be done by single positions (using up and down arrows) and pages (using PgUp and PgDn). If all positions above a certain address are empty, the scrolling stops. This is what is implied by the displayed messages "if they exist" in the corresponding help window.

To the right of the list appears the same listing of instructions and abbreviated explanations as described in 5.1.

Another way of displaying storage contents is described in 5.7.

5.5 Load instructions and data from disk into storage.

This command permits loading into storage instructions and data from a disk file. The available HIPO files (with extension ".hip") are displayed in the next-to-last line of the window activated with this command. They are taken from the current DOS directory. Attention must be paid here. HIPO files don't need to be in the same directory as hipo.exe. But in order for this command to function properly, it is necessary to make the current DOS directory that one where the HIPO files to be loaded are located before activating hipo.exe. Supposing the XYZ directory as exemplified in section 4, then from a HHH directory where the HIPO files are located one should activate HIPO as follows.

c:\HHH>c:\XYZ\hipo (or \hipo /t)

This way this command will correctly display the HIPO file names at HHH.

To load a program, the user has to type one of the displayed names. A mask prevents using any other character than a letter or a digit, beginning with a letter. See 5.8 for more details and the problem of loading a program over an existing one.

5.6 Trace execution of each instruction. ( Inactive )

This command permits switching the HIPO simulator into ("active" appears to the right of the command) and out ("inactive") of a "trace" state, where descriptions permitting the debugging of a program are displayed for each instruction executed. These descriptions, displayed on the left of a window having the list of instructions to the right, are headed with the indication --==<Tracing…>==--. They refer to the situation before the execution of the instruction, but appear after the instruction has been executed.

The execution of an input instruction 31 (INN) displays a message asking for the input number, which appears also on the left side of the window, interspersed with the trace descriptions.

Attention: if the user interrupts the execution of a program being traced, through the use of Esc, thus returning to the main menu, and then tries to restart the program at the next address using the command "Execute the program which is in storage," the accumulator will be cleared to the empty value, thus eventually losing some value that would be used later.

Tracing is a very important means of debugging a program, so we recommend that the instructor demonstrate its use to the class while introducing the simulator.

5.7 Display storage on screen, in matrix form.

This command produces a window where the storage contents are displayed in matrix form, each line containing 10 storage positions. For some purposes, this form is more readable than the vertical listing described in 5.4 particularly when it is necessary to examine storage positions with data. For instructions it has the drawback of lacking the list of instructions displayed by the other command.

5.8 Store instructions and data in storage into disk

This command "saves" what is in storage into disk. A name for the file, to be stored in the present DOS directory (see 5.5), is requested. The simulator adds the extension .hip before saving.

The format of .hip files is extremely simple: it is a storage map, with one storage position per record (line), covering the contents of the first storage positions up to the last non-empty position used, without their addresses. Empty values are recorded as blanks. So it must be clear that it is not possible to load two parts of a program (or, for that matter, two different programs) from two different files, beginning with the first part (lowest storage positions). The first empty positions of the second part would clear the correspondent positions of the first. The contrary is true, though: if the highest storage positions (second part) are loaded first, then the first storage positions don’t erase the former.

This command does not exist in the restricted version of HIPO (see section 4). It was noted by various instructors that students would modify one of the demonstration programs (see section 6) and then store it into disk, thus overriding the original, correct version. To save a program, the instructor has to be called by the students; issuing a Ctrl+backspace he/she may exit HIPO saving the storage and choosing an appropriate name for their files.

5.9 Automatic address generation during manual load

This command toggles the automatic address generation during manual input of instructions and data into storage before executing a program (see 5.1). It was introduced because it was felt that for sequential load addresses, automatic address generation would facilitate this process and avoid mistakes (inserting some instruction or data in a wrong position). But it was also excluded from the restricted version because students had difficulties using the automatic feature (see 5.1). In fact, in general programs are not very extensive, so there is no problem with giving an address before typing each instruction or data.

5.10 Exit HIPO.

This command returns the control to DOS. If something was loaded into storage, HIPO will ask if the user wants to save the storage contents into disk. This was the reason why it was taken out of the restricted version (see 5.8).

6. Demonstration programs

Two demonstration programs accompany the present version of HIPO: prog1 and prog2. They received these uninformative names because the instructor may ask the students to deduce what they do.

Prog1 adds non-negative input numbers until a negative number is given. Then the sum of the former numbers is printed. This is exactly the implementation of the Paper Computer program (see the paper on it on our web site), where instructions were written in text form (see next section). Its first instruction is at position 01.

Prog2 counts and adds non-negative input numbers, until a negative numbers is given. Then it prints the count and the sum, in this order. Its first instruction is at position 05.

7. Additional pedagogical considerations

As we said, the ideal way of introducing HIPO is to let the students perform the Paper Computer play. In a subsequent class, the instructor can show that for a computer it would not be very efficient to interpret instructions given in long text forms, and that they can be codified. He uses then the HIPO set of instructions to codify the Paper Computer instructions, deriving prog1 (see section 6). We used to handout a sheet of paper showing a block diagram representation of that program, with the corresponding HIPO instructions with their abbreviations to the right. It is now time to go to the lab and show the students that there is a computer that executes those instructions, disguised under the external cover of an IPM-PC… Students could use prog1 to get some experience with the HIPO commands, tracing instructions, etc. Then the instructor may ask the students to make a modification in the program, namely making it perform the multiplication of the input numbers, instead of their summation. This is a very interesting problem, because in general students just change the 21 {ADD} instruction to 23 {MUL}. They become very surprised when the result is always +0000, independently of the input numbers. The instructor should leave some time to see if they come to the right conclusion: the initialization of the storage position containing the result should be +0001 (the neutral element for the multiplication operator) instead of the original +0000 (the neutral for the sum).

After this, the instructor may tell the students to load prog2 and deduce by themselves what it does. Some students fuss with the program instructions, others try various inputs. After it is discovered or explained that the program adds non-negative numbers until a negative one appears, and also counts how many numbers were read, the instructor may discuss the implementation of counters. Then he could ask the students to modify the program: using the sum and the count, calculate the average.

With these examples the instructor would be implementing one of our basic ideas on teaching something about programming. We think that it is not correct to force every high school student to learn how to develop and test a program. Not every person can master the symbolic-logical, algorithmic reasoning to develop programs. What should be taught is what programs are. For this, it suffices doing some simple modifications in given programs.

Without knowledge of what programs are, it is impossible to understand what a computer really is, what it means to be a programmer, problems computers cause upon programmers and users, etc.

As it was the case with the Paper Computer, but now with a much clearer understanding, the teaching of general application software such as text editors and spreadsheets may be accompanied by explanations on how texts and formulas may be internally represented. For the way the computer may execute a formula, maybe one day we will write a paper showing how this can be easily done using stacks of operators and operands (Samelson&Bauer algorithm).

To use the HIPO structure to clarify how computers may store lines of text, it is necessary to show how would it be possible to represent letters and other characters in a decimal machine such as HIPO. This is very easily done at the blackboard: just codify each character using 2 digits, e.g. 01 for A, 02 for B, etc. This way, each storage position may represent two adjacent characters (the sign is ignored). A line of n characters would be represented by a sequence of consecutive n/2 storage positions. Special input/output instructions have to be built into the HIPO "hardware." For instance, a 32 {PRA} could print in the so-called "alphanumeric" mode the number of storage positions indicated by the number stored in the accumulator, starting at the AA address referred to by that instruction. Or it could use the first position referred to by AA as the number of positions that should be used by the instruction after this first one. Or a special code such as 00 (that’s why we defined the code for A as 01…) could be reserved to indicate the end of a string of coded characters. It is important to emphasize that if someone just reads the contents of some storage position, it is impossible to decide if it contains a regular decimal number or two coded characters (or, for that matter, an instruction). It is the instruction being executed that makes this distinction. That is the reason why we used the abbreviation INN for instruction 31: now it should mean "INput Numerically into storage position AA." On the other hand, 32 {PRA} should mean "PRint Alphanumerically the sequence of storage positions beginning at AA."

Another problem is how to deal with large numbers. How should 20,000 dollars be represented? For this the instructor should introduce the notion of floating point representation. In HIPO, this could be done considering the two leftmost digits of a storage position as an excess 50 exponent, and the two rightmost digits as the mantissa, for example considering a decimal point before the leftmost of these two. The sign should be considered the sign of the mantissa. So 20,000 would be represented by +5520 that is, 0.20 times 10 to the power 5 (55-50). -120000 would be represented by –5712, 0.24 would be +5024, -0.001 would be -4710. But this is unsatisfactory as far as the precision is concerned. So we could build the HIPO "circuitry" to consider each floating point number as being formed by two consecutive storage positions: the first works as in the single position solution, and the second as the continuation of the mantissa, now with a total of 6 digits. Or we could use 3 storage positions, having mantissas with a precision of 10 digits (which could be called, as in real computers, "double precision"). In a similar way as with the alphanumeric representation, the instruction being interpreted and executed would treat the storage positions in the adequate way. For instance, 61 {FLA} could be the FLoating Add instruction, using two words instead of just one used by 21 {ADD} which should now mean "ADD the integer in AA to the accumulator." Ops, what about the accumulator? HIPO circuitry could be expanded to use accumulators with 8 or 12 digits plus a sign, instead of just 4. Students may be told that some old computers used different accumulators for storing terms and results of floating point arithmetic operations (such as the IBM/360 – is this feature still in use?), because different arithmetic units dealt with integers and floating point numbers. On the other hand, the Burroughs 5000 and 6000 series used only floating point numbers.

One important aspect that could be touched during the class on HIPO is the fact that it is a decimal machine, and not a binary one. The instructor should call the attention that digital computers must be built around any numeric representation whatsoever. Using binary systems is just a technical, electronic engineering convenience. For this, an interesting pedagogical analogy is to ask the students if they have any doubt on saying that the lights in the class are on or off. But if there would be a dimmer with ten different, discrete positions, just by looking at the (incandescent) lamps it would be very difficult to decide which intensity they had, in a scale from 0 to 9. In the same way, it is much easier to build electrical circuits to detect if there is or there isn't a current or a voltage in a certain point, than detecting which intensity the current or voltage is in any scale larger than 3. (For the base 3, there could be 3 very distinct states: a negative, a null and a positive electrical current or voltage; once a base-3 computer was built in Poland.) But the base 2 permits the simplest possible circuits.

Another interesting educational point is to call the students' attention to the fact that, as HIPO demonstrates, computers don't take decisions: they make logical choices. Every choice has to be expressed numerically (or, more generally, symbolically), as in our conditional jumps. Humans take decisions, computers make logical choices. Whenever we delegate a decision to a computer, we are reducing the decision to a shadow of what it probably should be.

Finally, an important concept may be introduced using the fact that HIPO is being simulated in an IBM-PC: every computer may be simulated by any other computer, as long as there is enough capacity for that (storage and disk space). That is, computers are in this sense universal machines.

8. Conclusions

HIPO gives the students a unique opportunity of learning and practicing fundamental computer concepts. These concepts can only be understood and practiced through a machine language. Joseph Weizenbaum recognized these facts when he chose to introduce basic notions of computers in his wonderful book Computer Power and Human Reason: from Judgement to Calculation, San Franciso: Freeman, 1976. But he went even farther than we did: he used a model of a Turing Machine, with a tape implemented through a roll of toilet paper. Unfortunately, Turing Machines are too basic, too far from what one would expect from computers. Maybe it would be interesting to ask the students: could a computer be even simpler than HIPO? And then show that a Turing Machine is the most fundamental universal abstract machine (that is, one that changes nothing in the concrete, real word). A Turing Machine is a purely abstract machine (that is, there can be no real implementation of it, because it has infinite storage). It uses an infinite input/output tape where the machine can write symbols, move the tape to the right or to the left, and be in a finite number of different states. The state the machine is and the actual input symbol determine the change of state, the writing on the tape and the subsequent tape movement. A simple program to do additions in a base 1 numbering system can be briefly described (just move the 1s from one term to the end of the other). It is surprising that such a simple device can do all kinds of computations.

The teaching of a simple machine language provides a wonderful justification for the need of higher-level languages. The students should notice how difficult it is to insert a new instruction: it is necessary to jump to the previous address of another location where that instruction is loaded, preceded by the instruction replaced by the jump, followed by a jump back to the instruction following the original one. Moreover, if the students have some knowledge of a machine language, it is possible to show them how high-level constructs such as if…then…else… or while…do… are translated into simple ML constructs using conditional and unconditional jumps.

The HIPO computer could be extended to accommodate further educational requisites. For instance, Hendrik Ens from the Escola Waldorf Rudolf Steiner de São Paulo made his own implementation, with instructions using the RS232 serial port, sending through it pulses that would activate LEDs and other circuitry, for the use of his senior high school students.

We would like to thank Charles Tolman for having requested our educational material. This gave us the motivation to translate, write and implement some material that we have always found of great educational interest. Now that they are in English, and on the Internet, let's see if the world recognizes their usefulness. Very very few Brazilians did.

We would appreciate any comments on the written material and on the HIPO simulator.

9. Downloading the simulator and demonstration programs.

If the reader with an access to the Internet wishes to download the HIPO simulator for the IBM-PC, it suffices to activate the following URL:

www.ime.usp.br/~vwsetzer/hipo/hipo10.exe

The browser should ask for a directory where to save the file (with 44kb in its present version). Section 4.5 describes the problems involved with such a directory.

The version in Portuguese can be downloaded from

www.ime.usp.br/~vwsetzer/hipo/hipop10.exe

To download the demonstration programs (1kb each), activate

www.ime.usp.br/~vwsetzer/hipo/prog1.hip

and

www.ime.usp.br/~vwsetzer/hipo/prog2.hip

but they will be loaded as texts in the browser window (both on Netscape and Internet Explorer). In this case, save the displayed texts in files with names prog1.hip and prog2.hip respectively, as text files. Probably the browser will add a specific extension (.txt on Internet Explorer), which must be later eliminated. The observations made in section 5.5 should be taken into consideration when choosing a directory for these files.

The hipo.exe code was generated by us using Turbo Pascal 5 for DOS from a source code that was implemented by our students a long time ago, which has been now modified and extended by us. The present Portuguese version source code is the original one they developed at that time. We guarantee that both are safe of viruses. The source codes and Turbo Pascal 5 (which, according to recent information, is in the public domain) may be requested through e-mail.