CPE 315
SPIM Bugs and Gotchas

  1. Bad code is loaded
    If your .asm file has assembly errors, SPIM gladly loads it and will run it. (this is really bad design...)
    ALWAYS check the error window before you attempt a run.

  2. pseudoinstructions not caught
    Our assembler accepts pseudoinstructions of these forms:
    lw $1, address
    add $2, $2, 1
    add $3, 1
    Watch out. These aren't caught by the -nopseudo flag.

    You may not use these forms in your programs.

  3. missing -file flag
    If you forget the -file flag (e.g. xspim lab4.asm), no error message is generated AND
    xspim appears to be working. (it's not)

  4. lui constant
    The assembler will not accept constants with bit 15 == 0
    lui $1, 0x8000
    even though 0x8000 fits in 16 bits and the lui constant is an unsigned int.
    The workaround is to figure out a different way to get 0x80000000 into a register.
    The best way is probably to declare .word 0x80000000
    and then load it into the register.

  5. syscall 4
    syscall 4 doesn't work if $a0 points to the text area. The syscall displays the spim console but fails to display the string.
    $a0 must point to the data area.

  6. JAL bug
    JAL doesn't work if bit 31 of the address == 1.
    This is only a problem because of the kernal text area.
    The workaround is simple: use JALR instead.

  7. hidden pseudo instructions
    An instruction of the form:
    ori $t4,$t4,0x80000000
    correctly generates an assembly error.
    But then SPIM treats the instruction as a pseudo-instruction and generates two lines of code to accomplish the intended instruction.
    Wierd!

    An instruction of the form:

    lw $1, address
    is a valid MIPS 16 bit instruction.
    But SPIM treats it as a pseudo instruction and generates a 32 bit address. DO NOT use this pseudo instruction.

Last updated on 11/18/01