2 years ago

#29985

test-img

debaser36

MIPS ASSEMBLY split up a number

We have a little homework in MIPS ASSEMBLER to do, and I have a question to a little problem I have encountered. Somewhere in my Code I HAVE to split up a number into 2 registers. Is there an elegant way to do it? I really was thinking about it, and the only thing that comes to mind is the and or andi operator. Somehow it doesnt work for me, I dont know why, maybe I understand it wrong. We have a 6 bit Number, where the first 3 bits are the one number I have to extract, and the last 3 bits are the second number.

#-----split x and y-----#
andi $a2, $a0, 000111 # x--> a2
andi $a3, $a0, 111000 # y--> a3

Is this the correct way of thinking about it? Why doesnt it work? Thanks for the help!

assembly

mips

mars-simulator

0 Answers

Your Answer

Accepted video resources