All pastes #976561 Raw Edit

Stuff

public text v1 · immutable
·published 2008-04-08 08:07 UTC
rendered paste body
MiniISA has four registers: $0, $1, $2 and $r, represented as 00, 01, 10 and 11
respectively. $r stands for "result", and is as such the register into which
the results of math operations are placed. $2 is customarily the stack pointer.

The special register $01 is actually the 16-bit representation of registers $0
and $1, with $0 as the high bits.

_'s in the bit representation of operations are ignored bits.

bits            name            function
----------------------------------------
0000aa__        load $a         load into register a from address in $01
0001aa__        store $a        store from register a into address in $01
0010____        jump            jump to address in $01
0011oooo        jump o          jump o instructions (signed)
0100iiii        high $0 i       high bits of register 0 set to iiii
0101iiii        low $0 i        low bits of 0
0110iiii        high $1 i       high bits of 1
0111iiii        low $1 i        low bits of 1
1000aabb        sub $a $b       $r = $a - $b
1001oooo        branch o        if ($r < 0) jump o instructions (signed)
1010aabb        swap $a $b      $a and $b are swapped
1100aabb        srl             $r = $a >> $b (logical)
1101aabb        sra             $r = $a >> $b (arithmetic)
111_aabb        sll             $r = $a << $b

jumps:
A jump to a given address will actually continue execution at the immediate
next address. That is, the program counter is always incremented, even on
jumps. For this reason, an assembler implementing labels should make jumps go
to the address immediately preceeding a given label.

pseudoinstructions:
imm $a 0xAB
        high $a 0xA
        low $a 0xB
addr 0xABCD
        high $0 0xA
        low $0 0xB
        high $1 0xC
        low $1 0xD
jump <label>
        (if the label is within 8 instructions)
                jump <offset>
        (otherwise)
                addr <label>
                jump
branch <label>
        (if the label is within 8 instructions)
                branch <offset>
        (otherwise)
                branch 1
                jump 5
                addr <label>
                jump