0

I load up 2 files into SPIM in order.

File 1:

.globl getCount
.data
count:          .word 50

.text
getCount:       lw $v0, count($0)
                jr $ra

File 2:

 .text
  main:  #code to call the getCount label and print the result stored in $v0
         jr $ra

When SPIM merges the 2 files, it always seem to know to run at adress main and use the jr $ra in main to exit the program after printing the result. It doesn't run at address getCount and exit program with that method's jr $ra.

So I'm asking, is the main label a reseerved label that SPIM detects to run first or maybe that main chunk is put above the address of other ones?

NoName
  • 9,824
  • 5
  • 32
  • 52
  • Inspect the text segment and look at what code the simulator places before your code. – Michael May 24 '17 at 05:24
  • Okay, I see a `jal main` before my code, so the `main` label is special. I'm assuming if I replaced my `main` label with `main2`, it wouldn't work. – NoName May 24 '17 at 18:17

0 Answers0