diff --git a/main.py b/main.py index d7358bf..e481e0f 100644 --- a/main.py +++ b/main.py @@ -68,6 +68,12 @@ def binary_to_hex(bin): case "SHLV": instruction_decoded += "1010" + dec_to_hex[int(instruction_splitted[1][1])] + dec_to_hex[int(instruction_splitted[2][1])] + "111" + dec_to_hex[int(instruction_splitted[3][1])] decoded = True + case "STV": + instruction_decoded += "1111" + dec_to_hex[int(instruction_splitted[2][1])] + dec_to_hex[int(instruction_splitted[1][3])] + "001" + dec_to_hex[int(instruction_splitted[1][0])] + decoded = True + case "LDV": + instruction_decoded += "1111" + dec_to_hex[int(instruction_splitted[1][1])] + dec_to_hex[int(instruction_splitted[2][3])] + "010" + dec_to_hex[int(instruction_splitted[2][0])] + decoded = True if decoded: print(".word 0x" + str(binary_to_hex(instruction_decoded))) diff --git a/tests/test_STV.S b/tests/test_STV.S new file mode 100644 index 0000000..6eb58b5 --- /dev/null +++ b/tests/test_STV.S @@ -0,0 +1,74 @@ +.text +movi r0, 0x00 +movhi r0, 0x11 +mvrv v0, r0, 0 + +movi r0, 0x22 +movhi r0, 0x33 +mvrv v0, r0, 1 + +movi r0, 0x44 +movhi r0, 0x55 +mvrv v0, r0, 2 + +movi r0, 0x66 +movhi r0, 0x77 +mvrv v0, r0, 3 + +movi r0, 0x88 +movhi r0, 0x99 +mvrv v0, r0, 4 + +movi r0, 0xaa +movhi r0, 0xbb +mvrv v0, r0, 5 + +movi r0, 0xcc +movhi r0, 0xdd +mvrv v0, r0, 6 + +movi r0, 0xee +movhi r0, 0xff +mvrv v0, r0, 7 + +movi r0, 0x00 +movhi r0, 0x11 +mvrv v1, r0, 0 + +movi r0, 0x22 +movhi r0, 0x33 +mvrv v1, r0, 1 + +movi r0, 0x44 +movhi r0, 0x55 +mvrv v1, r0, 2 + +movi r0, 0x66 +movhi r0, 0x77 +mvrv v1, r0, 3 + +movi r0, 0x88 +movhi r0, 0x99 +mvrv v1, r0, 4 + +movi r0, 0xaa +movhi r0, 0xbb +mvrv v1, r0, 5 + +movi r0, 0xcc +movhi r0, 0xdd +mvrv v1, r0, 6 + +movi r0, 0xee +movhi r0, 0xff +mvrv v1, r0, 7 + +addv v2, v0, v1 + +movi r1, 0x00 +movhi r1, 0x00 + +STV 0(r1), v2 +LDV v2, 0(r1) + +halt \ No newline at end of file