输出换行


MyRecord struct
name db 16 dup ('$')
phone db 16 dup ('$')
MyRecord ends
;
data segment
TheRecord MyRecord <>
string db 16 dup('$')
TipMsg db 'Please input your name:$'
TipMsg2 db 'Please input your phone:$'
ErrMsg db 'The Number should not be char!Please input phone again.$'
data ends
;
MYCODE segment
assume cs:MYCODE, ds:data
START:
mov ax , data
mov ds , ax

mov dx, offset TipMsg
call SHOWMSG
call NEWLINE
lea dx , TheRecord ;获取字符串首地址
mov byte ptr [TheRecord+0], 0dh ;设置读取字符串大小
mov ah , 0ah
int 21h ;读取字符串

GETPHONE:
mov dx, offset TipMsg2
call SHOWMSG
call NEWLINE
lea dx, TheRecord +16
mov byte ptr [TheRecord+16], 0dh
mov ah, 0ah
int 21h
;类型检查
mov cx, 0ch
CHECK:
mov si, offset TheRecord
add si, 18
lodsb
cmp al, '0'
jb ERR
cmp al, '9'
ja ERR
loop CHECK

OVER: ;注意,不可使用关键字
mov ax, 4c00h
int 21h
;
ERR:
mov dx, offset ErrMsg
call SHOWMSG
call NEWLINE
jmp GETPHONE
SHOWMSG PROC
mov ah, 9h
int 21h
ret
SHOWMSG ENDP
NEWLINE PROC
mov dl,0dh
mov ah,2h
int 21h
mov dl,0ah
mov ah,2h
int 21h
ret
NEWLINE ENDP
MYCODE ends
end START
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值