| opcode |
format |
semantics |
example |
example assembly (RISC) |
| branch |
8-oo |
pc = pc-2 + 2*o |
1000: 8006 |
br 0x100c |
| branch if equal |
9roo |
if r[r] == 0,
pc = pc-2 + 2*o |
1000: 9206 |
beq r2, 0x100c |
| branch if greater |
aroo |
if r[r] > 0,
pc = pc-2 + 2*o |
1000: a206 |
bgt r2, 0x100c |
| jump |
b--- aaaaaaaa |
pc = a |
1000: b000 00008000 |
jmp 0x8000 |
| get pc |
6f-d |
r[d] = pc-2 |
6f01 |
gpc r1 |
| jump indirect |
croo |
pc = r[r] + 2*o |
c103 |
jmp 0x3(r1) |
| jump indirect, b+o |
droo |
pc = m[ r[r] + 4*o ] |
d103 |
jmp *0x3(r1) |
| jump indirect, index |
eir- |
pc = m r[r] + 4*r[i] ] |
e120 |
jmp *(4*r1,r2) |
Note 1: All "branch" machine language instructions are relative to the current PC (though their assembly versions are absolute). All "jump" instructions are absolute.
Note 2: the semantics for each branch instruction include a -2. This is to undo the +2 increment to PC during the fetch stage.
Corollary to Note 2: a branch of "0" should make the branch instruction branch to itself. So if you ever branch by 0, you will enter an infinite loop. This simplifies branching forwards and backwards.