davidgiven / ack

The Amsterdam Compiler Kit
http://tack.sf.net
Other
421 stars 60 forks source link

Some fixes for msdos386 target platform #270

Closed tkchia closed 2 years ago

davidgiven commented 2 years ago

Wow, so much of my shitty code fixed... You can tell I'm not fluent in DPMI! Thanks!

davidgiven commented 2 years ago

Just noticed you marked this as draft. Let me know when you think it's ready to go.

tkchia commented 2 years ago

Thanks @davidgiven . I have tried to fix some of the issues I saw in the msdos386 runtime modules. But we probably need a way to test them more rigorously. I also hope to refactor the code a bit — especially the transfer buffer stuff — some time soon.

By the way, I am surprised that you fashioned the stub to have an MZ header of size zero — and surprised that this actually works (on an actual Microsoft DOS, no less). :slightly_smiling_face: :slightly_smiling_face:

Thank you!

davidgiven commented 2 years ago

It didn't occur to me that a zero size MZ header would be problematic --- I did it like that so that I could generate the exe header inside the stub assembly and have all the offsets match correctly. Plus, that was the only way to make the maths work, and even then I had to modify the assembler to allow arithmetic on pointer differences.

Anyway, merging. Thanks!

tkchia commented 2 years ago

Hello @davidgiven,

Thanks!

From what I see, the usual practice for the MZ header size, is to have it cover the fixed portion — i.e. up to the "overlay number" (0x1a0x1b) — plus the entire MZ relocation table.

Apparently some compiler toolchains go even further, and pad the MZ header with null bytes up to a multiple of 512 bytes.

Thank you!