本文主要是介绍学 Win32 汇编[28] - 跳转指令: JMP、JECXZ、JA、JB、JG、JL、JE、JZ、JS、JC、JO、JP 等,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
跳转指令分三类:
一、无条件跳转: 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 procPrintText '1'jmp @FPrintText '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 procPrintText '1'mov eax, 123cmp eax, 123je @FPrintText '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 procPrintText '1'xor eax, eaxjz @FPrintText '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 procPrintText '1'xor eax, eaxdec eaxjs @FPrintText '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 procPrintText '1'mov al, 0FFhadd al, 1jc @FPrintText '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 procPrintText '1'mov al, -128sub al, 1jo @FPrintText '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 procPrintText '1'mov eax, 22cmp eax, 11ja @FPrintText '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 procPrintText '1'mov eax, 1cmp eax, -1jg @FPrintText '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 procPrintText '1'mov al, 00001110binc aljp @FPrintText '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 procPrintText '1'xor ecx, ecxjecxz @FPrintText '2'PrintText '3' @@: PrintText '4'ret main endp end main
这篇关于学 Win32 汇编[28] - 跳转指令: JMP、JECXZ、JA、JB、JG、JL、JE、JZ、JS、JC、JO、JP 等的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!