Re: Why isn't there a JMP immediate or absolute?




spamtrap@xxxxxxxxxx wrote:
It has been a while, but I had to write some 32 bit x86 assembly. This
was a function
thunk in Windows / Win32.

I was looking for a simple 5 byte instruction to JMP to an absolute
(ie. non-relative)
or immediate (imm32) address. Essentially very simple code generation.

I could not find such an instruction. All the JMPs were relative,
indirect, or specifying some segment index/TSS switch. In fact, in all
the windows thunking code, they branch relative which requires a tiny
amount of extra work when generating the code. I ended up using the EAX
register and more than one instruction to accomplish this.

Why was this choice made by Intel??

thx in advance

JMP FAR does what you want. Of course, in flat-model OSes (like Windows
or Linux) you don't really get to use it. That's the real problem.

Then again, I would argue that a tiny bit of extra work at code
generation time is a whole lot better than executing two instructions
at run time. How hard is it to compute the distance between the JMP and
target if you already know the target address?
Cheers,
Randy Hyde

.



Relevant Pages