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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.movusually copies one register to another.