当前位置:网站首页>Compile advanced notes

Compile advanced notes

2022-07-07 14:53:00 weixin_ forty-five million seven hundred and fifty thousand fou

1、 Pressing stack and elastic stack Is a very important machine operation :

The characteristics of the stack : Grow down , The stack top address is the smallest ;

Stack pressing is 1) Open the drawer (esp Reduce the number of bytes of data to be pressed )2) Put in the data ( high

Put bit data into high address , Put the low order data into the low address ).

The bomb stack is :1) Take out the data ( The number of bytes depends on pop Suffix or destination register , meanwhile

The high address data is put into the high order of the destination register );2) Close the drawer (esp Increase the number of corresponding bytes )

2、 Basic and special operations Operation instructions need to remember the name and specific operation , Especially the sequence of operations ( For example, subtraction is subtracting the front from the back , Put the results in the back );

3、 The four most important Condition code

1)CF: Think of operations as “ Unsigned number operation ”, If there is progress / Borrow position , Then put 1;

2)OF: Think of operations as “ Signed number operation ”, If overflow occurs , Then put 1;

3)SF: If the highest order of the result is 1, Then put 1;

4)ZF: If the result is 0, Then put 1.

4、 Jump unconditionally jmp Jump directly to the specified address , namely : Write its operand as an address %eip, Realization CPU Change of instruction execution .

Four ways :

 jmp LABEL Use it directly LABEL Address

 jmp *LABEL Use LABEL Address stored in address ( indirect )

 jmp 0x8048056 Directly use the immediate number as the jump address

 jmp *%eax take %eax As the address of jump

5、 Conditions jump : According to different combinations of condition codes , Can determine the size relationship , A jump that depends on the size relationship is a conditional jump . The form of the instruction character is J Followed by the suffix indicating the determination result J Followed by the suffix indicating the determination result , example

Such as :JGE, Namely :jump if greater or equal— Jump when greater than or equal .

6、 Conditional transmission (cmov), Function and format and mov Exactly the same , The difference is that it is different from conditional jump

Same with suffix , Only when the comparison relationship represented by the suffix is satisfied can the data be transferred , for example :

comvge %ax,%bx Only when it is greater than or equal to %ax The content of is passed on to %bx

7、 Flag bit setting instruction ( Flag bit setting instruction (set) Is the operand that will follow ( A byte ) Set to 1, The premise is that the determination result meets its suffix

for example :setge %al Indicates that when greater than or equal to %al Set up 1. such , The result of the comparison is in one byte 1 In the form of .

8、 Circulation in the machine is through Conditions jump To achieve .

After the loop body is executed , To judge ( Loop variable , Or other cycle end conditions ), Not meeting the conditions , Jump directly to the next instruction address outside the circulation ; Meet the conditions , Jump back to the beginning of the loop .

原网站

版权声明
本文为[weixin_ forty-five million seven hundred and fifty thousand fou]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130613572771.html