Homework 5
Show work for full credit
-
(5 points)
Show the machine code generated for the following MAL code fragment. The code starts at address 0x00aa0000.
Give all addresses in hexadecimal. Give the code both in binary and in hexadecimal.
jr $ra addi $a0, $s0, -4 mult $t0, $t1 mflo $s3
-
(5 points) Give machine code generated for the following TAL code fragment. Start code at address 0x0806a000. Give all addresses in hexadecimal. Give the code both in binary and in hexadecimal.
ori $a1, $t4, 0x0bbb add $s1, $s2, $s3 lw $t0, -12($sp) jr $ra
-
(18 points total)
Computers store both instructions and data as bits in memory. When they
fetch instructions from a memory location, they must decode the bits stored
there to determine what instruction they should perform. The table below
shows part of the computer's memory that contains instructions.
Address Hex Contents TAL Instruction [0x00400000] 0x3c011001 . [0x00400004] 0x34280190 . [0x00400008] 0x3c081001 . [0x0040000c] 0xad080000 . [0x00400010] 0x2108fff9 . [0x00400014] 0x0128502a . [0x00400018] 0x1540fff9 . [0x0040001c] 0x3402000a . [0x00400020] 0x0000000c . (A) Decode the bits stored in memory to determine which TAL instructions are stored in each location. Write legal TAL code to the right of each memory location in the table above.
(B) The linker and loader placed the data segment at address 0x10010000. Which instructions, if any, would change if the data were relocated to begin at address 0x20000000? If any changed, write the hex contents and corresponding TAL instructions in the table below. ONLY FILL IN ENTRYS THAT HAVE CHANGED. For entries that do NOT change, write "N/C".
Address Hex Contents TAL Instruction [0x00400000] . . [0x00400004] . . [0x00400008] . . [0x0040000c] . . [0x00400010] . . [0x00400014] . . [0x00400018] . . [0x0040001c] . . [0x00400020] . . (C) The linker and loader placed the text segment at address 0x00400000. What instructions, if any, would change if the text were relocated to begin at address 0x00801000? If any changed, write the hex contents, and corresponding TAL instructions below. ONLY FILL IN ENTRYS THAT HAVE CHANGED. For entries that do NOT change, write "N/C".
Address Hex Contents TAL Instruction [0x00400000] . . [0x00400004] . . [0x00400008] . . [0x0040000c] . . [0x00400010] . . [0x00400014] . . [0x00400018] . . [0x0040001c] . . [0x00400020] . . -
(4 points) Assume the MAL instruction
beq $t4, $s3, loop
is placed at address 0x0080abc0 by the assembler. The symbol loop is already in the symbol table, and has been assigned address 0x00800004. Give machine code for the beq instruction. -
(4 points) Assume the MAL instruction
jal procX
is placed at address 0x0080e040 by the assembler. The symbol procX is assigned address 0x00820c0c. Give machine code for the jal instruction. -
(4 points)
Consider the following MAL program:
__start: la $8, foo foo: lw $9, 0($8) done
- (5 points) A disk takes at most 10 milliseconds to move its read/write head over the correct cylinder. The disk is spinning at 4600 revolutions per minute, and it can transfer 2 Megabytes per second. The disk handles a request to read 2 256-byte sectors located on different tracks. What is the worst case time to do this?
-
(6 points)
A disk has 2000 tracks per surface, 12 platters. Each platter
provides two surfaces except the top and bottom, which only provide one
each. The tracks are 0.0125 millimeters apart, center to center, with the
innermost track having a diameter of 8 cm. The linear density of the
innermost track is 25,000 bits per cm.
(A) How many bits can be stored on the innermost track? (B) How many bits can be stored on the innermost cylinder? (C) If the same density of bits is stored on every track, how many total bits can be store on the outermost cylinder of the disk?
-
(6 points)
When a program is executed, it enters the kernel
with the following values in the coprocessor 0 registers:
$12: 0x00000000 $13: 0x00000014 $14: 0x00400024 The memory for the text segment looks like this: [0x00400000] 0x3402000c 0x0000000c0x00404020 0x310800fe [0x00400010] 0x01280018 0x3c0110010xac290000 0x01094820 [0x00400020] 0x3c011001 0xac2900010x21090001 0x3c011001 [0x00400030] 0x80290000 0x3c0110010x802a0001 0x012a4820 [0x00400040] 0x3c011001 0xac2a00000x3402000a 0x0000000c (A) What was the reason for entering the kernel? (B) What was the address of the instruction that caused the error? (C) Give a reasonable TAL description of the instruction.
- (3 points) Explain the purpose and use of the variable "flag" in the code on page 323.
- (3 points) When the clock interrupt on a computer occurs, the exception handler requires an average of 11 instructions to handle the interrupt and return control to the program it interrupted. If the computer can execute 300 million instructions per second, and the interrupt occurs every 10 microseconds, what percentage of the computer's total time is devoted to handling clock interrupts?