https://github.com/muhammedikinci/16bitvm
Developing 16bit virtual machine with Golang
https://github.com/muhammedikinci/16bitvm
16bit golang low-level virtual-machine vm
Last synced: 4 months ago
JSON representation
Developing 16bit virtual machine with Golang
- Host: GitHub
- URL: https://github.com/muhammedikinci/16bitvm
- Owner: muhammedikinci
- Created: 2025-07-01T20:52:15.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-07-02T21:20:21.000Z (4 months ago)
- Last Synced: 2025-07-02T21:27:02.273Z (4 months ago)
- Topics: 16bit, golang, low-level, virtual-machine, vm
- Language: Go
- Homepage: https://ikinci.dev
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 16bitvm
---
## Registers
| Name | Description |
| ---- | ------------------- |
| ip | Instruction pointer |
| acc | Accumulator |
| r1 | General-purpose |
| r2 | General-purpose |
---
## Opcodes
| Opcode | Mnemonic | Description | Format |
| ------ | ----------- | ------------------------------- | --------------------------------------------------- |
| 0x10 | MOV_LIT_REG | Move literal into register | 0x10 [lit_lo] [lit_hi] [reg_id] |
| 0x11 | MOV_REG_REG | Move value between registers | 0x11 [src_reg_id] [dest_reg_id] |
| 0x12 | MOV_REG_MEM | Move register value to memory | 0x12 [reg_id] [addr_lo] [addr_hi] |
| 0x13 | MOV_MEM_REG | Load memory value into register | 0x13 [addr_lo] [addr_hi] [reg_id] |
| 0x14 | ADD_REG_REG | Add two registers → acc | 0x14 [reg1_id] [reg2_id] |
| 0x15 | JMP_NOT_EQ | Jump if reg != value | 0x15 [reg_id] [val_lo] [val_hi] [addr_lo] [addr_hi] |
All literal and address values are 16-bit, little-endian.
---
## Example Memory Layout
```
Address | Byte | Meaning
--------|------|------------------------------
0x00 | 0x10 | LOAD_LITERAL r1
0x01 | 0x34 |
0x02 | 0x12 | → r1 = 0x1234 = 4660
0x03 | 0x11 | LOAD_LITERAL r2
0x04 | 0xCD |
0x05 | 0xAB | → r2 = 0xABCD = 43981
0x06 | 0x12 | ADD r1, r2
0x07 | 0x02 |
0x08 | 0x03 | → acc = r1 + r2 = 48641
```
---
## Run
```bash
go run main.go
```