I wrote swap on assembly, but I'm not sure that my code is right, this is the code
swap: mov r1, -(sp)
mov (sp) r1
mov 2(sp) (sp)
mov r1 2(sp)
mov (sp)+, r1
rts pc
swap receives pointer from stack
I wrote swap on assembly, but I'm not sure that my code is right, this is the code
swap: mov r1, -(sp)
mov (sp) r1
mov 2(sp) (sp)
mov r1 2(sp)
mov (sp)+, r1
rts pc
swap receives pointer from stack
is sp a stackpointer? There is usually the command ldw rA, 0(rB)
(0 is the offset and rB is the address you will load from, the actual data is now in rA). ldw loads a whole word into the memory, ldb loads a byte, stw rA, 0(rB)
stores a word. mov
usually copies one register to another.