Skip to content

Commit

Permalink
Merge pull request #1 from polsahi/main
Browse files Browse the repository at this point in the history
Add STV and LDV
  • Loading branch information
raulgilabert authored Jun 19, 2024
2 parents 1a9dccd + 15f5f0c commit cc97b2d
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
74 changes: 74 additions & 0 deletions tests/test_STV.S
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cc97b2d

Please sign in to comment.