How does the EIP register get its value?

I just started to study assembly at school, and we begin to plunge into registers and how to use them. The point I cannot understand is how the instruction pointer gets the address of the next instruction? For example, enter the following code:

nop
pushl    %ebp
movl    %esp, %ebp
subl    $4, %esp

In the previous code, the instruction pointer is incremented after each line, and I would like to know how he knows, what team do next (eg mov, sub, push, ... etc ..)? All the previous instructions are first loaded into RAM at the first start of the program, and the address of the first command ( nopin this case) is automatically loaded into eip, and then just iterates over them one by one? Or am I missing something?

Any help is appreciated.

+4
source share
1 answer

EIPit is updated with microcode (firmware) in the CPU itself each time a command is extracted and decoded for execution. I do not believe that you can even access it at regular times. However, it can be changed with the help of an instruction jmpthat is functionally (does not include problems with the pipeline, etc.) Just like mov %eip,address. It is also updated with conditional jumps, calland retinstructions.

( , , ), ( - -) jmp . , , , , , main call ed.

+4

All Articles