How to print with color using 0xb800 in Assembly? (VGA)
Posted: Wed Aug 09, 2017 7:45 am
Hello.
I've made a simple kernel (or second sector booted by INT 13h if preferred) that prints Hello World! on the screen. I want to add color to every character that prints. I am using the 0xb800 VGA address.
By the way, when I print 13 (0x0D or carriage return), 10 (0x0A or line feed) to make a new line, it only shows characters. It doesn't actually do a new line. Why is this? I just see a music symbol (that's supposed to be 0x0E) and a triangle, not a new line.
Any help is appreciated.
Thanks
Steve.
I've made a simple kernel (or second sector booted by INT 13h if preferred) that prints Hello World! on the screen. I want to add color to every character that prints. I am using the 0xb800 VGA address.
Code: Select all
BITS 16
org 0x7c00
jmp Main
Main:
mov dx, 0xb800
mov es, dx
mov si, msg
mov cx, 0
Print:
lodsb
cmp al, 0
je Done
mov di, cx
mov byte [es:di], 0x1f ; color that is expected to work.
mov byte [es:di], al ; this prints the actual character
inc cx
inc cx
jmp Print
Done:
ret
msg db 'Hello World!', 90, 0 ; I put in NOP operand because of a little problem... ignore this
Any help is appreciated.
Thanks
Steve.