Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Fat binary
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Combined COM-style binaries for CP/M-80 and DOS=== [[CP/M-80]], [[MP/M-80]], [[Concurrent CP/M]], [[CP/M Plus]], [[Personal CP/M-80]], [[SCP (operating system)|SCP]] and [[MSX-DOS]] executables for the [[Intel 8080]] (and [[Zilog]] [[Z80]]) processor families use the same [[.COM]] [[file extension]] as [[DOS]]-compatible operating systems for [[Intel 8086]] binaries.<ref group="nb" name="NB_CP/M-86"/> In both cases programs are loaded at offset +100h and executed by jumping to the first byte in the file.<ref name="Paul_2002_COM"/><ref name="Wilkinson_2005"/> As the [[opcode]]s of the two processor families are not compatible, attempting to start a program under the wrong operating system leads to incorrect and unpredictable behaviour. In order to avoid this, some methods have been devised to build fat binaries which contain both a CP/M-80 and a DOS program, preceded by initial code which is interpreted correctly on both platforms.<ref name="Wilkinson_2005"/> The methods either combine two fully functional programs each built for their corresponding environment, or add [[code stub|stub]]s which cause the program to [[exit gracefully]] if started on the wrong processor. For this to work, the first few instructions (sometimes also called ''[[#Gadget|gadget header]]s''<ref name="Cha-Pak-Brumley-Lipton_2010"/>) in the .COM file have to be valid code for both 8086 and 8080 processors, which would cause the processors to branch into different locations within the code.<ref name="Cha-Pak-Brumley-Lipton_2010"/> For example, the utilities in Simeon Cran's emulator MyZ80 start with the opcode sequence {{mono|EBh, 52h, EBh}}.<ref name="Wilkinson-Seligman-Drushel-Elliott-Harston_1999"/><ref name="Elliott_2009_PMARC"/> An 8086 sees this as a jump and reads its next instruction from offset +154h whereas an 8080 or compatible processor goes straight through and reads its next instruction from +103h. A similar sequence used for this purpose is {{mono|EBh, 03h, C3h}}.<ref name="Christ_2012"/><ref name="Brehm_2016"/> <!-- Using {{mono|EBh, 04h, EBh}} as start code, -->John C. Elliott's FATBIN<ref name="Elliott_1996_FATBIN"/><ref name="Elliott_1998_FATBIN"/><ref name="Elliott_2002_FBMAKE"/> is a utility to combine a CP/M-80 and a DOS .COM file into one executable.<ref name="Wilkinson-Seligman-Drushel-Elliott-Harston_1999"/><ref name="Elliott_2005_FATBIN-PMSFX"/> His derivative of the original [[PMsfx]] modifies archives created by Yoshihiko Mino's [[PMarc]] to be [[self-extractable archive|self-extractable]] under ''both'', CP/M-80 and DOS, starting with {{mono|EBh, 18h, 2Dh, 70h, 6Dh, 73h, 2Dh}} to also include the "-pms-" signature for self-extracting [[PMarc|PMA]] archives,<ref name="Elliott_1997_PMSFX2"/><ref name="Wilkinson-Seligman-Drushel-Elliott-Harston_1999"/><ref name="Elliott_2005_FATBIN-PMSFX"/><ref name="Elliott_2009_PMARC"/> thereby also representing a form of [[executable ASCII code]]. Another method to keep a DOS-compatible operating system from erroneously executing .COM programs for CP/M-80 and MSX-DOS machines<ref name="Wilkinson_2005"/> is to start the 8080 code with {{mono|C3h, 03h, 01h}}, which is decoded as a "RET" instruction by x86 processors, thereby gracefully exiting the program,<ref group="nb" name="NB_RET"/> while it will be decoded as "JP 103h" instruction by 8080 processors and simply jump to the next instruction in the program. Similar, the CP/M assembler Z80ASM+ by SLR Systems would display an error message when erroneously run on DOS.<ref name="Wilkinson-Seligman-Drushel-Elliott-Harston_1999"/> Some [[CP/M-80 3.0]] .COM files may have one or more [[RSX (computing)|RSX]] overlays attached to them by [[GENCOM (CP/M command)|GENCOM]].<ref name="Elliott_CPM3_COM"/> If so, they start with an extra [[256 byte boundary|256-byte]] header (one [[page (computing)|page]]). In order to indicate this, the first byte in the header is set to [[magic byte]] {{mono|C9h}}, which works both as a signature identifying this type of COM file to the CP/M 3.0 [[executable loader]], as well as a "RET" instruction for 8080-compatible processors which leads to a graceful exit if the file is executed under older versions of CP/M-80.<ref group="nb" name="NB_RET"/> {{mono|C9h}} is never appropriate as the first byte of a program for any x86 processor (it has different meanings for different generations,<ref group="nb" name="NB_C9"/> but is never a meaningful first byte); the executable loader in some versions of DOS rejects COM files that start with {{mono|C9h}}, avoiding incorrect operation. Similar [[opcode overlapping|overlapping]] code sequences have also been devised for combined Z80/[[6502]],<ref name="Wilkinson-Seligman-Drushel-Elliott-Harston_1999"/> 8086/[[68000]]<ref name="Wilkinson-Seligman-Drushel-Elliott-Harston_1999"/> or x86/[[MIPS architecture|MIPS]]/[[ARM architecture|ARM]] binaries.<ref name="Cha-Pak-Brumley-Lipton_2010"/>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)