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

a. Suppose the program counter, PC, has the value 0x12345678. What is the value

ID: 3716476 • Letter: A

Question

a. Suppose the program counter, PC, has the value 0x12345678. What is the value of PC after executing the following jump instruction?

j 0x10

Note: The meaning of "0x10" here is that the j instruction has the value 0x10 (= 16 in decimal) in its 26-bit immediate field.

Answer: The value of PC after execution (in hex) = 0x_________ (give all 8 hexits, leading "0x" already given)

b. Suppose the program counter, PC, has the value 0x12345678. What is the value of PC after executing the following instruction?

beq $0, $0, -5

Note: The meaning of "-5" here is that the branch instruction has the value -5 in its 16-bit immediate field.

Answer: The value of PC after execution (in hex) = 0x_________ (give all 8 hexits, leading "0x" already given)

c. Suppose the program counter, PC, has the value 0x12345678. What is the value of PC after executing the following instruction?

bne $0, $0, 5

Note: The meaning of "5" here is that the branch instruction has the value 5 in its 16-bit immediate field.

Answer: The value of PC after execution (in hex) = 0x_________   (give all 8 hexits, leading "0x" already given)

The correct answers are 10000040, 12345668, and 1234567c. Please show me how you got the answers.

Explanation / Answer

a.
j 0x10;

new PC = base address + offset *4 = 0x10000000 + 0x40 = 0x10000040


b.
beq $0,$0,-5

it has -5 in it's immediate field which means the new PC would PC + 4 - offset*4 .Therefore;
NEW PC = PC + 4 - 5*4 = 0x12345678 + 0x4 - 14 = 0x12345668

c.
beq $0,$0,5

it has -5 in it's immediate field which means the new PC would old PC + offset*4 .Therefore;
NEW PC = PC + 4 + 5*4 = 0x12345678 + 0x4 + 14 = 0x12345690

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote