Today, the assembly code of a C Bulider (Delphi) program is analyzed, and a tip of increasing code efficiency is found. I hope to provide a point when it is optimized to C Builder and Delphi programmers.
The assembly code is like this: When the input character of a text box is empty, the assembly code is: 00456DAB |. 8D55 E4 Lea Edx, DWORD PTR SS: [EBP-1C] 00456DAE |. 8b45 FC MOV Eax, DWORD PTR SS: [EBP-4] 00456db1 |. 8b80 cc020000 MOV EAX, DWORD PTR DS: [E8 90CAFCFF CALL CRACKME1.0042384C // Call GetdlgiteMtext00456DBC |. 8b45 E4 MOV EAX, DWORD PTR SS: [ EBP-1C] 00456dbf |. E8 08cDFAFF CALL CRACKME 1.00403ACC // Call Strlen Function 00456DC4 |. 85c0 Test Eax, EAX00456DC6 |. 0f8e F7010000 Jle CrackMe1.00456FC3
Next, it is connected to another string 00456dcf |. 8b45 FC MOV EAX, DWORD PTR SS: [EBP-4] 00456DD2 |. 8b80 CC020000 MOV EAX, DWORD PTR DS: [E8 6FCAFCFF Call crackme1.0042384c ~~~~~ / / Here we found a getDlgitemtext00456ddddd |. 8b55 E4 MOV EDX, DWORD PTR SS: [EBP-1C] 00456DE0 |. 8D45 EC LEA EAX, DWORD PTR SS: [EBP -14] 00456DE3 |. B9 68704500 MOV ECX, CRACKME1.0045706800456DE8 |. E8 2bcdfaff call crackme1.00403b18 // Call STRCAT functions
Translated into C Builder Code (Delphi) should be: if (Strlen (Edit1-> Text)> 0) {strtext = Edit1-> Text "Abcdef";} So, then we used edit1-> TEXT must call GetDlgitemText, which affects efficiency.
Rewrite this code we can write: str1 = edit1-text; if (str1)> 0) {str1 = str1 "abcDef"} This will be a getDLGItemText, the call, we know, each time more CALL A function, it is costly, such as the on-site save, stack operation, and code overhead inside the function.
I believe that there is a lot of similar edit1-> text operations in the Delphi (C Builder) code, and these excess overhead accumulates quite considerable, so we can greatly improve the efficiency, why we can change the style in the coding process. Leyure, not ~~ ^ _ ^
Good luck!