2019-2020-1 20199321 "Linux kernel principle and Analysis" in the second week of work

The first part basics

Composed register

8086 CPU to register 16 as an example, can be divided into three categories.

General-purpose registers

Data registers: AX (accumulator), BX (Base Address Register), CX (counter register), DX (data register). Available as two separate 8-bit registers used.
Pointer Registers: SP (stack pointer register), BP (base pointer register)
index registers: SI (source index register), DI (index register object)

Control register

IP (instruction pointer register), FLAG (flag register)

Segment register

CS (code segment register), DS (data segment register), SS (stack segment register), ES (extra segment register)

In the 32 bits, usually added at the beginning of E; in the 64-bit, as will be added at the beginning of R.

Common assembly instructions

B is the last one means 8, w is the last one is 16-bit, 32-bit refers to the last bit is l, q means the last one is 64-bit
"from front to back to see"
Register Addressing: movl% eax,% edx;
seek immediate address: movl $ 0x123,% edx;
direct addressing: movl 0x123,% edx;
indirect addressing: movl (% eax),% edx;
indexed addressing: movl 4 (% eax), % edx; ( at the same address plus 4)

pushl% eax $. 4 corresponds subl, ESP%; Movl EAX%, (% ESP);
popl% EAX corresponds movl (% esp),% eax ; subl $ 4,% esp;

The second part of the experiment summary

: Wq command in the press "ESC" Enter; Note g / .s * / input

experiment analysis

leave instructions for revoking the function stack, equivalent EBP% Movl, ESP%; EBP popl%;
Enter instructions for revoking the function stack, equivalent pushl% ebp; movl% esp, % ebp;

To understand what is the meaning of the code, you must first know what ESP, EBP, EIP register is to be stored, combined with understanding of the stack in learning C language to understand.

Guess you like

Origin www.cnblogs.com/20199321zjy/p/11531377.html