Prior Page
Next Page
This Chapter
Prior Chapter
Next Chapter
Running Programs on the Hermes Computer
The last section described a language called assembly language that
would allow programmers the ability to more easily control the
Hermes Computer.
Unfortunately Hermes Corp., maker of our computer, has
not gotten around to writing their assembler yet.
They have only provided a primitive loader which will let you load
the machine memory and then start the machine running at some
arbitrary place.
I called them up and complained, but they told me a pre-release
version of the assembler would only be available after a couple of months
and that even then it was likely to be pretty unreliable for sometime.
So we will have to make do with what we have.
The Hermes loader program translates ASCII versions of commands in a file
and loads them into Hermes memory;
it then executes the loaded program on the Hermes computer.
Each ASCII load file consists of data and instructions on how to load and
execute programs and data on the machine.
All files are loaded into the same memory and executed together,
so later elements with the same load address will overwrite earlier
ones if they overlap.
The loader accepts a fairly free format, which is defined a little later
in the section `Loader Data'.
After loading the memory, the Hermes computer starts executing
in the place specified by the loader data.
Hermes Computer Limitations
The machine was ordered with 1 meg of memory but
only ¼ meg was actually delivered.
The Hermes Corp. says it is having a hard time finding memory.
There is only keyboard input and CRT screen output planned for the machine,
but currently even these were not delivered.
Again the company is going to do a hardware update in a couple of months
and this hardware will then work.
Currently the only way to see any computer results is to end the
program with a FMCK instruction and examine the register and memory
dump for appropriate results.
Additional Hermes Computer Features
The Hermes machine comes with some additonal operations
all of which use op-code 0x7c.
Different instructions depend on the value of the gr register field.
These instructions include:
Options to the Hermes Memory Loader.
Allowable options on the command line are
A -v invokes the verbose option.
Makes the loader list the input files and associates a hex machine
address with each line of loaded data.
A -t invokes the trace instruction execution option.
This turns the trace function of the machine on prior to execution.
Tracing causes information to be output after each executed instruction.
The output includes a hex version of the instruction, the value
of the general register referred to in the instruction, the effective
address computed, the contents of memory at that address if such
an address exists, and the condition codes. If memory or the registers
change as a result of the instruction then the new contents are also
given.
A -x invokes the extra memory dump before execution option.
This causes the contents of memory to be output in hexadecimal, decimal,
and text form before the execution of the program. This provides an easy
way to check that the loader loaded what you intended.
Example output from both the -v and -t options used in conjunction
with a simple test program is given below.
Hermes Loader Data
The loader uses the first character on a line as a flag
to determine the type of data on the line.
Lines that start with white-space or // are comments.
Normally these lines are not printed; but if the -v (verbose) option
is given then the loader prints both comments and the address and
data stored in memory.
Lines that start with L or l contain an address at which
to start loading the Hermes machine.
This address can be in decimal, octal, or hexadecimal.
Decimal numbers are just given as numbers, octal numbers must start
with a 0, and hexadecimal numbers must start with 0x.
Lines that start with X or x contain an address at which
execution should begin.
The address uses the same conventions as load address line.
Lines that start with > contain `words' to be loaded into memory
starting at the current load address.
After each word is loaded the current load address is incremented
by the number of bytes stored.
Data words in a load line can be hexadecimal, text, mnemonics,
or word constants (in octal, decimal, or hexadecimal).
There can be more than one type of word on a single load line.
The word `//' on a load line starts a comment that is terminated
by the end of line.
Load data uses a slightly different convention from L and X lines
because most data load data is hexadecimal.
A word that starts with a digit or the small letters `a' to `f' is
assumed to be a hexadecimal value to be loaded into memory.
Every two characters in a hexadecimal word becomes a single byte.
Hexadecimal words should always contain an even number of characters.
A word that starts with a double-quote (") starts a text-word.
A text word can contain blanks and it continues until a matching
double-quote is found. Neither the beginning nor the ending double
quote is loaded into memory.
Characters within the double quotes are loaded one byte per character.
A few special two character escape sequences (which represent a single
memory character) are available in text words:
`\\' represents \, because we need a representation for the
back-slash character;
`\"' represents double-quote,
becasue we need a representation for the text marker character;
`\n' represents a new-line, because it difficult to represent otherwise;
`\t' represents a tab, because it is difficult to tell if you have one
or several blanks;
`\r' represents a carriage-return character, because like new-line
it is difficult to represent otherwise;
` ' represents a hex 0x00 character, this is commonly used as an
end of text marker.
A word that starts with a hash-mark (#) represents a full word
(4-memory-byte) value,
the # must be immediately followed by a numeric constant in
octal (starts with 0), decimal(starts with a digit), or hexadecimal
(starts with 0x).
A word that starts with an upper-case letter `A' to `Z' represents
a machine mnemonic. This represents either 1 or 2 bytes of data
in the instruction, depending on the mnemonic. So for example
the word
LA represents the single byte value 0x0b, the machine op-code
equivalent of LA.
Whereas a JEQ represents a two byte value 0x3520, this is the
machine op-code, 0x35, and the condition mask, 0x20, for the TST
instruction.
Small Example of Hermes Loader Input Data
Loader data is written by a programmer and put in a file
that the Hermes computer loader will use to load the memory
of the machine.
The actions of the Hermes computer are completely determined by the
data put in the loader file, this is the way a programmer controls
the computer.
Here is an example of what a programmer would write and put
into a file for the loader to load.
  HERMES TEST PROGRAM
  Load program values
L 0x1000
  loaded value // comments
> 0b 10 00 000001 // LA 1, 1
> 0b 20 00 000002 // LA 2, 2
> 0b 30 00 000022 // LA 3, 34
> 08 20 00 002000 // ST 2, 0x2000
> 10 30 00 002000 // ADD 3, 0x2000
> 05 40 00 001700 // L 4, 0x1700
> 05 50 00 001704 // L 5, 0x1704
> 05 60 00 001708 // L 6, 0x1708
> L 70 00 00170c // L 7, 0x170c
> DIV 60 00 001608 // DIV 6, 0x1608 (by =2=)
> L 80 00 00160c // L 8, 0x160c
> MUL 80 00 001630 // MUL 8, 0x1630 (by =12=)
> L a0 00 001600 // L 10, 0x1600
> SUB a0 00 001604 // SUB 10, 0x1604
> ATOI b0 00 001800 // ATOI 11, 0x1800
> ITOA b0 00 001810 // ITOA 11, 0x1810
> FMCK 00 00 000000 // FMCK
  Load some number values
L 0x1600
> #0x00 #01 #02 00000003
> 00000004 00000005
> 00000006
> 00000007
> 00000008
> 00000009 #012 #11 #12 #13
> #14 #15 #0x10
> #17
> #18
  Load all the byte values
L 0x1700
> 00010203 04050607 08090a0b 0c0d0e0f
> 1011 1213 1415 1617 1819 1a1b 1c1d 1e1f
> 202122232425262728292a2b2c2d2e2f
> 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
> 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
> 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
> 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
> 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f
> 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f
> 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f
> a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af
> b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf
> c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf
> d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df
> e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef
> f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff
  Load a string value
L 0x1800
> "1451300"
Example Output from the Hermes Computer
The output caused by the -v flag comes from the loader.
The loader tells you where the line was loaded (as a hexadecimal address)
followed by a copy of your specification for the line and any comments.
If you have put one instruction per line you can use this information
to go directly to the dump to examine its memory version.
Independent comment and blank lines from the input are also written out.
Following the loader output is the trace output from the execution
of the program. All numbers output in the trace are hexadecimal.
Following the trace output is the a hexadecimal-decimal-text `dump'
of the machine registers and memory. This is caused by an abnormal
end to the program. After normal termination this data would not
be printed.
Loader Output caused by the -v flag:
  HERMES TEST PROGRAM
  Load program values
Loading at 0x001000
  loaded value // comments
0x001000:  0b 10 00 000001 // LA 1, 1
0x001006:  LA 20 00 000002 // LA 2, 2
0x00100c:  LA 30 00 000022 // LA 3, 34
0x001012:  ST 20 00 002000 // ST 2, 0x2000
0x001018:  ADD 30 00 002000 // ADD 3, 0x2000
0x00101e:  L 40 00 001700 // L 4, 0x1700
0x001024:  05 50 00 001704 // L 5, 0x1704
0x00102a:  L 60 00 001708 // L 6, 0x1708
0x001030:  L 70 00 00170c // L 7, 0x170c
0x001036:  DIV 60 00 001608 // DIV 6, 0x1608 (by =2=)
0x00103c:  L 80 00 00160c // L 8, 0x160c
0x001042:  MUL 80 00 001630 // MUL 8, 0x1630 (by =12=)
0x001048:  L a0 00 001600 // L 10, 0x1600
0x00104e:  SUB a0 00 001604 // SUB 10, 0x1604
0x001054:  ATOI b0 00 001800 // ATOI 11, 0x1800
0x00105a:  ITOA b0 00 001810 // ITOA 11, 0x1810
0x001060:  FMCK 00 00 000000 // FMCK
  Load some number values
Loading at 0x001600
0x001600:  #0x00 #01 #02 00000003
0x001610:  00000004 00000005
0x001618:  00000006
0x00161c:  00000007
0x001620:  00000008
0x001624:  00000009 #012 #11 #12 #13
0x001638:  #14 #15 #0x10
0x001644:  #17
0x001648:  #18
  Load all the byte values
Loading at 0x001700
0x001700:  00010203 04050607 08090a0b 0c0d0e0f
0x001710:  1011 1213 1415 1617 1819 1a1b 1c1d 1e1f
0x001720:  202122232425262728292a2b2c2d2e2f
0x001730:  30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
0x001740:  40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
0x001750:  50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
0x001760:  60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
0x001770:  70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f
0x001780:  80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f
0x001790:  90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f
0x0017a0:  a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af
0x0017b0:  b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf
0x0017c0:  c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf
0x0017d0:  d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df
0x0017e0:  e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef
0x0017f0:  f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff
  Load a string value
Loading at 0x001800
0x001800:  "1451300"
Execution started at 001000
Trace output caused by the -t flag:
adddress  instruction effective mem (gr) changed condition
  address contents contents to code
001000: 0b-01-00-000001 [000001]00000000 (1)00000000-->00000001 CCr=2
001006: 0b-02-00-000002 [000002]00000000 (2)00000000-->00000002 CCr=2
00100c: 0b-03-00-000022 [000022]00000000 (3)00000000-->00000022 CCr=2
001012: 08-02-00-002000 [002000]00000000-->00000002 (2)00000002 CCr=2
001018: 10-03-00-002000 [002000]00000002 (3)00000022-->00000024 CCr=1
00101e: 05-04-00-001700 [001700]00010203 (4)00000000-->00010203 CCr=1
001024: 05-05-00-001704 [001704]04050607 (5)00000000-->04050607 CCr=1
00102a: 05-06-00-001708 [001708]08090a0b (6)00000000-->08090a0b CCr=1
001030: 05-07-00-00170c [00170c]0c0d0e0f (7)00000000-->0c0d0e0f CCr=1
001036: 13-06-00-001608 [001608]00000002 (6)08090a0b-->06068707 CCr=1
  (7)0c0d0e0f-->00000001
00103c: 05-08-00-00160c [00160c]00000003 (8)00000000-->00000003 CCr=1
001042: 12-08-00-001630 [001630]0000000c (8)00000003-->00000000 CCr=2
  (9)00000000-->00000024
001048: 05-0a-00-001600 [001600]00000000 (a)00000000-->00000000 CCr=2
00104e: 11-0a-00-001604 [001604]00000001 (a)00000000-->ffffffff CCr=4
001054: 32-0b-00-001800 [001800]31343531 (b)00000000-->00162524 CCr=1
  "1451300 "
00105a: 31-0b-00-001810 [001810]00000000-->2b303030 (b)00162524 CCr=1
  -->"+00001451300"
001060: 00-00-00-000000 [000000]00000000 (0)00000000-->00000000 CCr=1
Output caused by the Abnormal Termination of the program.
Hermes machine stopped after 60 machine cycles.
FMCK instruction stopped Hermes.
Status Reg: 0x10001066
Regs  0 to 3 0x00000000 0x00000001 0x00000002 0x00000024
  0 1 2 36
  "...." "...." "...." "...$"
Regs  4 to 7 0x00010203 0x04050607 0x06068707 0x00000001
  66051 67438087 101091079 1
  "...." "...." "...." "...."
Regs  8 to 11 0x00000000 0x00000024 0xffffffff 0x00162524
  0 36 -1 1451300
  "...." "... "
Regs 12 to 15  0x00000000 0x00000000 0x00000000 0x00000000
  0 0 0 0
  "...." "...." "...." "...."
Hermes Memory (0.25 megabyte machine; last address: 0x03ffff):
Address  Values in hexadecimal Values as text
  Value of 4 byte word in decimal
0x000000:  00000000 00000000 | 00256225 03327103 .........%b%.2q.
  0 0 | 2449957 53637379
0x000010:  00000000 00000000 | 00000000 00000000 ................
  0 0 | 0 0
254 lines same as above
0x001000:  0b100000 00010b20 | 00000002 0b300000 ....... .....0..
  185597952 68384 | 2 187695104
0x001010:  00220820 00002000 | 10300000 20000540 .". .. ..0.. ..@
  2230304 8192 | 271581184 536872256
0x001020:  00001700 05500000 | 17040560 00001708 .....P.....`....
  5888 89128960 | 386139488 5896
0x001030:  05700000 170c1360 | 00001608 05800000 .p.....`........
  91226112 386667360 | 5640 92274688
0x001040:  160c1280 00001630 | 05a00000 160011a0 .......0........
  369889920 5680 | 94371840 369103264
0x001050:  00001604 32b00000 | 180031b0 00001810 ....2.....1.....
  5636 850395136 | 402665904 6160
0x001060:  00000000 00000000 | 00000000 00000000 ................
  0 0 | 0 0
89 lines same as above
0x001600:  00000000 00000001 | 00000002 00000003 ................
  0 1 | 2 3
0x001610:  00000004 00000005 | 00000006 00000007 ................
  4 5 | 6 7
0x001620:  00000008 00000009 | 0000000a 0000000b ................
  8 9 | 10 11
0x001630:  0000000c 0000000d | 0000000e 0000000f ................
  12 13 | 14 15
0x001640:  00000010 00000011 | 00000012 00000000 ................
  16 17 | 18 0
0x001650:  00000000 00000000 | 00000000 00000000 ................
  0 0 | 0 0
10 lines same as above
0x001700:  00010203 04050607 | 08090a0b 0c0d0e0f ................
  66051 67438087 | 134810123 202182159
0x001710:  10111213 14151617 | 18191a1b 1c1d1e1f ................
  269554195 336926231 | 404298267 471670303
0x001720:  20212223 24252627 | 28292a2b 2c2d2e2f !"#$%&'()*+,-./
  539042339 606414375 | 673786411 741158447
0x001730:  30313233 34353637 | 38393a3b 3c3d3e3f 0123456789:;<=>?
  808530483 875902519 | 943274555 1010646591
0x001740:  40414243 44454647 | 48494a4b 4c4d4e4f @ABCDEFGHIJKLMNO
  1078018627 1145390663 | 1212762699 1280134735
0x001750:  50515253 54555657 | 58595a5b 5c5d5e5f PQRSTUVWXYZ[\]^_
  1347506771 1414878807 | 1482250843 1549622879
0x001760:  60616263 64656667 | 68696a6b 6c6d6e6f `abcdefghijklmno
  1616994915 1684366951 | 1751738987 1819111023
0x001770:  70717273 74757677 | 78797a7b 7c7d7e7f pqrstuvwxyz{|} .
  1886483059 1953855095 | 2021227131 2088599167
0x001780:  80818283 84858687 | 88898a8b 8c8d8e8f ................
  -2138996093 -2071624057 | -2004252021 -1936879985
0x001790:  90919293 94959697 | 98999a9b 9c9d9e9f ................
  -1869507949 -1802135913 | -1734763877 -1667391841
0x0017a0:  a0a1a2a3 a4a5a6a7 | a8a9aaab acadaeaf ................
  -1600019805 -1532647769 | -1465275733 -1397903697
0x0017b0:  b0b1b2b3 b4b5b6b7 | b8b9babb bcbdbebf ................
  -1330531661 -1263159625 | -1195787589 -1128415553
0x0017c0:  c0c1c2c3 c4c5c6c7 | c8c9cacb cccdcecf ................
  -1061043517 -993671481 | -926299445 -858927409
0x0017d0:  d0d1d2d3 d4d5d6d7 | d8d9dadb dcdddedf ................
  -791555373 -724183337 | -656811301 -589439265
0x0017e0:  e0e1e2e3 e4e5e6e7 | e8e9eaeb ecedeeef ................
  -522067229 -454695193 | -387323157 -319951121
0x0017f0:  f0f1f2f3 f4f5f6f7 | f8f9fafb fcfdfeff ................
  -252579085 -185207049 | -117835013 -50462977
0x001800:  31343531 33303000 | 00000000 00000000 1451300.........
  825505073 858796032 | 0 0
0x001810:  2b303030 30313435 | 31333030 00000000 +00001451300....
  724578352 808530997 | 825438256 0
0x001820:  00000000 00000000 | 00000000 00000000 ................
  0 0 | 0 0
125 lines same as above
0x002000:  00000002 00000000 | 00000000 00000000 ................
  2 0 | 0 0
0x002010:  00000000 00000000 | 00000000 00000000 ................
  0 0 | 0 0
rest of memory same as above.
Prior Page
Next Page
This Chapter
Prior Chapter
Next Chapter
Copyright © 1995 R. Uzgalis. All rights reserved.
Contact: buz@cs.aukuni.ac.nz