程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> 學 Win32 匯編[28] - 跳轉指令: JMP、JECXZ、JA、JB、JG、JL、JE、JZ、JS、JC、JO、JP 等

學 Win32 匯編[28] - 跳轉指令: JMP、JECXZ、JA、JB、JG、JL、JE、JZ、JS、JC、JO、JP 等

編輯:Delphi

跳轉指令分三類:
一、無條件跳轉: 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, stdcall 
 
include  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, stdcall 
 
include  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, stdcall 
 
include  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, stdcall 
 
include  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, stdcall 
 
include  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, stdcall 
 
include  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, stdcall 
 
include  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, stdcall 
 
include  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, stdcall 
 
include  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, stdcall 
 
include  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 


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved