2010-02-23

2010-02-23 - Bootblock Development

Bootblock:
1)  Correct the origin issue.  My code has to run with an Origin of 0 so that I can relocate it to 0x7A00 with ease
2)  Set the DS register correctly, it is needed for accessing the memory.
3)  Remember that sector 0 is invalid
4)  Read to the end of the chain, not to the end of the file.  File size is irrelevant, truncation is futile, the sectors will be assimilated
5)  The teletype function is INT 0x10,AH=0x0E
6)  Add LBA-CHS conversion to the sector loader.  Means one register for sector numbers up to 65536 (32Mb disk)


Because I am loading the code at 7C00 then copying it to 7A00 out of the way, there is no meaningful value I can use for the Origin of the file except zero.  Anything else and I either need to add an offset to each jump and memory reference before the 7A00 switch, or to everything after it.

I have gotten the code to work now using an Origin of zero.  The code segment I was loading was a power of 16 out.  Never can remember that Segment:Address syntax.

If I use a single 16-bit register (in real mode) to represent my sector address on disk, that gives me only 65536 sectors which means a limit of a 32Mb disk with a common 512-byte sector size, or rather, that we can only read the first 32 Mb of the disk.

Given that the CHS translation of the BIOS allows us to read the first 8Gb, I'd like to extend the LBA mapping to use two 16-bit registers to store the value.

However, in order to then compute the CHS values from the LBA value, I need to perform "long division" and "long modulo" on the two registers separately and then combine the result.

So just trying to compute the algorithm now.

Hmm, upon further investigation, the DIV instruction actually works against a 32-bit register pair anyway, specifically DX:AX, and would allow me to address 2Tb of drive, not that FAT12 can effectively support a drive that big, nor that the BIOS CHS can actually address a drive that big.

Anyway, given that the INT 0x13 command requires specific values in specific registers, and that the 32-bit DIV instruction requires the use of other specific registers, I shall try to write a LBA-CHS conversion algorithm that takes advantage of these whilst being efficient.

No comments:

Post a Comment