Byte Displacement in Assembly

651 views Asked by At

enter image description here

https://i.stack.imgur.com/CVHBj.png

I'm attempting to find the 1-byte displacement for some jumps. What I got was:

26
7
7
29

Not sure if I did that right though, any help?

1

There are 1 answers

1
Jester On BEST ANSWER

The offset is relative to the next instruction, you do not need to add the current instruction's length. In other words, the offset encoded is in addition to the normal increment that the cpu does for going to the next instruction. Which is why your first three answers are off by 2 each. Should be 0x24, 5 and 5.

For the last one you counted right, but forgot to negate the result because it's a backwards jump. Thus, the answer is -41 (decimal) which is 0xd7.

PS: you could have typed that into an assembler and verified the offsets yourself.