I was reading The intel microprocessor 8th edition. I came across the following text:

The Programming Model
The programming model of the 8086 through Core2 is considered to be program visible because its registers are used during application programming and are specified by the instructions. Other registers, detailed later in the chapter, are considered to be program invisible because they are not addressable directly during applications programming, but may be used indirectly during system programming.
This gives rise to the thought that all the instructions in 8086 and 8088 are program visible registers, including instruction pointer. Is it so?
You can’t touch the instruction pointer directly, but you can get it if you need to with a simple trick:
Then:
That’ll put the value of
eip, the instruction pointer, intoeax(because it’ll be whatever the stack pointerespwas referencing when you call intofetch_eip).It’s invalid to have
eipbe the destination of amovoperation, so you can’t fiddle witheipdirectly. The only way to affect it is with jump operations, call operations (as exploited by this trick), and some other limited cases.