5

In the following code snippet, the EB F2 instruction is causing execution to jump back up to the line indicated by the arrow. How is this the case given that there is no address supplied to EB and the jmp is less than F2 away in terms of address distance?enter image description here These two locations are 0xC from each other.

1 Answer 1

10

from google starmans realm

quoting relevant info

These are also known as SHORT Relative Jumps. Programs using only Relative    
Jump  instructions can be relocated anywhere in memory without having to     
change the    machine code for the Jumps. The first byte of a SHORT Jump is    
always EB and the    second is a relative offset from 00h to 7Fh for Forward    
jumps, and from 80h to    FFh for Reverse (or Backward) jumps. [Note: The    
offset count always begins at    the byte immediately after the JMP    
instruction for any type of Relative Jump!] 

so eb 01 to eb 7f jumps forward
eb fe to eb 80 jumpf backward

so current instruction is at 0x172b066 adding the opcode length 2 the current instruction ends at xxxx68 or the next instruction starts at 0xxxxx68 0xf2 == -0xe (read about twos complement notation)

0xxxxx68 - 0xe = 0xxxxx5A

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.