I find my VGA initialization code doesn't work properly on Bochs.
It works unexpectedly on Bochs(but doesn't crash it). On a real machine it just works the way I expect.
After hours of debugging and commenting I finally lock the point that goes wrong. I write a model for the "wrong" point as a boot sector program (see the code below), so that you can easily try it to see what it does to your Bochs.
Code: Select all
org 0x07C00
;general initilization
cli
mov ax,cs
mov ds,ax
mov fs,ax
mov gs,ax
sti
;clear the screen(I assume it's 80*25 text mode)
mov ax,0xb800
mov es,ax
xor di,di
xor al,al
mov cx,(2*80*25) ;go through Page 0
rep stosb ;char=NUL,foreground=0,background=0
;program the palette,RGB=(14,20,44)
mov dx,0x3c8
xor al,al ;index=0,which is the background color
out dx,al
mov dx,0x3c9
mov al,14
out dx,al
mov al,20
out dx,al
mov al,44
out dx,al
jmp $
times 510-($-$$) db 0
dw 0xaa55
I'm just wondering how it works on your Bochs. Would anyone bother trying this? Thanks in advance.