仅取0-10的数字,并在Q上终止


        .MODEL medium
        .STACK          ; Stack default size 1024 bytes
        .DATA           ; Data segment (for variables)
        .CODE           ; Run-able code goes in code segment
        .STARTUP        ; Handover code from OS call to typer.exe
nextc:  mov ah,8        ; Call int21 with ah=8 returns with
        int 021h        ; al equal to the ASCII character pressed
        mov dl,al       ; dl is assigned value in al, dl=al
        mov ah,02h      ; Call int21 with ah=2 prints ASCII
        int 021h

        cmp dl,'q'      ; compare dl with ASCII ‘q’=
        jz qt           ; if key pressed was not a ‘q’ go back
        cmp dl,'/'
        jnc skp 
        cmp dl,'9'      ;;compair 9 to q. if there is a carry 9<q  
        jc skp
skp:        
        jmp nextc
qt:
        .EXIT           ; Terminate and return control to OS
        END             ; End of file (for compiler) 

只需使用jl(如果少于)和jg(如果大于大于)指令。

cmp dl,'0'     ;compare to 0
jl skp         ; if less then skip
cmp dl,'9'     ;compare to 9
jg skp         ;if greater than skip
success:       ;yes we;ve found a digit.
.....
skp:           ;no digit.          
.....

这是所有有条件跳跃的列表:http://x86.renejeschke.de/html/file_module_x86_id_146.html

相关内容

最新更新