Sunteți pe pagina 1din 4

The International University Vietnam National University HCMC

QUIZ Duration: 30 minutes Date: Mar . 2013 Sheet: .

STUDENT INFO Student name: Student ID:

A MIPS assembly program in below is executed in MIPS 32-bit architecture at address 0x004000fc on memory.

addi $t0, $zero, 10 addi $s1, $zero, 0x3C sw $t0, 12($s1)

1. What are values of Program Counter, Memory Data and Address Registers while the third instruction of above program is executed? [60 points] 2. What is value of Instruction Register while the third instruction of above program is executed? [40 points] ---END---

SOLUTION At the third executing instruction in the 32-bit MIPS computer: Value of PC = starting address + 3*4 = 0x004000FC + 0x00000008 = 0x00400104 Value of MAR = base address + offset = value of $s1 + 0x0000000C = 0x0000003C + 0x0000000C = 0x00000048 Value of MDR = value of $t0 = result of first executed instruction = 0x0000000A Value of IR = machine code of sw instruction = 43 | reg number of $t0 | reg number of $s1 | 12 = 43 (6 bits) | 8 (5 bits) | 17 (5 bits) | 12 (16 bits) = 101011 | 01000 | 10001 | 0000 0000 0000 1100 =0xAD11000C

The International University Vietnam National University HCMC

QUIZ Duration: 30 minutes Date: Mar . 2013 Sheet: .

STUDENT INFO Student name: Student ID:

A MIPS assembly program in below is executed in MIPS 32-bit architecture at address 0x004000fc on memory.

addi $s0, $zero, 100 sll $t1, $s0, 2 add $t1, $t1, $s0

3. What are values of Program Counter, Memory Data and Address Registers while the third instruction of above program is executed? [60 points] 4. What is value of Instruction Register while the third instruction of above program is executed? [40 points] ---END---

SOLUTION At the third executing instruction in the 32-bit MIPS computer: Value of PC = starting address + 3*4 = 0x004000FC + 0x00000008 = 0x00400104 Value of MAR = 0x00000000 (No I-format Instructions have been done) Value of MDR = 0x00000000 (No I-format Instructions have been done)

Value of IR = add instruction = 0 | reg no of $t1 | reg no of $s0 | reg no of $t1 | 0 | 32 = 0 (6 bits) | 9 (5 bits) | 16 (5 bits) | 9 (5 bits) | 0 (5 bits) | 32 (6 bits) = 000000 | 01001 | 10000 | 10000 | 00000 | 100000 =0x01308020

S-ar putea să vă placă și