0
votes

I'm currently writing a division algorithm in MIPS using only native instructions. One problem that I'm having is that the algorithm requires the divisor to be in the left half of the register. Now, if I was loading an immediate I would just use LUI. But since I'm using syscall to get input from the user, it is being passed to a register. I'm not sure how to do this.

Here is how I'm currently storing:

    addi $v0, $0, 5
    syscall
    add $a1, $0, $v0    #store divisor into $a1

Thank you.

1

1 Answers

1
votes

Perform a left shift by 16 bits:

sll $a1, $v0, 16          #$a1 = $v0 << 16 

Upper 16 bits of $v0 are discarded.