Skip to content

Commit 04a6ac8

Browse files
committed
Make it easier to load 32-bit relative address
1 parent 103503a commit 04a6ac8

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/instruction-set.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ instruction MOV(d: u5, s: u5, m: u2, dir: u1, c: ConditionCode, l: bool):
251251
| `ST` | `0x03` | `dddddsssssww00000000000p` |
252252
| `LD` | `0x04` | `dddddsssssww00000000000p` |
253253
| `LDI` | `0x05` | `dddddh00iiiiiiiiiiiiiiii` |
254-
| `LRA` | `0x06` | `ddddd000oooooooooooooooo` |
254+
| `LRA` | `0x06` | `dddddx00oooooooooooooooo` |
255255

256256

257257
Payload Bits Legend:
@@ -263,6 +263,7 @@ Payload Bits Legend:
263263
* `h`: Hi/lo bits
264264
* `q`: Scale Quantity
265265
* `p`: Push/Pop
266+
* `x`: Sign/Zero Extend
266267

267268
Timing:
268269
* `ST`, `LD`: 4 Cycles, plus Memory Delay
@@ -273,7 +274,7 @@ Behaviour:
273274
* `ST`: Stores `1 << w` bytes from `d` to `[s]`
274275
* `LD`: Loads `1 << w` bytes from `[s]` into `d`
275276
* `LDI`: Loads an immediate `i` into the first (h=0) or upper (h=1) 16 bits of `d`
276-
* `LRA`: Loads the address `IP + o` (`o` is a signed immediate) into `d`. `IP` is taken from the beginning of the next instruction
277+
* `LRA`: Loads the address `IP + o` (`o` is a signed immediate if `x` is true, and an unsigned immediate otherwise) into `d`. `IP` is taken from the beginning of the next instruction
277278

278279
```
279280
instruction ST(s: u5, d: u5, w: u2, p: bool):
@@ -303,8 +304,8 @@ instruction LDI(d: u5, i: u15, h: u1):
303304
let val = ZeroExtend(i);
304305
WritePartialRegister(0,d,val, 16*h..16+(16*h));
305306
306-
instruction LRA(d: u5, i: u15):
307-
let val = SignExtend(i) + IP;
307+
instruction LRA(d: u5, x: bool, i: u15):
308+
let val = SignExtendOrZeroExtend(i, x) + IP;
308309
WriteRegister(0,d,val);
309310
```
310311

@@ -313,11 +314,12 @@ instruction LRA(d: u5, i: u15):
313314
| Mnemonic | Opcode | Payload |
314315
| -------- | ------ | -------------------------- |
315316
| | `0--7` | `8---------------------31` |
316-
| `ADDI` | `0x08` | `dddddsc00000iiiiiiiiiiii` |
317+
| `ADDI` | `0x08` | `dddddhcsiiiiiiiiiiiiiiii` |
317318

318319
Timing: 2
319320
Payload Bits Legend:
320321
* `d`: Destination Register
322+
* `h`: High half
321323
* `s`: Extend Sign
322324
* `c`: Surpress Flags Modification
323325
* `i`: Immediate

0 commit comments

Comments
 (0)