Converting from C to MIPS

Discussion in 'Embedded Systems and Microcontrollers' started by mad12, Jan 31, 2009.

  1. mad12

    Thread Starter Member

    Oct 9, 2008
    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

    Code ( (Unknown Language)):
    2. addi f,f,1
    3. 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

    Code ( (Unknown Language)):
    1. f = g + h;
    Am I right in this assumption, or is there something easy that I am missing? Thanks in advance
  2. veritas

    Active Member

    Feb 7, 2008
    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.