VR16 CPU Home Page
Assembler 🔗
Well as the name suggests, this explains how the assembler works hehe.
assembler.py
🔗
- Lines are first loaded onto a list from the asm source file.
- Based on the opcode, a simple if condition is run and the proper extractor() is chosen.
- Opcodes are only checked once the assembler reads start:, similarly exits the operation on seeing end:.
- Once the extractor runs, the output is further sent back from extractor.py to this file and they’re written onto the .mem file
extractor.py
🔗
- This file holds all functions based on opcode.
- Essentially substrings the list given by assembler.py and converts into string representation of binary.
- This is further sent back and written into the .mem file.
baseclass.py
🔗
- Holds custom exceptions by subclassing Exception.
- RegisterNotPresent and OpcodeNotPresent are two custom exceptions present at the moment.
VR-ASM Documention 🔗
This is subject to change.
General Introduction 🔗
- All programs must start with the start: keyword.
- Once start is initiliased, all instructions must be indented with spaces of 4.
- All lines must end with the
;
semicolon. This only applies to code once initialised. - Comments can made using the --.
- Everything must be in lowercase.
- All programs must end with the end: keyword.
Instructions and their syntax 🔗
<arg> = required argument.
[arg] = optional argument.
No need to type out <> and [].
- add, sub, mul, div:
- <opcode> <store_at> <operand_one> <operand_two>;
- addi, subi, muli, divi:
- <opcode> <store_at> <10_bit_immediate_value>;
- and, or, xor:
- <opcode> <store_at <operand_one> <operand_two>;
- not
- not <store_at> <operand_one>;
- jump: TO BE IMPLEMENTED
- delete
- delete <destination_register>;
- halt
- halt;
Registers Present 🔗
As mentioned, only 4 general purpose registers:
- r0
- r1
- r2
- r3