, and register use;It is a strong Convention that requires binary compatibility. If different call conventions are used by function callers and function bodies, program execution errors may occur and must be considered as part of the function declaration;
Ii. Common function call conventions;
Function call conventions in vc6;
Call Convention stack clearing parameter passing_ Cdecl the caller passes the stack from right to left_ Stdcall function is passed through Stack from right to left_ Fastcal
Method 1
MoV eax, 0MoV EBX, 0MoV ECx, 0MoV edX, 0
Method 2
XOR eax, eaxXOR edX, EDXXOR ECx, ECxXOR edX, ECx
Method 3
Hmm... yep, here the stall is partially balanced by the non-change of the source argument (a work/branch avoided by the CPU), so in this specific case, the difference is minimized.
XOR eax, eaxXOR ECx, ECxMoV EBX, eaxMoV
Chinese character. It is not hard to understand that the sixteen bits are two bytes. Of course, if there are sixteen bits, there must be thirty-two bits, sixty-fourteen bits, and so on. The thirty-two bits are called dual characters, and the sixty-fourteen bits are called four characters. The CPU we use today is believed to be 32-bit, unless you use 286 or earlier. Naturally, the registers in the CPU are 32-bit. That is to say, a register can hold 32 0 or 1 (this does not include segment regist
return value of the Function
Test code:
Struct Tagtest {
Int M_one;
Int M_two;
Int M_three;
Int M_four;
};
Tagtest rerstruct (){Tagtest testret;Testret. m_one =1;Testret. m_two =2;Testret. m_three =3;Testret. m_four =4;ReturnTestret;}
Disassembly code:
30 : Tagtest
Test
;
31 :
Test = Rerstruct ()
;
00401078
Lea Eax, [ebp-30h]; The ebp-30h address into the stack, the function of the struct value
00401_ B
Push Eax
00401_c
Call @ ILT +
0 (Rerstruct )(
0040100
,ec
MOVL%edx,ed
MOVL%esi,es
Ii. explanation of the content after the third colon
The third colon is optimized for GCC, which tells GCC how to use registers and memory in this assembly code, so that GCC does not cause errors when optimizing processing. It can be a register name such as "EAX", "ebx", "ecx", which means that the assembly code explicitly operates on the register, such as ASM ("MOV%%eax,%0 ",:" =r "(foo)::" EAX ") so that GCC avoids us
; Comparison0040132f |. 75 42 jnz short crackhea.00401373; wait until it is finished
The cursor stops at the command at the 00401328 address. Now we press F7 to follow up:
004013d2/$56 push ESI; ESI into Stack004013d3 |. 33c0 XOR eax, eax; eax cleared004013d5 |. 8d35 c4334000 Lea ESI, dword ptr ds: [4033c4]; send the value in the registration code box to ESI004013db |. 33c9 XOR ECx, ECx; ECx cleared004013dd |. 33d2 XOR edX,
The switch and if-else statements are both conditions in the C language. In terms of syntax, the two functions are the same. If the switch can be completed, the switch can also be completed, however, their application scenarios are slightly different. If is mostly used in a single branch, switch is mainly used in the case of multiple branches.
Let's take a look at the C program and the Assembly Code Compiled with GCC.
/* $ Begin switch-C */Int switch_eg (int x){Int result = X;
Switch (x ){
Case
analysis can be seen, the correct serial is stitched out.Show Code:
0042fa52 |. E8 D96EFDFF Call Acid_bur.004069300042fa57 |. 83F8 CMP eax,0x4; Compares whether the length of a string is greater than or equal to 40042FA5A | 7D 1D jge Short acid_bur.0042fa790042fa5c |. 6A Push 0x00042fa5e |. B9 74fb4200 mov ecx,acid_bur.0042fb74; ASCII, "Ry again!" 0042fa63 |. BA 80fb4200 mov edx,acid_bur.0042fb80; ASCII, "Orry, the serial is Incorect!" 0
the number of the string has changed, and so on the CW and so on the letter has not changed from the above analysis can be seen, the correct serial should be spliced out, in addition to the middle of the number of strings, the other content is hard coding good.show Code: 0042fa52 |. E8 D96EFDFF Call Acid_bur.004069300042fa57 |. 83F8 CMP eax,0x4; Compares whether the length of a string is greater than or equal to 40042FA5A | 7D 1D jge Short acid_bur.0042fa790042fa5c |. 6A Push 0x00042fa5e
command to get.Before calling the CPUID, the function code is stored in the EAX. After calling the CPUID, Eax,ebx,ecx,edx stores the various characteristic information of the CPU. This information is what we commonly call CPU serial numbers.mov eax, 0//Get manufacturer InfoCpuidmov eax, 1//Get the serial number of the CPUCpuidThe following three functions are available for reference:[C-sharp]View Plaincopy
function Newcpuid: string;
Const
CP
Linux-0.11 Memory Management module is the source of the more difficult to understand the part, now the author's personal understanding publishedFirst hair Linux-0.11 kernel memory management get_free_page () function analysisHave time to write other functions or files:)/* *author:davidlin *date:2014-11-11pm *email: [email protected] or [email protected] *world:the City of SZ , in China *ver:000.000.001 *history:editor time do 1) Linpeng 2014-11-11 Created this file! 2) */Here is the source code
; transfer to Tmpbuffer jmp wtin WTOUT:STOSB; Tmpbuffer end; ----------------------------------- ; Handling null Parameters "" (In fact, "->255"); -----------------------------------Lea ESI, Tmpbuffer Lea EDI, Cmdbuffer xor edx, edx, clear 0, using RNSST as a flag register: LODSB cmp al, 0 je rnsend; ESI points to null, which is done. if al! = 34; The character is not quoted. if
, nt must be added for each line, for example:
Asm (pushl % eaxnt
Movl $0, % eaxnt
Popl % eax );
In fact, gcc needs to print the content of asm (...) to the Assembly file when processing the assembly, so it is necessary to control the format. For example:
Asm (movl % eax, % ebx );
Asm (xorl % ebx, % edx );
Asm (movl $0, _ booga );
In the above example, we changed the values of edx and ebx in the Assembly, b
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.