Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. The table on the next page is the history of instructions and registers when

ID: 3349329 • Letter: 1

Question

1. The table on the next page is the history of instructions and registers when the following code is executed. The first column indicates which instruction is executed and the remaining columns indicate the value of registers after the instruction is executed. Fill out the table until the instruction at address 0x18 (nop) is reached. If a register is not updated, you may leave the cell blank. The first 10 instructions are given as an example. 0x00 main: 0x10 0x14 0x18 addi a0, $0, 1 ial sub1 no 0x30 0x34 0x38 0x3C 0x40 0x44 0x48 0x4C 0x50 0x54 0x58 ain $sp, sp,-8 sw $ra, 4($sp) sw a0, 0 (Ssp) subl: jr $ra L1 : ial sub1 lw a0, 0 (Ssp) 1w $ra, 4($sp) addi Ssp, SSp, 8 jr $ra nextl:

Explanation / Answer

The following is the table

Instruction

$pc

$sp

$ra

$a0

addi $a0, $0, 1

0x14

0x80

0x00

0x01

jal sub1

0x30

0x80

0x18

0x01

addi $sp, $sp, -8

0x34

0x78

sw $ra, 4($sp)

0x38

sw $a0, 0($sp)

0x3C

bne $a0, ,$0, L1

0x44

addi $a0, $a0, -1

0x48

0x00

jal sub1

0x30

0x4C

addi $sp, $sp, -8

0x34

0x70

sw $ra, 4($sp)

0x38

sw $a0, 0($sp)

0x3C

bne $a0, ,$0, L1

0x40

jr $ra

0x4C

lw $a0, 0($sp)

0x50

0x00

lw $ra, 4($sp)

0x54

0x4C

addi $sp, $sp, 8

0x58

0x78

jr $ra

0x4C

lw $a0, 0($sp)

0x50

0x01

lw $ra, 4($sp)

0x54

0x18

addi $sp, $sp, 8

0x58

0x80

jr $ra

0x18

nop

0x1C

Stack contents

Address

Content

0x80

0x7C

0x18

0x78

0x01

0x74

0x4C

0x70

0x00

Instruction

$pc

$sp

$ra

$a0

addi $a0, $0, 1

0x14

0x80

0x00

0x01

jal sub1

0x30

0x80

0x18

0x01

addi $sp, $sp, -8

0x34

0x78

sw $ra, 4($sp)

0x38

sw $a0, 0($sp)

0x3C

bne $a0, ,$0, L1

0x44

addi $a0, $a0, -1

0x48

0x00

jal sub1

0x30

0x4C

addi $sp, $sp, -8

0x34

0x70

sw $ra, 4($sp)

0x38

sw $a0, 0($sp)

0x3C

bne $a0, ,$0, L1

0x40

jr $ra

0x4C

lw $a0, 0($sp)

0x50

0x00

lw $ra, 4($sp)

0x54

0x4C

addi $sp, $sp, 8

0x58

0x78

jr $ra

0x4C

lw $a0, 0($sp)

0x50

0x01

lw $ra, 4($sp)

0x54

0x18

addi $sp, $sp, 8

0x58

0x80

jr $ra

0x18

nop

0x1C