• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

MIPS assembly language: Could someone explain to me why there is no subi instruction?

Jay59express

Senior member
Title pretty much says it all. Just wondering why there cannot be a subi (subtract immediate) instruction in the MIPS assembly language.
Thanks!
 
That was So fast!
But does that explain why you cannot subtract immediately? Is it because you need to add the opposite, which means you need to negate the 2nd operand first, then add?
 
instead of using subi, just use addi with a negative immediate value, if you think about it, this is what subi would do:

subi $t0, $t1, 16 # takes the value from $t1, subtracts 16, and stores it in $t0

here's what addi does:

addi $t0, $t1, -16 # takes the value from $t1, adds negative 16 (effectively subtracting 16) and stores it in $t0.

There's no benefit to having a subi instruction, just use the negative of the immediate value.
 
oh, and the reason that there isn't a subi instruction, is because it was easier to build the processor without one, and addi would work just fine.
 
cool, thanks man... you last post is what I was looking for, one of out homework questions asked why there was not a subi.
Thanks again
 
Back
Top