编写一个汇编语言程序,要求从键盘上接收一个四位的十六位进制数,并在终端上显示与它等值的二进制数。
[此贴子已经被作者于2006-10-23 21:39:22编辑过]
data segment
a db 4 dup(0)
data ends
code segment
assume cs:code
start: mov ax,data
mov ds,ax
mov ax,0b800h ;显示的位置
mov es,ax
mov di,160*10+5*2
mov ah,2
mov bh,0 ;置光标位置
mov dh,12
mov dl,3
int 10h
mov si,offset a
mov cx,4 ;读键盘字符
s0: mov ah,1
int 21h
cmp al,'9'
ja next
sub al,30h
jmp short s1
next: sub al,37h
s1: mov [si],al
inc si
loop s0
mov si,offset a ;输出
mov cx,4
s2: push cx
mov al,[si]
mov bl,al
mov dl,3
mov cx,4
s3: push cx
mov al,bl
mov cl,dl
shr al,cl
and al,00000001b
add al,30h
mov es:[di],al
mov byte ptr es:[di+1],2
dec dl
add di,2
pop cx
loop s3
pop cx
inc si
loop s2
mov ax,4c00h
int 21h
code ends
end start
具体的细节你自己再补充吧!