-
Notifications
You must be signed in to change notification settings - Fork 0
instructions
Tom Lonergan edited this page Jun 23, 2023
·
11 revisions
An example instruction looks like:
Hex - 8 3 7 2
Bin - 1000 0011 0111 0010
Shift r7 left 2 bits and store result in r3
Opcode | Instruction |
---|---|
0 | Add |
1 | Subtract |
2 | And |
3 | Or |
4 | SetIfLess |
5 | SetIfEqual |
6 | ShiftLeft |
7 | ShiftRightLogical |
8 | ShiftRightArithmetic |
9 | SetLower |
A | SetUpper |
B | LoadWord |
C | SaveWord |
D | SetPcIf |
E | SetPcIfNot |
F | Special |
Instruction in form:
Opcode | Destination register (d) | Source register 1 (s1) | Source register 2 (s2) |
---|
Opcode | Instruction | Operation | Notes |
---|---|---|---|
0 | Add | d = s1 + s2 | |
1 | Subtract | d = s1 - s2 | |
2 | And | d = s1 & s2 | |
3 | Or | d = s1 | s2 | |
4 | SetIfLess | d = 1 if s1 < s2, 0 otherwise | |
5 | SetIfEqual | d = 1 if s1 = s2, 0 otherwise | |
6 | ShiftLeft | d = s1 << s2 | Fills new right side bits with 0s |
7 | ShiftRightLogical | d = s1 >> s2 | Fills new left side bits with 0s |
8 | ShiftRightArithmetic | d = s1 >> s2 | Fills new left side bits with most significant bit |
Instruction in form:
Opcode | Destination register (d) | 8 bits value (v) |
---|
Opcode | Instruction | Operation | Notes |
---|---|---|---|
9 | SetLower | Lower 8 bits of d set to v | |
A | SetUpper | Upper 8 bits of d set to v |
Instruction in form:
Opcode | Offset (o) | Target (t) | Address (a) |
---|
Opcode | Instruction | Operation | Notes |
---|---|---|---|
B | LoadWord | Loads M(r(a) + o) into r(t) | Addresses in words |
C | SaveWord | Saves r(t) into M(r(a) + o) | Addresses in words |
Instruction in form:
Opcode | Value1 | Value2 | Value3 |
---|
Opcode | Instruction | Operation | Notes |
---|---|---|---|
D | SetPcIf | rPC set to value1 if r(value2) == r(value3) | |
E | Unused | ||
F | Special | Performs operation defined in value1 | See suboperations |
Subopcode | Instruction | Operation |
---|---|---|
0 | Syscall | OS syscall |
1 | Terminate | Terminate processor |
2 | Multiply | Multiply r(value1) and r(value2), store result in rHigh and rLow |
3 | Divide | Divide r(value1) and r(value2), store quotient in rHigh and remainder in rLow |