Re: [Freedos-kernel] Boot sector LBA detection error
> of course you are right. but maybe you are missing the point ... > why the > original author (m2) wrote it exactly as it is: to save precious 2 bytes > in > the boot sector code This is a problem for the FAT12 "OEM" boot sector only, all other boot sectors can be assembled with this patch without problems. To allow the FAT12 "OEM" boot sector to use this patch, I'd suggest to move the LBA disk access packet into the sector (where the first jump currently jumps to) but only declare and initialize the first word (LBA_SIZE) there. The initial jump would be adjusted to pass control to the code following after this (2 bytes higher than now). This would save us the 6-byte instruction "mov LBA_SIZE, 10h" (really "mov word [bp+0200h], 0010h") below read_next i.e. it would save 4 bytes overall. The packet would, once used, overwrite 14 bytes of following code but this initial part is safe to overwrite then. (NASM preprocessor conditionals could be used to check that only the initial part is overwritten.) Regards, Christian -- Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev ___ Freedos-kernel mailing list Freedos-kernel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-kernel
Re: [Freedos-kernel] Boot sector LBA detection error
of course you are right. but maybe you are missing the point why the original author (m2) wrote it exactly as it is: to save precious 2 bytes in the boot sector code Tom am 6. Dezember 2009 um 00:32 schrieben Sie: > Hi, > the LBA detection of the FAT12/FAT16 boot sectors (both for the FreeDOS > and "OEM" kernels) could misdetect that a BIOS does support LBA if it > doesn't really. This is the used code (after calling Int13.41 for the boot > unit): >> shr cx, 1 >> ; CX must have 1 bit set >> sbb bx, 0aa55h - 1 >> ; tests for carry (from shr) too! >> jne read_normal_BIOS > This test succeeds if (cx&1) && (bx==AA55h) as intended but also succeeds > if (!(cx&1)) && (bx==AA54h). This is a highly unlikely case but > nonetheless an error which should be corrected. Example: >> sub bx, 0AA55h >> jne read_normal_BIOS >> shr cx, 1 >> jnc read_normal_BIOS > Note that the code after this expects bx to be zero, so sub must be used > here instead of cmp. I exchanged the order of the test for cx bit 0 (disk > access support) and the correct signature in bx since it's easier to > understand the code this way. (It would work the other way around as well.) > Regards, > Christian -- Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev ___ Freedos-kernel mailing list Freedos-kernel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-kernel