Here is a lea that can be replaced by a mov to save a byte:
|
lea di, [bp + PARTTBL_OFFSET] ; start of partition table |
You don't check for multiple partitions marked as active (lDOS oldmbr does):
|
; We found an active partition. Load its boot sector to 0:7c00, |
If you address the relocated loader with segment zero then you only need one far jump (to relocate) and the jump to the next loader could be near instead:
|
jmp word 0x0:0x7c00 ; jump to volume boot code |
The print function is only ever called to halt the machine so you could put the halting into this function rather than returning to after the ASCIZ message string:
|
call print |
|
db 'no active partition found', 0 |
|
jmp $ |
The LBA packet could be aligned, at least on a word boundary (align 2 before the label):
|
;----------------------------------------------------------------------------- |
|
; BIOS disk access packet used by ext. INT13 LBA read function |
|
|
|
dap: |
|
.packet_size db 0x10 |
(The alignment is "free" if you move the packet to before the partition table as the table location must be aligned on a word boundary. lDOS MBR does not do this yet but it will.)
The word "shoud" is a misspelling:
|
mov bx, 0x55aa ; magic value shoud be changed after call |
shr cx, 1 \ jnc ... is a byte shorter than using test because test needs an immediate byte:
|
test cl, 1 ; no support if LBA flag not set |
The trail stc \ int 13h \ retn here can be shared with the CHS path, saving two bytes:
Function 42h doesn't use al so there is no need to init it to zero:
|
mov ax, 0x4200 ; LBA read function |
You're depending on the CHS tuple from the partition table entry if using CHS access (lDOS MBRs calculate CHS address from the LBA start using the geometry queried from function 08h):
I don't really see a reason why not to relocate to 600h like is standard for MBR loaders. If you combine this with my earlier cs = ds = es = 0 suggestion the relocation even may save a byte or two.
Over here you assume that there is enough space for the partition table. I think you should cause a build error if there would be overlap:
|
; zero-fill rest of sector and put signature into place |
|
times 0x1fe - $ + $$ db 0 |
|
db 0x55, 0xaa |
Finally, the reason I wanted to write this was I want the MBR to pass ds:si -> partition table entry being booted. This is what lDOS MBR do and also lDOS boot attempts to detect unless patched out eg using the build option or instsect /P none (in the instsect help).
Here is a
leathat can be replaced by amovto save a byte:fdisk/source/fdisk/bootnorm.asm
Line 54 in f52198a
You don't check for multiple partitions marked as active (lDOS oldmbr does):
fdisk/source/fdisk/bootnorm.asm
Line 65 in f52198a
If you address the relocated loader with segment zero then you only need one far jump (to relocate) and the jump to the next loader could be near instead:
fdisk/source/fdisk/bootnorm.asm
Line 73 in f52198a
The print function is only ever called to halt the machine so you could put the halting into this function rather than returning to after the ASCIZ message string:
fdisk/source/fdisk/bootnorm.asm
Lines 61 to 63 in f52198a
The LBA packet could be aligned, at least on a word boundary (
align 2before the label):fdisk/source/fdisk/bootnorm.asm
Lines 85 to 89 in f52198a
The word "shoud" is a misspelling:
fdisk/source/fdisk/bootnorm.asm
Line 111 in f52198a
shr cx, 1\jnc ...is a byte shorter than usingtestbecausetestneeds an immediate byte:fdisk/source/fdisk/bootnorm.asm
Line 119 in f52198a
The trail
stc\int 13h\retnhere can be shared with the CHS path, saving two bytes:fdisk/source/fdisk/bootnorm.asm
Lines 128 to 130 in f52198a
Function 42h doesn't use
also there is no need to init it to zero:fdisk/source/fdisk/bootnorm.asm
Line 126 in f52198a
You're depending on the CHS tuple from the partition table entry if using CHS access (lDOS MBRs calculate CHS address from the LBA start using the geometry queried from function 08h):
fdisk/source/fdisk/bootnorm.asm
Line 134 in f52198a
I don't really see a reason why not to relocate to 600h like is standard for MBR loaders. If you combine this with my earlier
cs=ds=es= 0 suggestion the relocation even may save a byte or two.Over here you assume that there is enough space for the partition table. I think you should cause a build error if there would be overlap:
fdisk/source/fdisk/bootnorm.asm
Lines 156 to 158 in f52198a
Finally, the reason I wanted to write this was I want the MBR to pass
ds:si-> partition table entry being booted. This is what lDOS MBR do and also lDOS boot attempts to detect unless patched out eg using the build option orinstsect /P none(in the instsect help).