I'm kinda new to assembly and I want to know how to get a char ASCII code and print out that ASCII code. I'm using MASM (Dosbox).
MOV AX, 'A'  ; -> I want to print out the ASCII code of 'A'
Thanks for the answers!
I'm kinda new to assembly and I want to know how to get a char ASCII code and print out that ASCII code. I'm using MASM (Dosbox).
MOV AX, 'A'  ; -> I want to print out the ASCII code of 'A'
Thanks for the answers!
 
    
     
    
    From comments
MOV AX, 'A'MOV BX, 10DIV BLMOV AH, 2INT 21h
This byte-sized division will leave a quotient in AL and a remainder in AH.
But the DOS.PrintCharacter function 02h expects its input in the DL register.
After DIV:
ADD AH, 48ADD AL, 48
Fine to convert, but you can do it in one go with ADD AX, 3030h
I got this output: ##
Try next code:
mov ax, 'A'
mov bl, 10
div bl
add ax, 3030h
mov dx, ax      ; Moving tens "6" to DL for printing and preserving the units in DH
mov ah, 02h     ; DOS.PrintCharacter
int 21h
mov dl, dh      ; units "5"
mov ah, 02h     ; DOS.PrintCharacter
int 21h
Displaying numbers with DOS has a detailed explanation about how to deal with even bigger numbers.
