-
Notifications
You must be signed in to change notification settings - Fork 3
MOS executable format
envenomator edited this page May 20, 2023
·
3 revisions
When a user executes the MOS run function, either by using 'RUN' as a command, or typing the name of a corresponding program in the /mos/ directory and hitting enter, MOS performs the following checks on the loaded program in memory:
- Are the ASCII characters 'M', 'O' and 'S' present from index location 40 hex / 64 decimal?
- Future check of MOS header version byte at location 43 hex / 67 decimal
- Check of ADL mode at location 44 hex / 68 decimal - (0: Z80, 1: ADL) to determine the program's memory mode
Assembler programs achieve this header implementation by using alignment to 40h / 64 and jumping to the user code after the header like:
.assume adl=1 ; program starts in ADL mode
.org $40000 ; program will be assembled to / loaded from first AgonLight RAM address
jp start ; skip over header
.align 64
.db "MOS" ; MOS header 'magic' characters
.db 00h ; MOS header version 0 - the only in existence currently
.db 01h ; Flag for run mode (0: Z80, 1: ADL) - We start up in ADL mode here
start:
; actual user code here
There is some space available between the 'jp start' opcode and the actual header. Some small variables may fit, such as the program name, but take care to not put in too much data and to obey the alignment, such that it doesn't skip to the next 64 bytes, invalidating the header.