testing the cpu for 386 or better:VST_0201 wrote:Notice that most of this message assumes you are developing in a Windows environment, but is not solely dependent upon it.
Code: Select all
test386:
pushf ; save old flags
xor ah,ah ; clear/empty high byte of ax
push ax ; push the value of ax onto the stack..
popf ; and pop that into flags register
; (flags = push'd value of ax)
; now high nibble is empty (if it wasn't)..
; try to set ceratain bits ourselves..
; if we can't then it's < 386
pushf ; push flags on the stack..
pop ax ; and pop that into ax (so we can modify it)
and ah, 0f0h ; try to set the high nibble
cmp ah, 0f0h ; on a 386, the high nibble can't be 0f0h
jne short .done ; restore flags and return (it's >= 386)
popf ; restore original flags
pushf ; save original flags again
mov ah, 70h ; now try to set NT and IOPL
push ax
popf
pushf
pop ax
and ah, 70h ; if fails, no 386 is installed
jnz short .done ; restore flags and return (it's >= 386)
mov si,no386msg ; put message into ds:si for printmsg
call printmsg ; print the no386 msg
call $ ; halt the computer
.done:
popf ; restore flags
ret
Doing IDT/ISR/IRQ stuff: You are going to love this one: http://tools.assembla.com/svn/gustavo/osdev/tutorial/
Read up on booting: http://en.wikipedia.org/wiki/Booting
If you are having issues getting your loader to work, like you start out using a single stage and realize that you need more memory, so you attempt a stage 2 loader and cannot for the life of you get it to load your kernel, before you give up use grub instead:
ftp://alpha.gnu.org/gnu/grub/grub-0.94-i386-pc.tar.gz
Create a batch file (DOS) and write: copy \b stage1 + stage2 boot
Double-Click the batch file and use RawWrite to write the image to a floppy.
Check out this link for info on how to use GRUB: http://www.osdever.net/tutorials/grub.php
Then use BOCHS or MS Virtual PC to test it.
This should get you rolling on your OS. Hope it helps.

