Lab 9

4. First non-zero address: [0x10010000] Contents: 0x61
1st b: [0x10010001]
Last character "\n": [0x1001000f]

5. Line 10 (this will depend on whether you type in all the commented lines or not).
beq: 11
Address = [0x00400020]
sb $9, 0($10) and then into the machine code: 0xa1490000

6. 00400000, which is the starting address of the text segment. The instruction is la $t2, chararray.

7. It is [0x00400000], i.e. the first line of code from the program.
AbbbAAbbbAbAbAb, which IS the correct answer.

N.B. Ensure you reload the code at this stage!!!!

9. [0x10010000] is the value in $t2 after the two lines of pseudo-instructions have been executed.
The contents of this address are 0x61.
The letter specified by letter is 'A'.
The address of 'A' is [0x10010011].
'A' in ASCII is 0x41.
$t1: 0x00000041

10. $t0 contains 0x00000061.

11. No $t0 is not zero. Next instruction is "bne $t0, 'a', nota"

12. 'a': 0x61 ; $t0 contains 0x00000061.
The program will not branch. It moves onto the next instruction sb $t1, ($t2)

13. $t2: [0x10010000]
Memory location is [0x10010000]
The current value is 0x61.
After execution the address [0x10010000] holds 0x41.

14. $t2 holds the address of the current character in the string that is being checked for whether it is an 'a' or not.
After execution $t2 is now 0x10010001

15. nextCh specifies lb $t0, ($t2)
PC: [0x00400028] After execution PC is now [0x00400010]

16. $t2 is now [0x10010001], this is one more than last time, i.e. we have gone to the next letter in the string.
$t0 is now 0x62.

17. beqz $t0, strEnd
$t0 is not zero.
A conditional branch is not made.

18. 'a' is 0x61 in Hex. $t0 is now 0x62.
Yes a conditional branch is made. The next instruction is add $t2, 1

19. $t2 now contains [0x10010002].
PC is now [0x00400010]
The next instruction is lb $t0, ($t2)

20. Yes as $t0 is equal to zero.
[0x0040002c] which is the same value as in the PC register.

Hosted by www.Geocities.ws

1