Reputation: 6547
I am trying to make my own boot-loader. As I will not have any interrupts when I change from 16bit to 32 bit mode, I will not be able to use int 10h
.
Here is the code I have so far:
org 0x7c00 ; add to offsets
xor ax, ax ; make it zero
mov ds, ax ; ds=0
mov ss, ax ; stack starts at 0
cld
mov ax, 0xb800 ; Ax = address of video memory
mov es, ax
xor di, di
call print ; call thr print function
hang:
jmp hang ; constanly loop
print:
mov si, msg ; load msg into si
mov cx, 4
mov ah, 07h
printchar:
lodsb ; Hear we load a letter from si
stosw
loop printchar ; if not end of msg, go back to printchar
ret ; return
msg db 'test' ; msg = 'test'
times 510-($-$$) db 0 ; make sure file is 510 bytes in size
dw 0xaa55 ; write boot signiture
And compiled with nasm:
nasm -f bin bootloader.asm -o myos.hdd
I have put comments in the lines I understand. What I don't understand is the usage of the video memory. Could someone explain this to me and show me where to find the documentation?
I have searched the internet but cannot find the documentation.
Upvotes: 1
Views: 147
Reputation: 6547
I think I get it now.
mov cx, 4
is the length of the message. "test" is four bytes long.
mov ah, 07h
is setting the colour data. 0 = black, 7 = light grey.
First number is the background colour, second number is the text colour.
This means that the character to be printed will be light grey on a black background.
Thank you to everyone who helped.
Upvotes: 2