I'm learning how to do MIPS and i'm confused on multiplication. Let's say I was converting the following C Code into MIPS.
c = b + a*3
with a,b,c stored in registers $s1,$s2,$s3 respectively. How am I supposed to write a*3 in MIPS? Is there an addi type instruction for multiplication or do I store 3 in a temporary register and use the mult operator like this?
addi $t0, $zero, 3
mult $s1,$t0
If so how do I get the final value or product of this operation to complete my C code?
loandhiregisters. Use themfloandmfhiinstructions to get their values (or justmfloif you're only interested in the 32 least significant bits). Consult a MIPS instruction set reference for more info on those instructions. - Michael