Assembler Working 🔗
VR16 CPU Home Page
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.
General Syntax 🔗
- All programs must start with the start: keyword and must end with end:.
- 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.
- Refer the instruction-set architecture for supported opcodes.
Registers Present 🔗
As mentioned, only 4 general purpose registers:
- r0
- r1
- r2
- r3