汇编语言 循环判断 输入是否为数字

时间:2014-04-29 13:33:20   收藏:0   阅读:559

源码:

data segment
    string1 db ‘Please input a number:‘,0dh,0ah,‘$‘
    string2 db 0dh,0ah,‘It is a number!‘,0dh,0ah,‘$‘
    string3 db 0dh,0ah,‘It is not a number!‘,0dh,0ah,‘$‘
data ends
code segment
    assume cs:code,ds:data
start:
    mov ax,data
    mov ds,ax
TIP:
    lea dx,string1
    mov ah,09h
    int 21h
    mov ah,01h
    int 21h
    cmp al,30h
    jnc GOON
    lea dx,string3
    mov ah,09h
    int 21h
    jmp TIP
GOON:
    cmp al,3ah
    jnc DONE
    lea dx,string2
    mov ah,09h
    int 21h
    jmp EXIT
DONE:
    lea dx,string3
    mov ah,09h
    int 21h
    jmp TIP
EXIT:
    mov ah,4ch
    int 21h
code ends
    end start

运行截图:

mamicode.com,码迷
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!