在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
技术交流,DH讲解. 之前照着天书夜读,用Delphi来弄了下循环体,现在就来弄一下条件判断吧. Var I: Integer; Begin I:= 99; If (I> 0)And (I< 0) Then Writeln('I>0') Else If (I> 10)And (I< 100) Then Writeln('I>10 and I<100') Else Writeln('I>100'); End. 反汇编出来会是什么样子的呢? Project5.dpr.12: I:= 99; 004AC44C B863000000 mov eax,$00000063 Project5.dpr.13: If (I> 0)And (I< 0) Then 004AC451 85C0 test eax,eax 004AC453 7E1F jle $004ac474 004AC455 85C0 test eax,eax 004AC457 7D1B jnl $004ac474 Project5.dpr.14: Writeln('I>0') 004AC459 A1DC314B00 mov eax,[$004b31dc] 004AC45E BAC4C44A00 mov edx,$004ac4c4 004AC463 E874BAF5FF call @Write0UString 004AC468 E8BF89F5FF call @WriteLn 004AC46D E83E7FF5FF call @_IOTest 004AC472 EB3E jmp $004ac4b2 Project5.dpr.16: If (I> 10)And (I< 100) Then 004AC474 83F80A cmp eax,$0a 004AC477 7E20 jle $004ac499 004AC479 83F864 cmp eax,$64 004AC47C 7D1B jnl $004ac499 Project5.dpr.17: Writeln('I>10 and I<100') 004AC47E A1DC314B00 mov eax,[$004b31dc] 004AC483 BAD8C44A00 mov edx,$004ac4d8 004AC488 E84FBAF5FF call @Write0UString 004AC48D E89A89F5FF call @WriteLn 004AC492 E8197FF5FF call @_IOTest 004AC497 EB19 jmp $004ac4b2 Project5.dpr.19: Writeln('I>100'); 004AC499 A1DC314B00 mov eax,[$004b31dc] 004AC49E BA04C54A00 mov edx,$004ac504 004AC4A3 E834BAF5FF call @Write0UString 004AC4A8 E87F89F5FF call @WriteLn 004AC4AD E8FE7EF5FF call @_IOTest 我们这里就容易得出来Delphi里面IF语句的结构了. Var I: Integer; Begin I:= 9; Case I Of 0: Writeln('0'); 1: Writeln('1'); 2: Writeln('2'); 3: Writeln('3'); 4: Writeln('4'); 5: Writeln('5'); 6: Writeln('6'); 7: Writeln('7'); Else Writeln('0'); End; End. 反汇编一下: Project5.dpr.12: I:= 9; 004AC44C B809000000 mov eax,$00000009 Project5.dpr.13: Case I Of 004AC451 83F807 cmp eax,$07 004AC454 0F8703010000 jnbe $004ac55d 004AC45A FF248561C44A00 jmp dword ptr [eax*4+$4ac461] 004AC461 81C44A009EC4 add esp,$c49e004a 004AC467 4A dec edx 004AC468 00BBC44A00D8 add [ebx-$27ffb53c],bh 004AC46E C44A00 les ecx,[edx+$00] 004AC471 F5 cmc 004AC472 C44A00 les ecx,[edx+$00] 004AC475 0FC54A0029 pextrw ecx,qword ptr [edx+$00],$29 004AC47A C54A00 lds ecx,[edx+$00] 004AC47D 43 inc ebx 004AC47E C54A00 lds ecx,[edx+$00] Project5.dpr.15: Writeln('0'); 004AC481 A1DC314B00 mov eax,[$004b31dc] 004AC486 66BA3000 mov dx,$0030 004AC48A E8DDADF5FF call @Write0WChar 004AC48F E89889F5FF call @WriteLn 004AC494 E8177FF5FF call @_IOTest 004AC499 E9D7000000 jmp $004ac575 Project5.dpr.17: Writeln('1'); 004AC49E A1DC314B00 mov eax,[$004b31dc] 004AC4A3 66BA3100 mov dx,$0031 004AC4A7 E8C0ADF5FF call @Write0WChar 004AC4AC E87B89F5FF call @WriteLn 004AC4B1 E8FA7EF5FF call @_IOTest 004AC4B6 E9BA000000 jmp $004ac575 Project5.dpr.19: Writeln('2'); 004AC4BB A1DC314B00 mov eax,[$004b31dc] 004AC4C0 66BA3200 mov dx,$0032 004AC4C4 E8A3ADF5FF call @Write0WChar 004AC4C9 E85E89F5FF call @WriteLn 004AC4CE E8DD7EF5FF call @_IOTest 004AC4D3 E99D000000 jmp $004ac575 Project5.dpr.21: Writeln('3'); 004AC4D8 A1DC314B00 mov eax,[$004b31dc] 004AC4DD 66BA3300 mov dx,$0033 004AC4E1 E886ADF5FF call @Write0WChar 004AC4E6 E84189F5FF call @WriteLn 004AC4EB E8C07EF5FF call @_IOTest 004AC4F0 E980000000 jmp $004ac575 Project5.dpr.23: Writeln('4'); 004AC4F5 A1DC314B00 mov eax,[$004b31dc] 004AC4FA 66BA3400 mov dx,$0034 004AC4FE E869ADF5FF call @Write0WChar 004AC503 E82489F5FF call @WriteLn 004AC508 E8A37EF5FF call @_IOTest 004AC50D EB66 jmp $004ac575 Project5.dpr.25: Writeln('5'); 004AC50F A1DC314B00 mov eax,[$004b31dc] 004AC514 66BA3500 mov dx,$0035 004AC518 E84FADF5FF call @Write0WChar 004AC51D E80A89F5FF call @WriteLn 004AC522 E8897EF5FF call @_IOTest 004AC527 EB4C jmp $004ac575 Project5.dpr.27: Writeln('6'); 004AC529 A1DC314B00 mov eax,[$004b31dc] 004AC52E 66BA3600 mov dx,$0036 004AC532 E835ADF5FF call @Write0WChar 004AC537 E8F088F5FF call @WriteLn 004AC53C E86F7EF5FF call @_IOTest 004AC541 EB32 jmp $004ac575 Project5.dpr.29: Writeln('7'); 004AC543 A1DC314B00 mov eax,[$004b31dc] 004AC548 66BA3700 mov dx,$0037 004AC54C E81BADF5FF call @Write0WChar 004AC551 E8D688F5FF call @WriteLn 004AC556 E8557EF5FF call @_IOTest 004AC55B EB18 jmp $004ac575 Project5.dpr.31: Writeln('0'); 004AC55D A1DC314B00 mov eax,[$004b31dc] 004AC562 66BA3000 mov dx,$0030 004AC566 E801ADF5FF call @Write0WChar 004AC56B E8BC88F5FF call @WriteLn 004AC570 E83B7EF5FF call @_IOTest 在这里我们看到了一个Delphi的优化,它首先把I和7比,如果大于就直接跳到else语句那里. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论