HOW TO USE THE SEIJI HARIKI HIPO SIMULATOR

Valdemar W. Setzer
www.ime.usp.br/~vwsetzer
This version: Oct 6, 2019

1. Introduction

For a description of the HIPO virtual computer, which was developed to be used in introductory courses on programming, showing what a machine language and its logics are, see

www.ime.usp.br/~vwsetzer/HIPO/hipo-descr.html

The simulator, programmed by Victor Seiji Hariki, may be loaded into a web browser presently from

https://seijihariki.github.io/HIPO-simulator/#/

It may be downloaded using the browser Save command, for later local use.

2. Using the simulator

  1. At left, one may see three windows, labelled Code (this title is presently missing), Input and Output. At their right there is a HIPO storage map, already initialized with +0000 in every storage position.
  2. To insert code or data into the storage map, click with the right mouse key on a cell. A menu appears; the last option permits the editing of a storage cell. If chosen, a window is opened allowing typing of its desired contents. It is not necessary to type a HIPO word with signal (+ or -) and 4 digits. So one may type 12 or -12, converted automatically to +0012 and -0012 respectively.
  3. Before running a code, one may insert instructions in the code window, one per line. The first line has the implicit adress 0, the second one 1 and so on, unless an address is specified before the instruction, such as 5 +2115. The instruction +2115 will be inserted into storage position 05.
  4. In the upper menu, the rightmost field "Reading pointer", shows the line number that is going to be read in the next input instruction (+31XX).
  5. Input lines may be deleted using the Delete key.
  6. Output (+41XX) is written sequentially on the Output window, one per line. In the present version, it can be erased with the Clear I/O button.
  7. To run a program, set the field "Pointer position" to the storage address of the program's first instruction to be executed.
  8. Buttons Run and Step produce a whole or stepwise (instruction by instruction) execution of the program presently displayed in the storage map.
  9. The Reset button resets all storage proisitons to +0000, and the Instruction pointer, Accumulator and Reading pointer fields to 0. It does not affect the Code, Input and Output windows. The Clear button clears everything.
  10. The window Code allows programming and editting a code; the button Translate inserts it into the storage to be run.

3. Writing code into the Code window

Suppose one has typed the following program (reads data from the Input window and prints data into the Output window indefinetly -- use the Step button to test it); one may simply copy the following 4 lines and paste them into the Code window and then hit the Translate button to transfer it into the HIPO storage:

1 +3145
+4145
+5101
45 999

Notice that the three instructions will be inserted into storage positions 1, 2 and 3 and the number +0999 into position 45. Just to remember, +31XX, +41XX and +51XX are, respectively, Input, Print and Unconditional jump instructions.

Suppose some input is written in the Input window, e.g.

12
-13
14
155

Now set the IP (Instruction pointer) to 1, the address of the first instruction (+3145). Hitting the Step button produces the execution of this input instruction. If the input window is empty, an error will appear i the message window (below the storage map window). Hitting Step again will produce the execution of the program.

Rules:

1. In the Code window one may write a HIPO code, one instruction or data per line. Hint: one may save a program from the Code window into the Windows (or other operating system) transfer area or into some file, reloading it later.

2. It is necessary to use the +XXXX instruction format.

3. The button Translate can be activated at any time.

4. If no address is inserted before the first instruction or data at the Code window, its address will be set at 00. Subsequent instructions or data without preceeding addresses will be inserted into the following storage positions. If there is an address preceeding an intruction or data, subsequent instructions or data wihtout addresses will be inserted into subsequent addresses. 

5. In the example above, position 45 was initialized to +0999 just as an example on how to insert data into storage.

6. The first line at the Code window has to have some instruction or data!!! Otherwise, a message

Error:Label undefined not found!!

will appear. One has to leave this window by hitting its OK button.

7. Comments may be inserted after an instruction or data, preceeded by a ; sign or enclosed in brackets [...].

4. The HIPO instruction set

Notation: The first column shows the mnemonic code in Portuguese (which can be used when programming in the present assembly language, see next section). The second column contains the mnemonic codes in English, as specified in the hipo-descr page referred to in the Introduction. The third column contains the HIPO instruction codes. The fourth column contains a concise description of the instruction. [XX] should be read "the contents of storage position with address XX"; Acc: the accumulator; [Acc]: contents of the accumulator. <-- stands for "receives".

Port
Eng
Code
Meaning
CEA LDA +11XX Acc <-- [XX]
CAE STA +12XX XX <-- [Acc]

Som

ADD +21XX Acc <-- [Acc] + [XX
Sub SUB +22XX Acc <-- [Acc] - [XX]
Mul MUL +23XX Acc <-- [Acc] * [XX]
Div DIV +24XX Acc <-- [Acc] / [XX]
Rem REM +25XX Acc <-- [Acc] % [XX] (remainder)
Rev REV +29XX XX <-- -[Acc]
Lei INN +31XX XX <-- [input]
Imp PRN +41XX Output <-- [XX]
Nop NOP +50XX No operation
Des JMP +51XX Unconditional jump to instruction at XX
DNI JLE +52XX If Acc<=0 jump to XX
DDZ JDZ +53XX If Acc<>0 jump to XX (<>: different than)
DPo JGT +54XX If Acc>0 jump to XX
DZe JEQ +55XX If Acc=0 jump to XX
DNe JLT +56XX If Acc<0 jump to XX
DPI JGE +57XX If Acc>=0 jump to XX
Par STP +70XX Stop

For an explanation of each instruction, see

https://www.ime.usp.br/~vwsetzer/HIPO/hipo-descr.html

5. Writing assembler code

The Code window permits writing instructions using the HIPO assembler language. Hitting the Translate button produces the corresponding machine code, which is loaded into the storage unit. Unfortunately, present mnemonic codes, given in the previous section, are only in Portuguese. Using codes in English is being planned.

5.1 Instruction format

XX Label Mnem Arg

where

  • XX is the HIPO address where this instruction is going to be loaded. If the subsequent instructions don't have an address XX, they will be automatically be loaded into consecutive addresses.
  • Label is an optional name beginning with a letter. If followed by a number X or XX, this number will be assigned to the label.
  • Mnem is the mnemonic code of the instruction, either in Portuguese or English.
  • Arg (for "argument") is a storage address of the form X or XX, or a label indicating some storage position.
  • Comments may be inserted after the contents of each line, preceeding it with a ; or can be inserted anywhere in a line if enclosed by [...].

5.2 Data format

XX Label Value

  • XX as above
  • Label is a name beginning with a letter; if this laber is used afterwards, it will be replaced by XX
  • Value is the initial value wich will be stored into position XX

5.3 Assembler code example

The following assembler code example generates a program that inputs a list of non-negative numbers, prints each number and produces their sum. The list has to be ended by a negative number, which is not included into the sum.

When the following program is copyed into the Code area and the Translate button is hit,

1 CEA Zero
CAE Sum
Back Lei Num
Imp Num
CEA Num
DNe End
CEA Sum
Som Num
CAE Sum
Des Back
End Imp Sum
Par 00
30 Zero 00
40 Sum 00
45 Num 00

it generates the following code loaded into the storage:

01 +1130
02 +1240
03 +3145
04 +4145
05 +1145
06 +5611
07 +1140
08 +2145
09 +1240
10 +5103
11 +4140
12 +7000
30 +0000

This HIPO code can be directly copied and pasted into the Code area; hitting Translate will load into the storage unit extactly the same code as the code generated by the assembly code above.