Lab 6
3. Messages, Data Segment, Text Segment, Registers.
5. Math1.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.
6. The null termimated strings "ANSWER = " and "\n".
Also the numbers 7,3,4 and 5 have been stored in word format.
7. Address: [0x10000000] Contents: 0x00000000
8. The first statement is .data
There are 32 bits in a word. Remember bits = binary digits.
0x00000007
[0x10010000] to [0x10010003]
The label is X.
Next Address: [0x10010004] (Each word takes up 4 bytes, each address holds one byte).
Contents: 0x03.
B: [0x10010008] and C: [0x1001000c]
11. [0x10010010]
The string attached to the label ans consists of 9 bytes,
(6 alphabetic characters, 2 spaces and an equals).
|
Address of Memory Cells
|
Contents of Cell
|
Letter
|
|
[0x10010000]
|
07
|
7
|
|
[0x10010001]
|
00
|
0
|
|
[0x10010002]
|
00
|
0
|
|
[0x10010003]
|
00
|
0
|
|
[0x10010004]
|
03
|
3
|
|
[0x10010005]
|
00
|
0
|
|
[0x10010006]
|
00
|
0
|
|
[0x10010007]
|
00
|
0
|
|
[0x10010008]
|
04
|
4
|
|
[0x10010009]
|
00
|
0
|
|
[0x1001000A]
|
00
|
0
|
|
[0x1001000B]
|
00
|
0
|
|
[0x1001000C
|
05
|
0
|
|
[0x1001000D]
|
00
|
0
|
|
[0x1001000E]
|
00
|
0
|
|
[0x1001000F]
|
00
|
0
|
|
[0x10010010]
|
41
|
A
|
|
[0x10010011]
|
4e
|
N
|
|
[0x10010012]
|
53
|
S
|
|
[0x10010013]
|
57
|
W
|
|
[0x10010014]
|
45
|
E
|
|
[0x10010015]
|
52
|
R
|
|
[0x10010016]
|
20
|
(space)
|
|
[0x10010017]
|
3d
|
=
|
|
[0x10010018]
|
20
|
(space)
|
|
[0x10010019]
|
00
|
Null terminator
|
|
[0x1001001A]
|
0a
|
\n
|
|
[0x1001001B]
|
00
|
0
|
9. [0x0040000c]
Machine code: 20
[0x00400008] This maybe different if you have the li and la instructions in the
reverse order.
It is translated into: lui $1, 4097 [A] and lw $9, 4($1) [A].
10. 00400000, which is the starting address of the text segment.
lw $t0, X i..e the first line of code from the program.
11. Yes i.e. [0x00400000]
ANSWER = 180
N.B. Ensure you reload the code at this stage!!!!
13. The first line of code from the text segment has appeared in the messages window.
000000003, 000000004, 000000005.
mul is used to multiply numbers
The first operand stores the answer. The second and third are the two numbers
that are being multiplied together.
mult $8, $8 and mfl0 $12.
The contents are 0x31 or 49 in decimal. Under Simulator -> Settings there
is a choice of having the registers displayed in hex or not.
$t1 represents A = 3
$t4 represents X squared = 0x31 or 49 in decimal.
$t1 x $t4 - 147 in decimal or 93 in hex.
$t4 now holds 93 after this instruction is carried out.
$t5 = 28 in decimal, 1c in hex.
14. Total in decimal is 175 and AF in hex. Note that the 5 in $t3 has not been
added in yet!
15. 41 (which is the ASCII code for 'A')
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".
"ANSWER = " has appeared in it.
17. 1 is used to print an integer.
ANSWER = 180
18. Exit
19. The answer is 345
|