图 1 程序运行示意
stack segment stack
db 512 dup(?)
stack ends
data segment
msg1 db "enter the string : $"
msg2 db "string is not valid $"
msg3 db "stinrg is valid $"
str1 db 20 dup('$')
line db 10,13,'$'
data ends
dis macro str
mov ah,09h
lea dx,str
int 21h
endm
code segment
assume ds:data, cs:code, ss: stack
start:
mov ax, stack
mov ss, ax
mov ax, data
mov ds, ax
dis msg1
mov ah, 0ah
lea dx, str1
int 21h
dis line
lea si, str1+2
mov al, '0'
cmp byte ptr[si],al
jl l2
mov al, '9'
cmp byte ptr[si],al
jg l2
dis msg2
jmp l1
l2:
dis msg3
l1:
mov ah, 4ch
int 21h
code ends
end start