Exercise: strcpy program in MIPS assembly
This is an exercise to familiarize you to MIPS assembly language and the SPIM simulator.
Examine the strcpy.asm program, with main and strcpy functions and data. The program is based on the discussion (p. 124-126) in the textbook.
Start SPIM, check delayed branches under setting. Load strcpy.asm
Examine the program and data areas. See how
beq $t2,$zero,L2 is assembled
How the packed byte string is represented started from location 0x10010000
Set break points (note addresses and enter them)
right at jal strcpy (it will stop right before)
in the called function at beq $t2,$zero,L2
right after coming back from the called function, i.e. at la $a0, x
Start execution. At breakpoints, observe what has happened
At jal strcpy: What are the contents of $a0, $a1? Note the value of $sp
At first beq $t2,$zero,L2: What are the contents of $s0, $t1, $t2, $t3? The new value of $sp? How did a data byte change?
At la $a0, x: What are the changed data bytes? The new value of $sp?
Are all the observations as you expected?
You don't need to turn anything in. But you will need the skills for programming in MIPS.