BCD to ASCII conversion

血红的双手。 提交于 2019-12-02 17:04:34

问题


I know that every 4 bit in BCD is one digit in decimal, but I have a problem, for example when I want to print a BCD value stored in CH I do this :

add ch, 30h

but, when the value is 12, it prints "C", I want to print "12". How can I do operations on 4 bit of data?


回答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



来源:https://stackoverflow.com/questions/37024912/bcd-to-ascii-conversion

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!