The SimpSim simulator of the simple machine architecture introduced in Brookshear's book Computer Science: An Overview, 8e, introduces an assembly language that corresponds to and extends the simple machine language summarized in Appendix C (pp. 501-502) of the texbook.
| Op-code | Operation | Description |
|---|---|---|
| 1 | load RN,[XY] | LOAD register N with the value at address XY in memory (direct load). reg[N] := memory[XY] Example: load R3,[0A0h] |
| 2 | load RN,XY | LOAD register N with the value XY (immediate load). reg[N] := XY Example: load RF,10 (This writes a newline character to the console output window.) |
| 3 | store RN,[XY] | STORE the value in register N in the memory cell at address XY (direct store). memory[XY] := reg[N] |
| 4 | move RN,RM | MOVE (i.e., copy) the value in register M to register N. reg[N] := reg[M] Example: move R0,R4 (This copies the value in register 4 to register 0.) Note that the order of the operands for this assembly language instruction is the reverse of the order of the operands in the corresponding machine language. |
| 5 | addi RL,RM,RN | ADD the values in registers M and N, assuming that they are two's-complement integers,
and store the result in register L. reg[L] := reg[M] + reg[N] Example: addi R0,R0,R1 (This adds the value in register 1 to the value in register 0, overwriting the previous value in register 0.) |
| 6 | addf RL,RM,RN | ADD the values in registers M and N, assuming that they are in floating-point representation,
and store the result in register L. reg[L] := reg[M] + reg[N] Example: addi R0,RA,RB |
| 7 | or RL,RM,RN | OR the bit patterns in registers M and N and store the result in register L
(bitwise OR). reg[L] := reg[M] OR reg[N] |
| 8 | and RL,RM,RN | AND the bit patterns in registers M and N and store the result in register L
(bitwise AND). reg[L] := reg[M] AND reg[N] |
| 9 | xor RL,RM,RN | EXCLUSIVE OR the bit patterns in registers M and N and store the result in register L
(bitwise XOR). reg[L] := reg[M] XOR reg[N] |
| A | ror RN,M | ROTATE the bit pattern in register N one bit to the right M times.
This is a circular shift, so the bit that is rotated out of the low-order end is shifted
into the high-order end. reg[N] := reg[N] >> M Example: ror R1,2 (circular shift of the contents of register 1 by 2 bit positions) |
| B | jmpEQ RN=R0,XY | JUMP to the instruction located in the memory cell at address XY if the value in
register N is equal to the value in register 0; otherwise, continue execution with
the next instruction in sequential order (conditional branch). The jump is implemented by copying the value XY into the program counter during the execute phase. PC := XY if reg[N] = reg[0] Example: jmpEQ R3=R0,48 The target of a jump is usually indicated with a label rather than with a numeric value. Labels are explained below. Example: jmpEQ RB=R0,Next |
| jmp XY | JUMP to the instruction located in the memory cell at address XY (unconditional branch). PC := XY |
|
| C | halt | HALT execution. |
| D | load RN,[RM] | LOAD register N with the value from memory at the address in register M (indirect load). reg[N] := memory[reg[M]] This instruction is an extension to the machine language in Appendix C (see pp. 348-349). |
| E | store RN,[RM] | STORE the value in register N in the memory cell at the address in register M (indirect store). memory[reg[M]] := reg[N] This instruction is an extension to the machine language in Appendix C (see pp. 348-349). |
| F | jmpLE RN<=R0,XY | JUMP to the instruction located in the memory cell at address XY if the value in
register N is less than or equal to the value in register 0; otherwise, continue execution with
the next instruction in sequential order (conditional branch). The jump is implemented by copying the value XY into the program counter during the execute phase. PC := XY if reg[N] <= reg[0] Example: jmpLE R3<=R0,30h |
SimpSim assembly language also includes the following pseudo-operations:
| Pseudo-op | Description |
|---|---|
| db N db M,N,.. db "string",0 |
DATA BYTE: place the specified value(s) in the next memory location(s). The data bytes may be
specified singly, in a comma-separated list, or as a string of characters (enclosed in double quote marks). Examples: db 1,4,9,16,25,36 db "Hello, world",10,0 (a zero-terminated string, with a newline character following the printable characters) |
| org addr | ORIGIN: Place the next instruction or data byte at the memory address addr. This allows a program or data to be placed at arbitrary places in memory. |
SimpSim assembly language also supports mnemonic labels. Any assembly language instruction or data byte specification can be preceded by a label, which is an identifier followed by a colon. The label name must begin with an alphabetic character. The label may then be used wherever an address or an XY value may be used.
Extended example (from a sample file that accompanies SimpSim):
; Print a zero-terminated string
load R1,Text ; the start of the string
load R2,1 ; increase step
load R0,0 ; string terminator
NextChar: load RF,[R1] ; get character and print it on screen
addi R1,R1,R2 ; increase address
jmpEQ RF=R0,Done ; when string terminator, then done
jmp NextChar ; loop to print next character
org 0F0h ; place string at address F0 (hex)
Text: db "A string",10 ; string and newline character
db 0 ; string terminator
Note that hexadecimal values that would otherwise begin with an alphabetic character ('A' through 'F') must be prefixed by a zero in order to distinguish such numeric values from label identifiers (which must begin with an alphabetic character). Hexadecimal values are distinguished from decimal values by a trailing 'h'. For example, the operation
load R0,[A0]
loads the value at label A0, whereas the operation
load R0,[0A0h]
loads the value from memory address A0 (hexadecimal).