3 Comments
Oct 1Liked by Julio Merino

Actually, the first 256 bytes contains code for the operating system. For instance, in MSX-DOS (a variant of MS-DOS for Z-80 machines), the address 05H is used to call the BDOS (Basic Disk Operating System). For instance: loading the address at register DE, the code 09H on the register C and calling the address 05H, either by CALL 05H or RST 05H would print the string contained in (DE), terminated by a "$". Since MSX could swap memory pages at each 16Kb, the first page was static (containing the BDOS and the COM code), the last page was fixed as well because it contains DOS RAM stuff, such as settings, stack, etc., that would give you 2 pages you could swap to use unlimited (well, at most 4Mb) RAM. CP/M was the same, AFAIK.

Expand full comment
author

I don't know much about the architecture of MSX, but according to https://en.wikipedia.org/wiki/Program_Segment_Prefix for DOS and https://en.wikipedia.org/wiki/Zero_page_(CP/M) for CP/M, address 05h seems to just be a "trap door" to get into the OS and the PSP doesn't seem to contain actual code... Maybe the processors that CP/M ran on didn't have software interrupts and couldn't do the equivalent of INT 21h?

Expand full comment

CP/M run on 8080 (which Z-80 is compatible). Those architectures had a RST instruction (one byte instruction that is the same as CALL for fixed addresses). INT, as far as I know, need an interrupt vector table (don't know if this IVT is writable or fixed). RST has fixed addresses always. From memory, I remember RST 0 is return control to MSX-DOS or CP/M, RST 5 is call BDOS (for 16-bit CP/M is INT 0E0h), etc.

This link has all CP/M or MSX-DOS BDOS functions (they are the same because MS is good in acquiring software, not building them): https://www.seasip.info/Cpm/bdos.html

So, TL;DR; that's the reason COM files are 0100h bytes offset =)

Expand full comment