Search code examples
assemblynasmx86-16bochs

Assembly - Printing a char on graphical mode


I'm trying to print a character while on graphical mode. Usually when I print a character I'm doing:


mov ah,14   ; ah=14
mov al,'x' 
int 10h     ; print the character

This time it doesn't work. I guess that the problem is that I switch to graphical mode:


push ax
mov ah, 0
mov al, 13h
int 10h
pop ax
ret

So how can i still use graphical mode (i need it) and print a char? I'm using nasm compiler, bochs debugger, and 8086 platform.

Thanks alot!


Solution

  • Always have Ralf Brown Interrupt List handy.

    The service int 10h/AH=0Eh requires the page number in BH and the color to use in BL.

    This snippet works

    mov ah, 0eh           ;0eh = 14
    mov al, 'x'
    xor bx, bx            ;Page number zero
    mov bl, 0ch           ;Color is red
    int 10h
    

    In text mode the BL is not used, however in graphical mode it is.
    Not properly setting it may end up writing "black on black".