tags:

views:

40

answers:

1

I've decided to write my own bootloader.

I've been able to set the video mode to 3 (although qemu already sets it to 3 already), and then print 'A' at the first character of the first line on the screen by directly changing video memory.

[org 0x7C00] ;Address BIOS loads the bootloader into
[bits 16]

;Set video mode to mode 3
mov al, 0x03
mov ah, 0x00
int 0x10

mov ax, 0xB800
mov es, ax
mov bx, 0
mov [es:bx], byte 65
mov [es:bx+1], byte 0x0F

;cli

JMP $       ;Infinite loop, hang it here.

times 510 - ($ - $$) db 0   ;Fill the rest of sector with 0
dw 0xAA55         ;Add boot signature at the end of bootloader

Note the commented out cli instruction. When I remove the semicolon and only the semicolon, the 'A' is no longer printed. I don't understand how clearing the IF flag can have the sideeffect of affecting what's in memory. If someone could shed some light on this that'd be great.

Oh and for what it's worth, the commands I use to run the bootloader

nasm -o bl.bin bl.asm
qemu -fda bl.bin

I got flamed somewhere else, and read up as much as I could. Someone mentioned setting up a stack, but I don't understand it's relevance to my issue.

Help is really appreciated!

A: 

Depend of video card hardware! Some video cards don't directly support all video modes but it only simulate. So via interrupts the internal part of code is responsible to copy this memory every few ms in to the graphic card memory. When you switch off the interrupts you will also switch off refreshing of internal video memory on graphic card. CLI instruction disables all software interrupts so only hardware instructions are present so BIOS will not work correct. You can use CLI instruction only for synchronisation of reading or writing to memory or IO ports. To be sure about my answer you can do a small pause for about 6ms before you execute CLI instruction and character will be shown.

GJ
Turns out it's an issue with qemu, which I was using.
alphomega
But turning off interrupts in emulated code isn't the same thing as REALLY turning of interrupts. The qemu software should be virtualizing this, and getting its interrupts just fine, so it can update the screen.
I. J. Kennedy
As I said before a few ms pause before CLI instruction will answer on this doubt.
GJ