3

What is the difference between jmp function and mov function, %eip

Actually, What happens when i change the eip value forcefully?

I know that a eip is instruction pointer that pointing the instruction that will be executed by CPU.

This means that the CPU reads the eip and load the instruction from memory by referring eip.

Is it possible?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Joontaek Oh
  • 152
  • 9
  • 3
    `mov $function, %eip` doesn't assemble; that's not how x86 works. The instruction for moving values to EIP is called `jmp`. – Peter Cordes Mar 23 '18 at 10:56
  • 1
    There is no instruction `mov function,%eip`. On i386, `%eip` is not a general purpose register. – fuz Mar 23 '18 at 10:56
  • What does work though is `mov something,%cs`. I recall this causing a far jump on 8086, but I'm not sure on what the effect is on later architectures. Similarly, the 8086 had `pop %cs` causing a far jump, but this instruction was actually removed in the 80186. – fuz Mar 23 '18 at 10:57
  • 1
    @fuz: I think I recall someone commenting that only *early* 8086 silicon supported `mov` or `pop` to set `CS`. Both are invalid in 186 and later: see the current docs for `mov`: https://github.com/HJLebbink/asm-dude/wiki/MOV. *The MOV instruction cannot be used to load the CS register. Attempting to do so results in an invalid opcode exception (`#UD`). To load the CS register, use the far JMP, CALL, or RET instruction.* – Peter Cordes Mar 23 '18 at 11:06

0 Answers0