Is the instruction pointer a program visible register?

I read the 8th release of the Intel microprocessor. I came across the following text:

enter image description here

Programming model

The 8086 programming model through Core2 is considered a visible program , because its registers are used during application programming and are indicated in the instructions. Other registers, described in detail later in the chapter, are considered software invisible because they are not addressed directly during application programming, but can be used indirectly during system programming.

This leads to the idea that all instructions in 8086 and 8088 are software visible registers, including an instruction pointer. This is true?

+4
source share
2 answers

You cannot directly touch the instruction pointer, but you can get it if you need with a simple trick:

fetch_eip: mov eax, [esp] ret 

Then:

 call fetch_eip 

Put the value eip , the instruction pointer, in eax (because it will be that the esp stack pointer was referenced when fetch_eip called).

It is not eip that eip was the destination of the mov operation, so you cannot play with eip directly. The only way to influence this is with jump operations, call operations (as used by this trick), and some other limited cases.

+6
source

The instruction pointer is a special-purpose register, see this article for a list of all 8086 registers: Inside an 8086 CPU (CPU)

In general, there is no reason for IP to be "software". Its value will be influenced by code that uses any commands that affect the control flow, for example, call or jmp . Actual IP value is not required.

+1
source

Source: https://habr.com/ru/post/1394410/


All Articles