BBC BASIC for Windows
Programming >> Assembly Language Programming >> EIP (instruction pointer) register http://bb4w.conforums.com/index.cgi?board=assembler&action=display&num=1243374283 EIP (instruction pointer) register
Post by David Williams on May 26th, 2009, 9:44pm
How can I read the contents of the EIP register, and is it safe to directly modify it?
This pertains to my attempt to create some position-independent code.
Regards,
David.
Re: EIP (instruction pointer) register
Post by admin on May 26th, 2009, 10:30pm
Quote:
How can I read the contents of the EIP register
You can use this code to copy eip into eax:
Code:
call next
.next
pop eax
Note that although this will always work, it may cause performance issues on modern processors which expect a call always to be paired with a ret.
Quote:
is it safe to directly modify it?
I'm not too sure what you mean by "directly" modifying it, but all the common means of modifying eip (jmp, call, ret) are "safe" in the sense that you should be able to rely on them doing what they're supposed to do!