Skip to content

3.0 - Stack operations

Compare
Choose a tag to compare
@katepavlu katepavlu released this 02 Nov 09:27
· 4 commits to master since this release

Changes

  • added automatic prelude insertion. Before each program, the following instructions are inserted:
    lui $gv, 0x1000 # initialize global pointer
    lui $sp, 0x8000 # initialize stack pointer
    ja $zero, main  # jump to main function
    
  • because ja is a pseudoinstruction, this translates to five machine instructions. As such, your program now starts at address 0x14(=20)
  • added two new pseudo-instructions:
    push $t0 # push the contents of t0 onto the stack
    pop $t0   # retrieve the top value from the stack into $t0
    
  • error messages now correctly refer to the file the error is in
  • error messages now count lines from 1 (was 0 in previous releases)

Migration

  • add a "main:" label to the entry point of your program
  • if you are using manually calculated jumps anywhere, add 20 to your addresses