You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/isa.md
+1-90Lines changed: 1 addition & 90 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,93 +13,4 @@ refer to `include/hardware.h`
13
13
14
14
## Scope
15
15
16
-
This document captures the current draft ISA for the VM and the stable parts of the design that are already present in the codebase. It intentionally leaves unspecified items blank until the implementation lands. The design targets an 18-bit, randomised ISA in later iterations while the first implementation runs a non-randomised, 16-bit equivalent.
17
-
18
-
## Word size
19
-
20
-
* Early implementation: 16-bit words
21
-
* Planned implementation: 18-bit words (with a 5-bit opcode in the high-order bits)
The 16-bit variant keeps the same conceptual fields but packs them within 16 bits. Final bit positions for the 16-bit encoding are TBD in this document and will be aligned with the implementation.
46
-
47
-
## Opcodes
48
-
49
-
The following opcodes are defined in the headers and constitute the core instruction set. Semantics follow conventional interpretations unless specified otherwise. Execution details for edge cases will be specified alongside the implementation.
50
-
51
-
| Mnemonic | Category | Brief semantics |
52
-
| --- | --- | --- |
53
-
|`NOP`| Control | No operation |
54
-
|`HALT`| Control | Stop execution |
55
-
|`ADD`| R-type |`rd = rs + rt`; updates `COND`|
56
-
|`SUB`| R-type |`rd = rs - rt`; updates `COND`|
57
-
|`AND`| R-type |`rd = rs & rt`; updates `COND`|
58
-
|`OR`| R-type | `rd = rs | rt`; updates `COND` |
59
-
|`XOR`| R-type |`rd = rs ^ rt`; updates `COND`|
60
-
|`NOT`| R-type |`rd = ~rs`; updates `COND`|
61
-
|`MOV`| R-type |`rd = rs`; may update `COND` (TBD) |
62
-
|`LSH`| R-type | Logical left shift (operands/amount TBD) |
63
-
|`RSH`| R-type | Logical right shift (operands/amount TBD) |
64
-
|`CMP`| R-type | Compare `rs` and `rt`, set `COND`|
Copy file name to clipboardExpand all lines: docs/vm.md
+5-28Lines changed: 5 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ refer to `include/hardware.h`
12
12
13
13
## Scope
14
14
15
-
This document describes the VM that executes the virtualised program. It covers the current 16-bit early implementation and highlights planned shifts to an 18-bit, randomised ISA. It intentionally omits unfinished or unspecified details.
15
+
This document describes the VM that executes the virtualised program. It covers the current 16-bit early implementation of the VM interpreter. It intentionally omits unfinished or unspecified details.
16
16
17
17
## Architecture overview
18
18
@@ -22,6 +22,8 @@ This document describes the VM that executes the virtualised program. It covers
22
22
* Fetch–decode–execute loop drives execution
23
23
* Image files are loaded into memory before execution begins
24
24
25
+
This is to align with the design of LC-3
26
+
25
27
## Registers
26
28
27
29
| Name | Width | Purpose |
@@ -49,39 +51,14 @@ This document describes the VM that executes the virtualised program. It covers
49
51
| --- | --- |
50
52
| Address space | 0x0000 to 0xFFFF |
51
53
| Capacity | 65,536 words |
52
-
| Word width | 16 bits (early implementation) |
54
+
| Word width | 16 bits |
53
55
| Layout | Unified code and data |
54
56
55
57
`PC` is initialised to `PC_START` (currently `0x3000`). This leaves lower memory available for images, vectors, and future system structures. Exact segmenting is to be defined.
56
58
57
59
## Program loading
58
60
59
-
* Command-line accepts one or more image files
60
-
* Each image is validated and loaded into memory
61
-
* On failure to load, execution aborts
62
-
63
-
Image format and relocation rules are to be defined. The loader interface exists; the on-disk format is not yet documented here.
64
-
65
-
## Execution model
66
-
67
-
* Initialise arguments and memory
68
-
* Set `COND` to `FL_ZRO`
69
-
* Set `PC` to `PC_START`
70
-
* Main loop repeats while running
71
-
* Fetch: read instruction word at `PC`, then increment `PC`
72
-
* Decode: extract opcode from the high-order bits
73
-
* Execute: dispatch to the operation handler
74
-
* Update flags and registers as specified by the operation
75
-
76
-
At present, `HALT` terminates the loop. Additional operations are defined by the ISA but may be implemented incrementally.
77
-
78
-
## Instruction width and encoding
79
-
80
-
* Early implementation uses 16-bit instruction words
81
-
* Planned implementation uses 18-bit instruction words with a 5-bit opcode field and structured operand fields
82
-
* To maintain forward compatibility, the VM structure and instruction taxonomy align with the 18-bit design even when running 16-bit words
83
-
84
-
Exact 16-bit field layouts are intentionally not fixed in this document. See the ISA document for the intended 18-bit layouts.
61
+
Images are embedded into the memory with an image embedding tool that creates a relocatable object (containing the image as a byte array), exposes symbols for the image start & end, and the C code accesses the image through these two pointers.
0 commit comments