Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
You don't set up a stack, init your segment registers (before or after the jump to PMode), align the GDT, or ensure that the BIOS didn't start at 0x07C0:0x000 or 0x0:0x7C00 or any other variation.
I'd also imagine you may have some GDT descriptor issues as well.
Also, next time (or even this time), include a bit more information as it makes it a lot easier for us to help. Do you use BOCHS or any other emulator/virtualization with debugging features? If so, where does it fault, what's in the registers, examine these things and you may find your answer.
Code seems to work fine when I converted it to Fasm (bochs & code2duo).
But I dont fully understand why. First 4 bits of 0x98 constant means its code section for execution. Try chaging it to 9A: code + execute + read
And dont forget to display something on the screen so like "mov word [0b8000h], 0404h" so youknow it does(not) work.
Edit: a bird just told me that Read is required when you keep static data such as constants in the code section and reference them. I guess it would count when you have 4GB data & code starting at the same address.
Last edited by geppyfx on Sat May 02, 2009 12:55 pm, edited 1 time in total.
And you should set up a stack using the same selector and a nice offset like 0x9000 or something.
EDIT: What assembler are you using? NASM?
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
It's probably the GDT. Try putting "align 4" before it.
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
Umm... How do you know that it doesn't work, if you don't get any output?
I compiled your code with NASM and tested it with bochs. For me, it works well.
At first I was confused because I don't saw any difference in bochs after running your code,
but then I recognized the infinite loop that you built in at the end of the code without printing anything on the screen.
Print something on the screen so you'll see that it should work.
I have compiled you last source with nasm and written it at the begining of the floppy (you can use usb stick). Works (along with the code in you first post). Image attached.
Show some proof that it doesn't work such as bochs debugging info.
This is the problem...in bochs it work but on my machine it dont...im thinking if it not the a20 line...its possible?
i put this output(mov [0xb8000], word 0x0404) before the loop and it didnt appear on the screen before the computer reset...
Any ideias?
Thanks,
Ângelo
Ah, I hate it if emulators don't act like my real pc, feels like doing something for nothing.
I think you test your code with a floppy, don't you?
Maybe your bios requires a table (forgot the special name for it ) like the following one:
jmp start
OSName db 'OS '
BytesPerSec dw 512
SecPerClus db 1
RsvdSecCnt dw 2
NumFATs db 2
RootEntCnt dw 224
TotSec dw 2880
MediaType db 0xF0
FATSize dw 9
SecPerTrack dw 18
NumHeads dw 2
HiddenSec dd 0
TotSec32 dd 0
DrvNum db 0x00
Reserved db 0
BootSig db 0x29
VolumeID dd 00000000h
VolumeLabel db 'NO NAME '
FileSysType db 'FAT12 '
Put it at the top of your bootstrap and look if anything has changed on your real pc.
I'm not sure whether (older?) bioses need this piece of code in a bootloader.
I don't think the A20 line is the cause of it because you never try to write something above the 1MB limit.