0

What are the operands to perform an absolute Far Jmp?

I think it should look something like below:

EA XX XX XX XX

I tried making XX XX XX XX a 4 byte address to which I wanted to jump, but it didn't work as intended.

user1432882
  • 1,126
  • 4
  • 14
  • 29
  • What address did you use for `XX XX XX XX`? Keep in mind it's little endian too – Govind Parmar Feb 10 '19 at 01:35
  • 1
    If you are talking about 16-bit code then a FAR JMP (direct addressing) would be something like: `jmp word 0x5678:0x1234` (segment:offset). They are stored in the instruction in little endian format. Offset first and segment last. `jmp word 0x5678:0x1234`would be `EA 34 12 78 56` .A segment:offset pair translate into the physical address segment<<4+offset and in my example that would be (0x5678<<4)+0x1234=0x56780+0x1234=physical address 0x579B4 – Michael Petch Feb 10 '19 at 01:37

1 Answers1

7

This will be an absolute far jump.

For example, for 16-bit code the bytes 0xEA, 0x12, 0x34, 0x56, 0x78 wll be the instruction jmp far 0x7856:0x3412 (where CPU will try to set CS to 0x6745 and set IP to 0x3412).

For 32-bit code the size needs to be larger. E.g. the bytes 0xEA, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC will be the instruction jmp far 0xBC9A:0x78563412 (where CPU will try to set CS to 0xBC9A and set EIP to 0x78563412).

In other words, the operands are the target 16-bit IP (or 32-bit EIP) followed by the target code segment; with both pieces in little-endian order.

Brendan
  • 35,656
  • 2
  • 39
  • 66
  • 1
    Or 16-bit code with a 32-bit operand (for i386+ systems) is allowable with a prefix. NASM syntax would be `jmp dword 0xBC9A:0x78563412` which would be instruction encoding prefixed with a 0x66 operand prefix – Michael Petch Feb 10 '19 at 02:08