BCD到ASCII转换

时间:2016-05-04 10:21:47

标签: assembly x86-16

我知道BCD中的每4位都是十进制的一位数,但我有一个问题,例如当我想要打印存储在CH中的BCD值时,我这样做:

add ch, 30h

但是,当值为12时,它打印“C”,我想打印“12”。 如何对4位数据进行操作?

1 个答案:

答案 0 :(得分:-1)

mov al,ch      ; if ch has 12h
aam            ; ax will now be 0102h
or ax,3030h    ; converting into ascii - ax will now become 3132h
; you can now print the value in ax
mov cx,ax
mov dl,ch      ; to print on screen
mov ah,02h
int 21h
mov dl,cl
int 21h
ret

8086 AAM Instruction

8086 INT 21h function to print a character

相关问题