How I can see assembler code when Optimization level > 1 lazarus / 12-Debugger ---------------------------------------------------------------------- ydd · 2020-11-18 03:28 I do not need to debug it, just to see for example - asm code without optimization for:   i := Length(S); look like: Test.lpr:134                         i := Length(S); 00000001000018C3 488b1d46170800           mov    0x81746(%rip),%rbx      # 0x100083010 00000001000018CA 4885db                   test   %rbx,%rbx 00000001000018CD 7404                     je     0x1000018d3 00000001000018CF 488b5bf8                 mov    -0x8(%rbx),%rbx 00000001000018D3 4889d8                   mov    %rbx,%rax 00000001000018D6 482d00000080             sub    $0xffffffff80000000,%rax 00000001000018DC 48baffffffff00000000     movabs $0xffffffff,%rdx 00000001000018E6 4839d0                   cmp    %rdx,%rax 00000001000018E9 7605                     jbe    0x1000018f0 00000001000018EB e880b90000               callq  0x10000d270 00000001000018F0 89d8                     mov    %ebx,%eax 00000001000018F2 890528170800             mov    %eax,0x81728(%rip)      # 0x100083020 I believe it is possible to optimize it. I want to see asm code when optimization is turned on. For Delphi 2005 same code look like: Without optimization: Main.pas.279: i := Length(S); 004309D1 A148964300       mov eax,[$00439648] 004309D6 A354964300       mov [$00439654],eax 004309DB 833D5496430000   cmp dword ptr [$00439654],$00 004309E2 740F             jz $004309f3 004309E4 A154964300       mov eax,[$00439654] 004309E9 83E804           sub eax,$04 004309EC 8B00             mov eax,[eax] 004309EE A354964300       mov [$00439654],eax 004309F3 A154964300       mov eax,[$00439654] 004309F8 A350964300       mov [$00439650],eax With optimization: Main.pas.279: i := Length(S); 0042F9D3 8B1548864300     mov edx,[$00438648] 0042F9D9 8BC2             mov eax,edx 0042F9DB 85C0             test eax,eax 0042F9DD 7405             jz $0042f9e4 0042F9DF 83E804           sub eax,$04 0042F9E2 8B00             mov eax,[eax] ---------------------------------------------------------------------- bytebites · 2020-11-18 07:47 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i O1I:=Length(S);0000000000414DF9 488d0540d91200           lea    rax,[rip+0x12d940]      0000000000414E00 488b18                   mov    rbx,QWORD PTR [rax]0000000000414E03 4885db                   test rbx,rbx0000000000414E06 7404                     je     0x414e0c 0000000000414E08 488b5bf8                 mov    rbx,QWORD PTR [rbx-0x8]0000000000414E0C 4889d8                   mov    rax,rbx0000000000414E0F 482d00000080             sub    rax,0xffffffff80000000 O4I:=Length(S);000000000040BFA4 48c7c0d0335300           mov    rax,0x5333d0000000000040BFAB 488b00                 mov    rax,QWORD PTR [rax]000000000040BFAE 4885c0                   test   rax,rax000000000040BFB1 7404                     je     0x40bfb7 000000000040BFB3 488b40f8                 mov    rax,QWORD PTR [rax-0x8] ---------------------------------------------------------------------- PascalDragon · 2020-11-18 08:12 Quote from: ydd on November 18, 2020, 04:28:48 amI want to see asm code when optimization is turned on. Simply compile your code with the option -al. The resulting assembly file will then be called YourFile.s (in the same directory as the ppu and o files) and will contain the assembly code as its used for the final object file. ---------------------------------------------------------------------- ydd · 2020-11-18 13:05 Quote from: PascalDragon on November 18, 2020, 09:12:53 amSimply compile your code with the option -al. The resulting assembly file will then be called YourFile.s (in the same directory as the ppu and o files) and will contain the assembly code as its used for the final object file. thank you, problem solved!