Lab 8
5. Messages, Data Segment, Text Segment, Registers.
6. The null termimated strings "Length is" , "hello world" and "\n".
7. Address: [0x10000000] Contents: 0x00
8. Line 11 (this will depend on whether you type in all the commented lines or not).
9. 00400000, which is the starting address of the text segment.
The instruction is la $t2, str.
11. Yes i.e. [0x00400000], i.e. the first line of code from the program.
N.B. Ensure you reload the code at this stage!!!!
12. The first line of code from the text segment has appeared in the messages window.
14. $t0 contains 0x68 if a lowercase h was used or 0x48 for 'H'. 15. No $t0 is not zero. Next instruction is "add $t1, $t1, 1" 16. $t1 is now 0x00000001.
17. $t2 holds the address of the current character being counted from the string.
This is similar to the "index" variable that you might have in Java for keeping
a record of which character in a string is being dealt with.
18. The instruction specified by the label nextCh is lb $t0, ($t2)
19. $t2 is now 0x10010001 at Step 14 it was 0x10010000.
20. The next instruction that will be executed is beqz $t0, strEnd
21. $t1 = 0x00000002 and $t2 = 0x10010002, we have counted two characters. Note here that the address is actually the third character at this stage but we need to check if it's the null terminator before counting it.
22. The program does make a conditional jump as the value of $t0 is 0.
23. $a0 = 0x1001000c, the contents at this address are "4c".
24. $v0 = 0x00000004. The register number is R2.
"Length is " has appeared in it.
25. It copies the values from $t0 into $a0.
26. 1 is used to print an integer.
27. Exit |