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

1. A function is called using an jal instruction. The jal instruction is located

ID: 3682469 • Letter: 1

Question

1. A function is called using an jal instruction. The jal instruction is located at 0x00402000. The function is located at 0x00404008. What is the value in the PC after the jal instruction is executed?

a. 0x00402000

b. 0x00404008

c. 0x00402004

d. 0x0040400C

2. A function is called using an jal instruction. The jal instruction is located at 0x00402000. The function is located at 0x00404008. What is the value in the $ra after the jal instruction is executed?

a. 0x00402000

b. 0x00404008

c. 0x00402004

d. 0x0040400C

Explanation / Answer

jal means jump and link instruction

Syntax:

jal LabelName

jr = jump to the address mentioned in the register

jr means Jump Return or Jump Register

location of jal instruction = 0x00402000

location of function = 0x00404008

Program Counter PC =

The PC contains the next instruction’s memory address on the pipe line to be executed

4

every instruction is stored 4 memory location addresses apart

00400038

0040003C

00400040

00400044

00400048

0040004C

00400050

etc

when the jal is at 0x00402000 and if the current instruction is at the same 0x00402000 then the Program Counter (PC) will hold the address of the next instruction to be executed

that will be = 0x00402000 + 4 = 0x00402004

But when the jal had already jumped to the label at 0x00404008 then the the next instruction to be executed has to be in 0x00404008 + 4 = 0x0040400C

2.

$ra is the return address register used by the jr ( jump register)

the op code used is register – register

reg – reg

the function code used is 8

the value of the return address will be the address of the next instruction that is immediately following the jump call

the jal is at 0x00402000

hence the return address will be 0x00402004