汇编语言 从键盘输一字符串,存入BUFIN为首地址的内存区(长20H)中,从此内存中调用,在屏幕显示该字符串
务请您按照此流程编写,谢谢谢!!:显示提示‘Doyouwangttoinputstring?(Y/N)’--->等待键盘输入Y/N如果N则退出--->如果Y,则存储字符串...
务请您按照此流程编写,谢谢谢!!:显示提示‘Do you wangt to input string?(Y/N)’ ---> 等待键盘输入Y/N 如果N则退出--->如果Y,则存储字符串至BUFIN,计算字符串长度,并将结尾加$--->然后从内存BUFIN调出并显示字符串.结束退出
完全符合要求再加50-100分!谢谢!完成务请您发至邮箱766451099@qq.com 展开
完全符合要求再加50-100分!谢谢!完成务请您发至邮箱766451099@qq.com 展开
2个回答
展开全部
dosseg
.model small
.stack
.data
msg db 13,'Do you want to input string? (Y/N) '
bksp db 8,32,8,36
crlf db 13,10,36
msg1 db 13,10,'The string you have entered : $'
bufin db 20h dup (?)
msg2 db 13,10,'String length in byte(s) : $'
.code
.startup
@@: mov dx,offset msg ;'Do you want to input string?'
call puts
call getchar
and al,not 20h ;to_uppercase
cmp al,'N'
je quit
cmp al,'Y'
je @f
mov dx,offset bksp ;erase invalid key echo on screen
call puts
jmp @b
@@: mov dx,offset crlf ;enter string at a new line
call puts
push ds
pop es
mov di,offset bufin
xor cx,cx
cld
getk: call getchar
cmp al,13 ;ENTER?
je done
cmp al,8 ;BKSP?
jnz @f
jcxz getk ;ignore BKSP is buffer is empty
dec cx
dec di
mov dx,offset bksp+1 ;erase previous char, we dont need the 1st bksp coz we've got one from the key echo
call puts
jmp getk
@@: cmp cx,length bufin-1 ;it has reached buffer tail?
jae @f
stosb
inc cx
jmp getk
@@: mov dx,offset bksp ;remove the key echo
call puts
jmp getk
done: mov al,'$' ;
stosb
mov dx,offset msg1 ;'The string you have entered '
call puts
mov dx,offset bufin ;the string just entered
call puts
mov dx,offset msg2 ;'String length in byte(s)'
call puts
mov ax,cx ;CX=string length
call printax
quit: mov ah,4ch
int 21h
;以10进制输出ax中的无符号整数
printax proc
mov bx,10 ;按10进制输出
or ax,ax ;是0则直接输出
jnz @f
mov dl,'0'
call putc
ret
@@: xor dx,dx
div bx
mov cx,ax
or cx,dx ;若商与余数都为0则结束递归
jz @f
push dx ;留存DX中的余数以在递归后输出
call @b ;递归
pop dx ;从最高位开始恢复余数
add dl,'0'
call putc
@@: ret
printax endp
puts proc
mov ah,9
int 21h
ret
puts endp
putc proc
mov ah,2
int 21h
ret
putc endp
getchar proc
mov ah,1
int 21h
ret
getchar endp
end
.model small
.stack
.data
msg db 13,'Do you want to input string? (Y/N) '
bksp db 8,32,8,36
crlf db 13,10,36
msg1 db 13,10,'The string you have entered : $'
bufin db 20h dup (?)
msg2 db 13,10,'String length in byte(s) : $'
.code
.startup
@@: mov dx,offset msg ;'Do you want to input string?'
call puts
call getchar
and al,not 20h ;to_uppercase
cmp al,'N'
je quit
cmp al,'Y'
je @f
mov dx,offset bksp ;erase invalid key echo on screen
call puts
jmp @b
@@: mov dx,offset crlf ;enter string at a new line
call puts
push ds
pop es
mov di,offset bufin
xor cx,cx
cld
getk: call getchar
cmp al,13 ;ENTER?
je done
cmp al,8 ;BKSP?
jnz @f
jcxz getk ;ignore BKSP is buffer is empty
dec cx
dec di
mov dx,offset bksp+1 ;erase previous char, we dont need the 1st bksp coz we've got one from the key echo
call puts
jmp getk
@@: cmp cx,length bufin-1 ;it has reached buffer tail?
jae @f
stosb
inc cx
jmp getk
@@: mov dx,offset bksp ;remove the key echo
call puts
jmp getk
done: mov al,'$' ;
stosb
mov dx,offset msg1 ;'The string you have entered '
call puts
mov dx,offset bufin ;the string just entered
call puts
mov dx,offset msg2 ;'String length in byte(s)'
call puts
mov ax,cx ;CX=string length
call printax
quit: mov ah,4ch
int 21h
;以10进制输出ax中的无符号整数
printax proc
mov bx,10 ;按10进制输出
or ax,ax ;是0则直接输出
jnz @f
mov dl,'0'
call putc
ret
@@: xor dx,dx
div bx
mov cx,ax
or cx,dx ;若商与余数都为0则结束递归
jz @f
push dx ;留存DX中的余数以在递归后输出
call @b ;递归
pop dx ;从最高位开始恢复余数
add dl,'0'
call putc
@@: ret
printax endp
puts proc
mov ah,9
int 21h
ret
puts endp
putc proc
mov ah,2
int 21h
ret
putc endp
getchar proc
mov ah,1
int 21h
ret
getchar endp
end
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
已发送至你邮箱,请查收
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询