Prior Page     Next Page     This Chapter    Prior Chapter    Next Chapter





Programing the Hermes Computer

It is now time to turn away from describing the computing machine and try to use it. This is to convince you the while no Hermes Computer has ever been built, it is still conceptually capable of doing anything. And if it were built it would be a satisfactory computer to do anything that you wanted.

Programming using just the hexadecimal or decimal representation of instructions is possible, but tiresome.

Jump instructions are easier to remember if the conditions are specified in the mnemonic rather than in the field instruction.  So for the Hermes computer some additional mnemonics are defined which imply the value of the ccm (the gr field).


Jump Extended Operation Codes


The extended operation codes fill 2-bytes of the instruction rather that just one.  So
JMIX put 0x35 in the operation field and 0x04 in the gr (or ccm) field. So one needs only to additionally specify the addr-field and the xr-field.  Don't specify a gr-field for these instructions. Thus: /tl ''JMIX 0x001050[3]''
is the proper form for one of these extended operation codes.

Here is a little piece of code that saves the registers in the memory pointed at by general purpose register 14;


Saveregs Procedure (Ver. 1)

This is a pretty boring program. But it demonstrates the importance of the effective address computation. The calling program puts the address of a save area (array) in register 14 and then branches to the saveregs procedure. Saveregs uses register 14 to store successive registers. The procedure returns using the Jr register 15, with all the registers as they were at the subroutine jump.

Note that all the numbers in the program are given in decimal and the opcode is in mnemonics. This is so you can understand it, not because it is convenient to write programs in this form.

If you were to write this program for loading into the Hermes machine it would look like this:

Another way to do this same program, that is save the registers would involve writing a loop, the following is a general pattern for the machine program.



Saveregs Procedure (Ver. 2)

In the above I used symbolic lables (that is words) for addresses. This does not work on the Hermes machine but it is convenient to write programs this way. The program refers to STOREOP+4, STOREOP is the first byte in the ST operation that saves a register. So STOREOP+4 computes to an address that is the fifth byte of the instruction. A load half from the fifth byte of an instruction will give you the low order 16 bits of the instruction address.

As you write the Hermes programs to answer the programming problems in the exercises, you may get tired of changing addresses as you need to add an instruction here and there. It is then you will begin to use symbolic labels to mark locations in the program.

There is an important lesson in SAVEREGS(Ver.2), it showed how the machine could modify one of its own instructions by treating the machine instruction itself as data. Later it executes the very instruction it computed. At one time the bits were just data upon which we did arithmetic, in the next moment they were machine instructions. At any one moment data in a computer is what it is being used as. It can change from moment to moment.








Prior Page     Next Page     This Chapter    Prior Chapter    Next Chapter


Copyright © 1995 R. Uzgalis. All rights reserved.
Contact: buz@cs.aukuni.ac.nz