Skip to content

Commit

Permalink
added full asm list
Browse files Browse the repository at this point in the history
  • Loading branch information
Peppy3 committed Feb 21, 2022
1 parent 9bd29fe commit 9da2b15
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
Binary file not shown.
27 changes: 25 additions & 2 deletions Compiler/py compiler/instructions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
def create_opcodes(instruction: str, r: int, s: int, t: int):
def create_opcodes(instruction: str, r: int, s: int, t: int, i: int):
instructions: dict = {
"""
DICT STRUCTURE
[opcode name]: tuple
The tuple can contain an int or an tuple:
The tuple can contain an int or a tuple:
- int: gets appended directly onto the byte array
- tuple: ([value], [size])
value: the value that should be appended to the array
Expand Down Expand Up @@ -72,6 +72,29 @@ def create_opcodes(instruction: str, r: int, s: int, t: int):
"rri": (0x9E, (r, 1), 0x00, (t, 1), (s, 4)),
"rl": (0x8F, (r, 1), (s, 1), (t, 1), (0, 4)),
"rli": (0x9F, (r, 1), 0x00, (t, 1), (s, 4)),

#Memory
"lw": (0x40, 0x00, (r, 1), (s,1), (t, 4)),
"lwi": (0x50, 0x00, (r, 1), (s, 1), (t, 4)),
"sw": (0x41, 0x00, (r, 1), (s, 1), (t, 4)),
"swi": (0x51, 0x00, (r, 1), (s, 1), (t, 4)),

#IO
"lio": (0x44, (r, 1), (s, 1), 0x00, (t, 4)),
"sio": (0x45, (r, 1), (s, 1), 0x00, (t, 4)),

#call n return
"call": (s, 7),
"ret": (0x43, (0, 7)),

#register stuff
"cp": (0xc0, (r, 1), 0x00, (t, 1), (0,4)),
"cpeq": (0xc2, (r, 1), (s, 1,), (t, 1), (i, 4)),
"cpi": (0xd0, (0,2), (t, 1), (i, 4)),
"cp": (0xd2, (r, 1), (s, 1), (t, 1), (i, 4)),
"swp": (0xc8, (r, 1), (s, 1), (0, 5)),
"swpeq": (0xca, (r, 1), (s, 1), (0, 5))

}

instruction_cmd: tuple = instructions.get(instruction)
Expand Down
2 changes: 1 addition & 1 deletion Compiler/py compiler/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import instructions

test: bytearray = instructions.create_opcodes("clti", 1, 2, 3)
test: bytearray = instructions.create_opcodes("cpeq", 1, 2, 3, 4)

text: str = ""
for i in test:
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions Test_programs/Calibrating_Laser_Canons.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ioread(x,0,10);
x = x * 6;
iowrite(x,0,9);

0 comments on commit 9da2b15

Please sign in to comment.