Converting from C to MIPS

Thread Starter

mad12

Joined Oct 9, 2008
11
I am getting into MIPS programming and one of my homework problems requires me to write the corresponding C code for given MIPS instructions. The MIPS instruction I am getting confused about is

Rich (BB code):
addi f,f,1
add f,g,h
I am under the impression that the first line would not matter since f is going to get overwritten once the second line exectues. I would think the answer to this would then be

Rich (BB code):
f = g + h;
Am I right in this assumption, or is there something easy that I am missing? Thanks in advance
 

veritas

Joined Feb 7, 2008
167
Technically yes, only the second line will get executed, but if that MIPS code were actually converted from C, then the first line had to come from somewhere. If "f" were a memory-mapped I/O register, for instance, then that first line might be important.
 
Top