Lab 5

5. Messages, Data Segment, Text Segment, Registers.

7. Hello.asm has been successfully loaded. If an error occurs check that there is a carriage return on the last line, i.e. go to the end of the place line and press the enter key.

8. The null termimated string "hello world". The label str was attached to it.

Address: [0x10000000] Contents: 0x00000000

9. The first statement is .data
NB. there is a misprint here, the letter 'h' is represented by 0x68 (in Hex).
It takes 1 byte to store a letter.
Address: [0x10010000]
The label is str.
Next Address: [0x10010001] (Each letter takes up 1 byte, each address holds one byte).
Contents: 0x65.

10.

Address of Memory Cells Contents of Cell Letter
[0x10010000] 68 h
[0x10010001] 65 e
[0x10010002] 6c l
[0x10010003] 6c l
[0x10010004] 6f o
[0x10010005] 20 (space)
[0x10010006] 77 w
[0x10010007] 6f o
[0x10010008] 72 r
[0x10010009] 6c l
[0x1001000A] 64 d
[0x1001000B] 0a \n

11. [0x0040000c]
Machine code: 0c
[0x00400008] This maybe different if you have the li and la instructions in the reverse order.
It is translated into: ori $2, $0, 4 (Mnemonic description) and then into 0x34020004 (machine language).
Register $v0.

12. 00400000, which is the starting address of the text segment.
li $v0,4 i..e the first line of code from the program.

13. Yes i.e. [0x00400000]
hello world

15. The first line of code from the text segment has appeared in the messages window.
[0x10010000], this is the first address where data is stored in the data segment.
It refers to the 'G' of "Good Morning".

16. 10010000.
The function of $a0 is to store data or an address where data is held. It stores an integer when an integer has to be printed and the starting address of a string, when a string has to be printed.
The next lines from the program.

17. 00000004
R2
$v0 holds the system call codes from 1 to 10. Anytime a syscall command is executed the content of $v0 are checked to see what has to be done.
4 represents "print a string".

18. Good Morning has appeared in it.

19. 0000000a
Exit

20. The last line from the text segment has been added to the messages window.

Hosted by www.Geocities.ws

1