回 帖 发 新 帖 刷新版面

主题:小程序   在线等

从键盘输入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

回复列表 (共1个回复)

沙发

data segment
input  db 13,10,'input string:',13,10,'$'
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
lea dx,input
mov ah,9
int 21h
mov dl,0
mov cx,7
begin:
mov ah,1
int 21h
.if al==30h
  clc
  rcl dl,1
.elseif al==31h
  stc
  rcl dl,1
.endif
loop begin
mov dh,dl
mov dl,10   ;换行显示
mov ah,2
int 21h
mov dl,dh  ;显示对应的字符
mov ah,2
int 21h
mov ah,4ch
int 21h
code ends
end start

;如果输入的是1000001,则输出的是A

我来回复

您尚未登录,请登录后再回复。点此登录或注册