I came across a question about assembly that I was confused on.

We are given the following table for addresses and instructions: enter image description here

The question says: replace the labels of PC-relative targets with their immediate values. What is the offset value of bnez at address 0x20? Write your answer in decimal.

I put -6, since if bnez, it goes to loop, which is at 0x14. However, the answer given is -12.

How did they get that?

  • 2
    \$\begingroup\$ Welcome to the site. When you say you 'came across' this question, do you mean this is homework? \$\endgroup\$
    – TonyM
    May 10, 2021 at 5:41
  • 4
    \$\begingroup\$ 0x20 and 0x14 are hexadecimal \$\endgroup\$
    – Oskar Skog
    May 10, 2021 at 6:25
  • 1
    \$\begingroup\$ Translate both addresses into decimal and try again. \$\endgroup\$ May 10, 2021 at 12:23


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.