SimHYMN Machine Code Example Program

SimHYMN Example Machine Code Program

This is an example machine code program. Here is an analysis, line by line, with the program starting at address 00000 because the PC starts with that value.

00000 1001110 LOAD 11110 - This first instruction does a load from 11110. However, a load from 11110 will access the memory-mapped input device (the keyboard), print a ? in the I/O window, and wait for the user to enter a value between -128 and 127 decimal. The value typed will appear in the I/O window and will be transferred to the AC (Accumulator) after the user hits the Enter key. The program will proceed to the next instruction.

00001 10110100 STOR 10100 - This instruction takes the value the user typed in from the AC and stores it in memory location 10100 (at the top of the third column). The program proceeds to the next instruction in memory.

00010 10011110 LOAD 11110 - This instruction is identical to the first instruction. The user sees a question mark in the I/O section, types in a number, and that value is placed in the AC. The program proceeds to the next instruction.

00011 11010100 ADD 10100 - The first number the user entered (which was put into memory location 10100) is fetched from memory and added to the second value the user entered (which is in the AC as a result of the previous instruction). The result is placd in the AC. The program proceeds to the next instruction.

00100 10111111 STOR 11111 - This does a STOR of the value in AC to 11111. However, a STOR to 11111 activates the memory-mapped output device which prints the result to the I/O window. This printed value is the sum of the two numbers the user entered as a result of the previous ADD instruction. The program proceeds to the next instruction.

00101 00000000 HALT - The program stops.

Here is the result of a run of this program where the user enters 5 and 8.

SimHYMN Machine code execution example

Back to Top of Help