Win 32アセンブリ[28]-ジャンプ命令:JMP、JECXZ、JA、JB、JG、JL、JE、JZ、JS、JC、JJJ、JPなど…

5090 ワード

ジャンプ命令は三つの種類に分けられます.
一、無条件ジャンプ: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