added syscall and jalr to assembler, also fixed v1 value

master
bx 2021-09-03 13:58:33 +01:00
parent a7979dfeab
commit 0989bd54f0
1 changed files with 19 additions and 1 deletions

View File

@ -6,7 +6,7 @@ def r0() 0 end # zero
def at() 1 end # assembler temporary
# subroutine return values, may be changed by subroutines
def v0() 2 end ; def v0() 3 end
def v0() 2 end ; def v1() 3 end
# subroutine arguments, may be changed by subroutines
def a0() 4 end ; def a1() 5 end
@ -193,6 +193,24 @@ class Assembler
word op
end
# TODO: actually encode "comment" argument
def syscall(comment)
# iiiiii ccccc ccccc ccccc ccccc iiiiii
op = 0b000000_00000_00000_00000_00000_001100
word op
end
# TODO: expose the return address storage register
# NOTE: cannot use the same register for both operands
def jalr(reg)
# jumps to addr in j and stores return adr in r
# iiiiii jjjjj ----- rrrrr ----- iiiiii
op = 0b000000_00000_00000_00000_00000_001001
op |= (reg & 0b11111) << 21
op |= (ra) << 11 # ra
word op
end
# # # PSEUDO-INSTRUCTIONS # # #
def nop
word 0x00000000