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?
MIPS instruction set doesn't provide a mult instruction with immediate value. Hence you would have to store the value into a temporary register and then use mult instructions. The result of the mult instruction would be stored in lo and hi registers giving the lower 32-bit of the result and upper 32-bit of the result respectively.