主题:小程序 在线等
从键盘输入7位2进制数,显示出对应的字符,回车键退出循环,终止程序。
以下是我编写的,但不能达到题目要求,望哪位高人指点指点,谢谢
data segment
buffer db 7,?,'1111111',13,10,'$'
input db 13,10,'input string:$'
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
lea dx,input
mov ah,9
int 21h
lea dx,buffer
mov ah,10
int 21h
lea si,buffer+1
mov cl,buffer+1
mov ch,0
mov bx,0
compute:
inc si
mov bh,byte ptr [si]
sub bh,30h
jz other
mov ax,1
shl ax,cl
add bx,ax
loop compute
jmp L
other:
add bx,0
loop compute
L:
mov ah,10
int 21h
mov dl,bl
mov ah,2
int 21h
mov ah,1 ;若输入的不是回车,继续。
int 21h
cmp al,13
jnz compute
mov ah,4ch
int 21h
code ends
end start
以下是我编写的,但不能达到题目要求,望哪位高人指点指点,谢谢
data segment
buffer db 7,?,'1111111',13,10,'$'
input db 13,10,'input string:$'
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
lea dx,input
mov ah,9
int 21h
lea dx,buffer
mov ah,10
int 21h
lea si,buffer+1
mov cl,buffer+1
mov ch,0
mov bx,0
compute:
inc si
mov bh,byte ptr [si]
sub bh,30h
jz other
mov ax,1
shl ax,cl
add bx,ax
loop compute
jmp L
other:
add bx,0
loop compute
L:
mov ah,10
int 21h
mov dl,bl
mov ah,2
int 21h
mov ah,1 ;若输入的不是回车,继续。
int 21h
cmp al,13
jnz compute
mov ah,4ch
int 21h
code ends
end start