Bona Fide OS Developer
View unanswered posts | View active topics It is currently Thu Mar 28, 2024 12:16 pm



Post new topic Reply to topic  [ 11 posts ]  Go to page Previous  1, 2
 loading sector and jmp 
Author Message

Joined: Sat Jul 25, 2009 11:26 am
Posts: 81
Post 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


Fri Oct 23, 2009 4:25 am
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ]  Go to page Previous  1, 2


Who is online

Users browsing this forum: No registered users and 22 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin and tweaked by the BF Team.