彙編跳轉指令
跳轉指令分三類:
一、無條件跳轉: JMP;
二、根據 CX、ECX 暫存器的值跳轉: JCXZ(CX 為 0 則跳轉)、JECXZ(ECX 為 0 則跳轉);
三、根據 EFLAGS 暫存器的標誌位跳轉, 這個太多了.
根據標誌位跳轉的指令:
JE ;等於則跳轉 JNE ;不等於則跳轉JZ ;為 0 則跳轉
JNZ ;不為 0 則跳轉JS ;為負則跳轉
JNS ;不為負則跳轉JC ;進位則跳轉
JNC ;不進位則跳轉JO ;溢位則跳轉
JNO ;不溢位則跳轉JA ;無符號大於則跳轉
JNA ;無符號不大於則跳轉
JAE ;無符號大於等於則跳轉
JNAE ;無符號不大於等於則跳轉JG ;有符號大於則跳轉
JNG ;有符號不大於則跳轉
JGE ;有符號大於等於則跳轉
JNGE ;有符號不大於等於則跳轉JB ;無符號小於則跳轉
JNB ;無符號不小於則跳轉
JBE ;無符號小於等於則跳轉
JNBE ;無符號不小於等於則跳轉JL ;有符號小於則跳轉
JNL ;有符號不小於則跳轉
JLE ;有符號小於等於則跳轉
JNLE ;有符號不小於等於則跳轉JP ;奇偶位置位則跳轉
JNP ;奇偶位清除則跳轉
JPE ;奇偶位相等則跳轉
JPO ;奇偶位不等則跳轉
跳轉相關的標誌位:
11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|---|---|---|
OF | DF | IF | TF | SF | ZF | AF | PF | CF | |||
溢 出 | 符 號 | 零 | 未 用 | 輔 助 | 未 用 | 奇 偶 | 未 用 | 進 位 |
JMP 測試
; Test28_1.asm; .386 .model flat, stdcallinclude windows.inc
include kernel32.inc
include masm32.inc
include debug.inc
includelib kernel32.lib
includelib masm32.lib
includelib debug.lib.code
main proc
PrintText '1'
jmp @F
PrintText '2'
PrintText '3'
@@: PrintText '4'
ret
main endp
end main
;測試結果應該是:
;1
;4
;以下都應該是這樣.
JE 測試
; Test28_2.asm; .386 .model flat, stdcallinclude windows.inc
include kernel32.inc
include masm32.inc
include debug.inc
includelib kernel32.lib
includelib masm32.lib
includelib debug.lib.code
main proc
PrintText '1'
mov eax, 123
cmp eax, 123
je @F
PrintText '2'
PrintText '3'
@@: PrintText '4'
ret
main endp
end main
JZ 測試
; Test28_3.asm; .386 .model flat, stdcallinclude windows.inc
include kernel32.inc
include masm32.inc
include debug.inc
includelib kernel32.lib
includelib masm32.lib
includelib debug.lib.code
main proc
PrintText '1'
xor eax, eax
jz @F
PrintText '2'
PrintText '3'
@@: PrintText '4'
ret
main endp
end main
JS 測試
; Test28_4.asm; .386 .model flat, stdcallinclude windows.inc
include kernel32.inc
include masm32.inc
include debug.inc
includelib kernel32.lib
includelib masm32.lib
includelib debug.lib.code
main proc
PrintText '1'
xor eax, eax
dec eax
js @F
PrintText '2'
PrintText '3'
@@: PrintText '4'
ret
main endp
end main
JC 測試
; Test28_5.asm; .386 .model flat, stdcallinclude windows.inc
include kernel32.inc
include masm32.inc
include debug.inc
includelib kernel32.lib
includelib masm32.lib
includelib debug.lib.code
main proc
PrintText '1'
mov al, 0FFh
add al, 1
jc @F
PrintText '2'
PrintText '3'
@@: PrintText '4'
ret
main endp
end main
JO 測試
; Test28_6.asm; .386 .model flat, stdcallinclude windows.inc
include kernel32.inc
include masm32.inc
include debug.inc
includelib kernel32.lib
includelib masm32.lib
includelib debug.lib.code
main proc
PrintText '1'
mov al, -128
sub al, 1
jo @F
PrintText '2'
PrintText '3'
@@: PrintText '4'
ret
main endp
end main
JA 測試
; Test28_7.asm; .386 .model flat, stdcallinclude windows.inc
include kernel32.inc
include masm32.inc
include debug.inc
includelib kernel32.lib
includelib masm32.lib
includelib debug.lib.code
main proc
PrintText '1'
mov eax, 22
cmp eax, 11
ja @F
PrintText '2'
PrintText '3'
@@: PrintText '4'
ret
main endp
end main
JG 測試
; Test28_8.asm; .386 .model flat, stdcallinclude windows.inc
include kernel32.inc
include masm32.inc
include debug.inc
includelib kernel32.lib
includelib masm32.lib
includelib debug.lib.code
main proc
PrintText '1'
mov eax, 1
cmp eax, -1
jg @F
PrintText '2'
PrintText '3'
@@: PrintText '4'
ret
main endp
end main
JP 測試
; Test28_9.asm; .386 .model flat, stdcallinclude windows.inc
include kernel32.inc
include masm32.inc
include debug.inc
includelib kernel32.lib
includelib masm32.lib
includelib debug.lib.code
main proc
PrintText '1'
mov al, 00001110b
inc al
jp @F
PrintText '2'
PrintText '3'
@@: PrintText '4'
ret
main endp
end main
JECXZ 測試
; Test28_10.asm; .386 .model flat, stdcallinclude windows.inc
include kernel32.inc
include masm32.inc
include debug.inc
includelib kernel32.lib
includelib masm32.lib
includelib debug.lib.code
main proc
PrintText '1'
xor ecx, ecx
jecxz @F
PrintText '2'
PrintText '3'
@@: PrintText '4'
ret
main endp
end main