Reading Sectors with BIOS

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.
Goober

Re:Reading Sectors with BIOS

Post by Goober »

Thanks man, I can't believe I didn't see that data segment problem!

I assumed that the kernel wouldn't error because it's so simple.

Code: Select all

ORG 0x1000
use16

; Print welcome message
mov si,msg4
call print
call br
; Finish up
jmp $
Plus the appropriate print, br and msg4 calls.
AR

Re:Reading Sectors with BIOS

Post by AR »

The problem with the segments is there again.

CS=0x1000 IP=0 DS=0x1000 and your ORG=0x1000, so when you try to access the strings and code the assembler assumes 0x0:0x1000 + Offset so what you end up with is 0x1000:0x1000 + Offset, change ORG to 0.
Goober

Re:Reading Sectors with BIOS

Post by Goober »

Thanks for pointing that out.

However, no cigar ??? . It still crashes before printing the kernel's message.
AR

Re:Reading Sectors with BIOS

Post by AR »

Try putting cli hlt at the start, also you may want to set the segments manually as well, it is better to not rely on the bootloader to set your segments for you in realmode.

If it actually executes CLI HLT then it is probably a problem with the parts of the program that you didn't include.
Goober

Re:Reading Sectors with BIOS

Post by Goober »

What a frustrating problem. There's no code I didn't post.

How can I tell if it executed cli hlt at the start of the kernel? Wouldn't it just hang like it does now?
AR

Re:Reading Sectors with BIOS

Post by AR »

Where's "print" and "br" in the kernel?
Try:

Code: Select all

mov ax, 0xb800
mov gs, ax
mov byte [gs:0], 0x21
cli
hlt
You're using the wrong cylinder, you're setting the cylinder to 0x1 (CH) which is the second one. Both Cylinders and Heads are base 0, Sectors are base 1.
Goober

Re:Reading Sectors with BIOS

Post by Goober »

YOU DUNNIT AGAIN AR!

ch was supposed to be 0. I'm proud to present the working output:
Booting from Floppy...
[Boot] Setting up system stack...
[Boot] Reading kernel from disk...
[Boot] Jumping to kernel...
[Kernel] Started...
Thanks again!
Post Reply