Example of a TC1 assembly language program
Here, we demonstrate a TC1 program in assembly language. This offers a means of testing the simulator and showing how it works. We would like to test a range of facilities, so we should include looping, conditional testing, and pointer-based memory access. We will write a program to do the following:
- Fill a region of memory from locations 0 to 4 with random numbers.
- Reverse the order of the numbers.
Since this problem uses memory and sequential addresses, it involves register indirect addressing, that is, LDRI
and STRI
instructions. Creating the random numbers and storing them sequentially in memory can be done by doing the following:
Set a pointer to the first memory location (i.e.,0)
Set a counter to 5 (we are going to access five locations 0 to 4)
Repeat
Generate a random number
Store this number at the pointer address
Point to next number (i.e., add 1 to the pointer)
...