CITS2002 Systems Programming  
 

Unit home

Project 1

help2002

Lecture & Workshop
recordings on LMS

Schedule

FAQ

Unit outline

C textbooks

OS textbooks

Information resources


Extra reading

Past projects

Recent feedback


Working effectively

Look after yourself!

The instruction set

Abbreviations:
PC - program counter
FP - frame pointer
SP - stack pointer
TOS - top of stack

mnemonic opcode (number) memory words description
halt 0 1 halt
the program no longer executes, and exits (using the Linux system-call) with the integer on the TOS as the program's exit status
nop 1 1 no operation
the PC is advanced to the next instruction
add 2 1 addition
the two integers on the TOS are popped from the stack, added together, and the result left on the TOS
sub 3 1 subtraction
the two integers on the TOS are popped from the stack, the second subtracted from the first, and the result left on the TOS
mult 4 1 multiplication
the two integers on the TOS are popped from the stack, multiplied together, and the result left on the TOS
div 5 1 division
the two integers on the TOS are popped from the stack, the second divided from the first, and the result left on the TOS
call 6 2 function call
the word following the 'call' instruction holds the address of the required function's first instruction. The function's first instruction is the next instruction to be executed
return 7 2 function return
the flow of execution returns to the instruction immediately following the 'call' instruction that called the current function. The integer value on the TOS is the function's returned value (even if the current function is of type void). The value immediately following the return opcode indicates where the function's returned value should be copied before the function returns - to the location of FP+value of the current function's stack frame.
jmp 8 2 unconditional jump
the flow of execution continues at the address in the word immediately following the 'jmp' instruction
jeq 9 2 conditional jump
the value on the TOS is popped from the stack and, iff the value is zero, the flow of execution continues at the address in the word immediately following the 'jeq' instruction
printi 10 1 print integer
the value on the TOS is popped from the stack and printed to stdout
prints 11 2 print string
the NULL-byte terminated character string whose address immediately follows the 'prints' instruction is printed to stdout
pushc 12 2 push integer constant
the integer constant in the word immediately following the 'pushc' instruction is pushed onto the stack
pusha 13 2 push absolute
the word immediately following the 'pusha' instruction holds the address of the integer value to be pushed onto the stack
pushr 14 2 push relative
the word immediately following the 'pushr' instruction provides the offset to be added to the FP to provide the address of the integer value to be pushed onto the stack
popa 15 2 pop absolute
the word immediately following the 'popa' instruction holds the address into which the value on the TOS should be popped
popr 16 2 pop relative
the word immediately following the 'popr' instruction provides the offset to be added to the FP to provide the address into which the value on the TOS should be popped

Helpful resources:

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Presented by [email protected]