BCD to ASCII conversion

前端 未结 1 1954
时光说笑
时光说笑 2021-01-26 10:50

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
         


        
1条回答
  •  情歌与酒
    2021-01-26 11:28

    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

    0 讨论(0)
提交回复
热议问题