# Sample Assembler Programs

The following sample assembler programs are provided:

- Hello World 1
- Hello World 2
- Character Set
- Tape Printer
- Random Storage
- Play Music

Note: the sample assembler programs have been written and assembled using a simple assembler utility provided with the simulator. This is similar though not identical to the original 803 assembler. In addition they often use one of the special simulator control instructions to exit in a clean way.

Some sample programs that can be used with the ALGOL compiler are also provided and documented separately.

## Hello World 1

Source Code | `samples/assembler/hello1.a1`
Program Tape | `tapes/samples/hello1.tape`

This is a very simple assembler "hello world" program. It just prints a short message to the output teletype and exits. It is compiled to a self-triggering tape that can be loaded and run using the initial instructions. This program is used in the Quick Start Guide.

## Hello World 2

Source Code | `samples/assembler/hello2.a1`
Program Tape | `tapes/samples/hello2.tape`

This is a minor variation on the Hello World 1 sample. The program is compiled to a binary tape that can be loaded using the initial instructions but the tape does not trigger to the entry point. This program is loaded to a fixed address starting at location 7. As the tape does not "trigger" the initial instructions will try to continue to read past the end and the tape will fall out of the reader - this was fairly normal 803 behaviour! When there is no more tape to read the system will show a busy light as it gets stuck in a read instruction. At this point you need to press the Reset key on the console, to clear the busy condition, and perform a manual jump to the entry point at location 7 - so set up the instruction 40 7 : 00 0 on the word generator and then do the standard sequence Read, Operate, Normal, Operate. After this the message should appear in the output teletype.

This program also enters a spin-loop when it finishes (identified by the high pitch speaker tone), which was fairly standard 803 behaviour, again the Reset key needs to be used to regain operator control.

## Character Set

Source Code | `samples/assembler/charset.a1`
Program Tape | `tapes/samples/charset.tape`

This program prints the all 62 telecode characters - the 31 letter-shift versions and the 31 figure-shift versions - to the output teletype then exits. This shows all the characters available and also illustrates the use of a 73 instruction to do a procedure call and return. The program is compiled to a self-triggering tape that can be loaded and run by the initial instructions.

## Tape Printer

Source Code | `samples/assembler/print.a1`
Program Tape | `tapes/samples/print.tape`

This program will print the contents of the tape in Reader 2 to the output teletype. The program is compiled to a self-triggering tape that can be loaded and run by the initial instructions. The CPU will enter a "busy" wait if there is no tape in Reader 2, as soon as a tape is loaded it should continue and print out the tape contents.

The behaviour is similar to an online version of the TapePrint utility program.

## Random Storage

Source Code | `samples/assembler/random.a1`
Program Tape | `tapes/samples/random.tape`

This program writes random numbers (from 0 to 3) to random storage locations, avoiding overwriting the program itself which is loaded into the very top of store. The program is compiled to a self-triggering tape that can be loaded and run by the initial instructions.

The program is intended to illustrate the use of the random number simulator device and also shows the core store window updating.

## Play Music

Source Code | `samples/assembler/music.a1`
Program Tape | `tapes/samples/music.tape`

This program attempts to play some music on the console speaker. It is written in a very simple way and is a little out of tune, but shows the speaker producing something other than random noise.

The program is compiled to a self-triggering tape that can be loaded and run by the initial instructions. After the tape loads it will enter a "sign wait" with a high pitch tone. Change the value of the top-most sign bit on the console to play the music!

Tim Baldwin December 2013 tjb803@tinymail.co.uk | Return to index © Tim Baldwin 2009,2013