如何将压缩BCD码转换成ASCII码

如何将压缩BCD码转换成ASCII码?
2024-12-17 08:38:38
推荐回答(1个)
回答1:

Code Segment
Assume CS:Code,DS:Code
BCD_Number db 45h,32h,56h,98h
dw 6 dup(?)
Start: push cs
pop ds
push cs
pop es ;使数据段、附加段与代码段同段
cld
lea si,BCD_Number
lea di,BCD_Number[8]
mov cx,2
rep movsw ;把这4个字节的压缩BCD码保存到与其相距8个字节的后续单元
lea si,BCD_Number[8]
lea di,BCD_Number
mov cx,4
BCD_ASCII: lodsb
push cx
mov cx,4
xor ah,ah
shl ax,cl
shr al,cl
or ax,3030h
xchg ah,al
stosw
pop cx
loop BCD_ASCII
Exit_Proc: mov ah,4ch ;结束程序
int 21h

Code ENDS
END Start