Delphi迴圈語句對應的彙編語句序列 轉

2021-08-31 15:01:57 字數 2246 閱讀 5951

count: 終值, start:起始值

正向:語句:for i:=0 to count do

彙編:mov eax, [count]

test eax, eax

jl ***

inc eax

[迴圈體]

dec eax

jnz [迴圈體]

***

語句:for i:=0 to count-1 do

彙編:mov eax, [count]

dec eax

test eax, eax

jl ***

inc eax

[迴圈體]

dec eax

jnz [迴圈體]

***

語句:for i:=1 to count do

彙編:mov eax, [count]

test eax, eax

jle ***

[迴圈體]

dec eax

jnz [迴圈體]

***

語句:for i:=1 to count-1 do

彙編:mov eax, [count]

dec eax

test eax, eax

jle ***

[迴圈體]

dec eax

jnz [迴圈體]

***

語句:for i:=start to count do

彙編:mov edx, [start]

mov eax, [count]

sub eax, edx

jl ***

inc eax

[迴圈體]

dec eax

jnz [迴圈體]

***

語句:for i:=start to count - 1 do

彙編:mov edx, [start]

mov eax, [count]

dec eax

sub eax, edx

jl ***

inc eax

[迴圈體]

dec eax

jnz [迴圈體]

***

逆向:語句:for i:=count downto 0 do

彙編:mov eax, [count]

cmp eax, 0

jl ***

[迴圈體]

dec eax

cmp eax, -1

jnz [迴圈體]

***

語句:for i:=count-1 downto 0 do

彙編:mov eax, [count]

dec eax

cmp eax, 0

jl ***

[迴圈體]

dec eax

cmp eax, -1

jnz [迴圈體]

***

語句:for i:=count downto 1 do

彙編:mov eax, [count]

cmp eax, 1

jl ***

[迴圈體]

dec eax

test eax, eax

jnz [迴圈體]

***

語句:for i:=count-1 downto 1 do

彙編:mov eax, [count]

dec eax

cmp eax, 1

jl ***

[迴圈體]

dec eax

test eax, eax

jnz [迴圈體]

***

語句:for i:=count downto start do

彙編:mov edx, [start]

mov eax, [count]

sub edx, eax

jg ***

dec edx

[迴圈體]

inc edx

jnz [迴圈體]

***

語句:for i:=count - 1 downto start do

彙編:mov edx, [start]

mov eax, [count]

dec eax

sub edx, eax

jg ***

dec edx

[迴圈體]

inc edx

jnz [迴圈體]

***

Delphi語法基礎 迴圈語句

一 for語句 格式 for 控制變數 初值 to 終值 do 語句 for 控制變數 初值 downto 終值 do 語句 for語句執行過程 1 先將初值賦給左邊的變數 稱為迴圈控制變數 2 判斷迴圈控制變數的值是否已 超過 終值,如已超過,則跳到步驟5 3 果末超過終值,則執行do後面的那個語...

彙編與C的基本邏輯語句對應關係

基本函式結構 push ebp mov ebp,esp sub esp,44h push ebx push esi push edi lea edi,ebp 44h mov ecx,11h mov eax,0cccccccch rep stos dword ptr edi xor eax,eax 若...

Delphi 迴圈的秘密

技術交流,dh講解.哈哈,我承認我是標題黨.最近看天書夜讀裡面是對c語言的 反彙編,不錯,可惜delphi沒有這樣的書,那我們自己動手吧.首先進入for迴圈了.function testfor a,b integer integer var i integer begin result a b fo...