Got stuck with your boot sector? can't guess where your pmode switcher hangs ? here's a trick of mine: play with VGA registers (especially palettes) for debuggin purpose.
One of my favourite applications of this is to switch background color to blue within interruptions and restore it to black after the interruption is done. This will give you hints of what is happening if you run your program on real hardware.
%macro premarker 0
save ax,dx
mov dx,0x03c0
mov al,0x31
out dx,al
inc dx
in al,dx
dec dx
restore ax,dx
%endmacro
%macro marker 1
save eax,edx
mov dx,0x03c0
mov al,0x31 ; overscan color, normal crt
out dx,al
mov al,%1 ; send colour value
out dx,al
restore eax,edx
%endmacro
these few line will play with the "overscan color" of your screen and make it change its colour (red border -> something is going bad). By placing some of them at interresting points, you'll be able to track the execution of your code easier than by writing to 0xb800 (for instance when you don't want to touch any segment registers because you can't assume the GDT is valid, etc.)
the save and restore macros are simply repeated push/pops but they are conditionnal (so that you can choose not to use the stack but trashing 2 registers).
See the full toolkit at http://cvs.sourceforge.net/cgi-bin/view ... /debug.ash and http://cvs.sourceforge.net/cgi-bin/view ... nhance.ash
Premarker is going to help you synchronizing with the CRT, but it might be needed once or twice according to the kind of VGA hardware you own ... i still have to clean this (when bugging, the whole screen becomes light blue).
rookie steps #2: a trick for low-level debugging.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact: