主题:[讨论]帮帮忙 跪求汇编程序
mini201
[专家分:0] 发布于 2006-11-19 20:18:00
编写一程序,要求从键盘接收一个4位的16进制数,
并在终端上显示与它等值的2进制数[em19]
minghongyun@post.usts.edu.cn
回复列表 (共4个回复)
沙发
mini201 [专家分:0] 发布于 2006-11-19 20:35:00
data segment
buf db 10
db?
db 10 dup(?)
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov dx,offset buf
mov ah,0ah
..................还请高手完成余下的
板凳
天空未蓝 [专家分:360] 发布于 2006-11-20 07:39:00
完成了有什么好处???呵呵[em9]
3 楼
天空未蓝 [专家分:360] 发布于 2006-11-20 07:51:00
data segment
buf db 4,?
ascstg db 10 dup(?)
integer dw 0
promt db 'Input hexadecimal(4):$'
dsperr db 0dh,0ah,'error!no hexadecimal!$'
data ends
code segment use16
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov dx,offset promt
mov ah,09h
int 21h
mov dx,offset buf
mov ah,oah
int 21h
mov cl,4
lea si,ascstg
mov al,[si]
cld
xor dx,dx
mov bl,0
mov ch,buf[1]
cmp ch,0
jz exit
cmp al,'+'
jnz next
inc si
dec ch
jmp conv
next: cmp al,'-'
jnz conv
inc si
dec ch
mov bl,0ffh
conv: cmp ch,0c
jz store
lodsb
cmp al,'0'
jb error
cmp al,'9'
ja next1
sub al,30h
jmp short rotate
next1: call a_to_f
jc error
rotate: shl dx,cl
or dl,al
dec ch
jmp short conv
store: cmp ,bl,0
jz lp
neg dx
lp: mov integer,dx
exit: mov dx,offset dsperr
mov ah,09h
int 21h
jmp exit
a_to_f proc
cmp al,'a'
jb nohex
cmp al,'f'
ja next2
sub al,37h
jmp hex
next2: cmp al,'a'
jb nohex
cmp al,'f'
ja nohex
sub al,547h
hex: clc
ret
nohex: stc
ret
a_to_f endp
code ends
end start
4 楼
mini201 [专家分:0] 发布于 2006-11-20 19:30:00
楼上的谢啦[em2]
我来回复