A Python OISC emulator and assembler using Subleq
whisk_asm_2.py reads the assembly source file input.sla and writes the assembled output to output.slq.
whisk.py can the be run which will read the source in output.slq and run it.
I created my own assembly syntax for this project using various conventions from different places. The following is a list of commands that can be used:
s a b cis the standard subleq operation. The value atais subtracted from the value atband stored atb. If this value is less than or equal to zero, the code will branch to adressc.bcan be an adress (15) or a variable ($name).ccan also be a label (:here) andacan also be a label or literal (!42).add a bwill add the value at a to that at b. The arguments can be addresses or variables, andacan be a literal.inc aordec awill increment or decrement the value ata.jmp awill jump to the address or labela.cpy a bwill copy the value atatob.:heredeclares a label that can be jumped to later.print aprints the value at a to console.$name = aassigns the valueato the variable with name$name.
- A general rule here is that you can never have a literal as the second argument to a statement as this will change the stored value of that literal and is therefore not allowed.
- The symbol
?can be used to specify a jump to the next command with ansstatement meaning no conditional branching will occur, e.g.s !10 $value ?.
Happy Coding!