The QtSPIM MIPS simulator automatically sets the registers a1 and a2 to the following values upon execution of the first line of any assembler program:
R5 [a1] = 7ffff57c
R6 [a2] = 7ffff584
What is the reason for that? Is there a way to avoid it?
QtSPIM loads a short start sequence that invokes main
. This start sequence sets argc
, and argv
, so that main
can have a normal C-style signature: int main(int argc, char*argv[]);
.
When you run QtSPIM, it first loads the kernel-mode exception handler file, which actually includes this user-mode startup sequence. You should notice that your assembler program is loaded at 004000020
or so, and the code starting at 00400000
up to 00400018
is that user-mode startup.
See also this answer on QtSPIM: Explanation for code shown without loading program which speaks to the exception handler file.
The way to avoid this is to load/specify your own exception handler file (see above link) that is empty — or at least doesn't have a .text
section (only .ktext
) You will forgo the exception handler itself, but that doesn't do much except print the exception.