-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MBR code comments #84
Comments
Thanks for the comments! This was the first iteration on trying to improve the old code. I will study your proposals to learn something from it :) To make it short: as most of your comments are already implemented in the lDOS MBR code, may I substitute the current bootnorm.asm with your code? |
Sure, just make sure to keep the license and attribution (from syslinux which is what I based them on). |
NB, I didn't add the Xi8088 BIOS workaround to lDOS MBR yet. Is the Book8088 drive MBR-partitioned? If so I should add it. It is not a problem for the size of the code. |
I am in the mood of doing some assembly, so I could not resist to apply most of your proposals to the bootnorm.asm :) 8539f43 Currently missing: multiple active detection and the LBA to CHS translation. The other stuff should be in. |
I am searching for a MASM label (the keyword) equivalent for NASM. I have a driveno variable I would like to place at offset 0 (0:0x600) without loosing type information. Do you know a way of doing this? Currently it wastes a byte. |
There is no type information in NASM, a label is merely a scalar value or relocatable address. You can place the label |
I reviewed your changes. I would suggest moving the LBA packet down before the padding (just align it) because, as hpa put it:
|
Of course, you can use the |
Played too much with JWasm in recent times to forget that NASM has basically no type info for labels (even no concept of variables). That absolute is new to me, but seems to be nearly what I was looking for (apart from the type info). I'll try that out. |
Regarding the multiple active partitions, did you encounter that anywhere? Converting the LBA values I guess is for the cases where multiple BIOSes may disagree over the CHS values? |
No.
Yes. In my MS-DOS fork I also deleted all uses of CHS values from the partition tables. When you can use LBA values there is no downside to doing so. |
Here is a
lea
that can be replaced by amov
to 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 2
before 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 usingtest
becausetest
needs an immediate byte:fdisk/source/fdisk/bootnorm.asm
Line 119 in f52198a
The trail
stc
\int 13h
\retn
here 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
al
so 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).The text was updated successfully, but these errors were encountered: