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 ;初始化ds lea dx,string1 ;取string1的偏移地址,放入dx mov ah,09h int 21h ;从键盘输入字符串 mov ah,01h int 21h ;从键盘输入字符串 cmp al,30h ;和‘0’相比较 jnc GOON ;无进位转移到goon lea dx,string3 ;取string3的偏移地址,放入dx jmp EXIT ;跳转到exit GOON: cmp al,3ah ;与‘:’相比较 jnc DONE ;无进位转移到done lea dx,string2 ;取string2的偏移地址,放入dx jmp EXIT DONE: lea dx,string3 ;取string3的偏移地址,放入dx jmp EXIT EXIT: mov ah,09h int 21h ;从键盘输入字符串 mov ah,4ch int 21h ;从键盘输入字符串 code ends end start
原文地址:http://blog.csdn.net/xuejiawei123/article/details/25339911