Bona Fide OS Development
http://forums.osdever.net/

loading sector and jmp
http://forums.osdever.net/viewtopic.php?f=4&t=55
Page 2 of 2

Author:  Love4Boobies [ Fri Oct 23, 2009 4:25 am ]
Post subject:  Re: loading sector and jmp

Well there are a few extra lines there (e.g., the call that changes the value of DL) ;) And I did assume you already made the correction regarding CHS (check the code I quoted, CHS is 0/0/2).

My point was that you don't need to disable interrupts (i.e., you don't need the CLI) since they can't screw up anything. If you're worried about racial conditions, i.e.:

Code:
mov ss, ...
; IRQ COMES ALONG AND CS:IP IS PUSHED TO A BOGUS STACK
mov sp, ...


then don't. Even with interrupts enabled, "mov ss, ..." and any instruction that follows are executed atomically to prevent this. Since your next instruction sets the stack pointer everything's fine.

Not that it would matter much but you could've pushed DX onto the stack instead (since you can't push r8). Your solution is just as good but it takes up more bytes everytime you load/store. Pushing and popping take 1 byte each. You might think a few bytes won't hurt but MBRs get really crowded once you want to support hybrid MBRs for both legacy and GPT partitions (and if you're really picky you'll test whether the CPU is 32-bit since otherwise the code will break on an 8086), both the legacy INT 13h and EDD interfaces for reading, fault tolerance and error reporting.

The BBS defines the entry point at 0000:7C00h not 07C0:0000 which indeed resolve to the same physical address. If you use the wrong address you will have to be careful not to use any non-relative jumps. Unfortunately the 07C0h thing has spread because people noticed some BIOSes using that address - i.e., some buggy BIOSes. Yes, us OS deveopers need to cope with firmware as well as hardware problems. Just wait till you stumble upon crappy MP tables, or even worse, ACPI tables.

Does your code work? I only bothered reading the first few lines this time cause I wasn't sure...

Cheers,
Bogdan

Page 2 of 2 All times are UTC - 6 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/