Sentinel65X-Handbook/Executables.md

29 lines
1.4 KiB
Markdown

---
gitea: none
include_toc: true
---
# Executables
Sentinel 65X's firmware is designed to load and execute binaries in the `PGZ` format. This is a multi-segment binary file format which can load data into any number of areas of memory from a compact binary.
## PGZ Format
The first byte of a PGZ file is always an ASCII "Z", hexadecimal value `0x5A`, decimal value `90`.
This is followed by one or more segments, packed with no padding or separator. Each such segment has the following format:
| Offset | Length | Description |
| :----: | :----: | :------------: |
| 0 | 3 bytes | Target address |
| 3 | 3 bytes | Length of data |
| 6 | ... | Data |
This enables the binary loader to be extremely simple, as the data to be read into memory is always read from a contiguous region of memory, and the information provided is sufficient to make use of the C standard library `memcpy()` function.
The final segment is special: its target address represents the entry point to the executable, and its length of data value is always `0x000000`. The loader can easily detect this to identify when loading is done and where to enter the program.
The Sentinel 65X SDK will be configured to produce PGZ format executables by default, with the option to instead export to a file suitable for writing to a ROM cartridge.
Note: The open-source 64Tass assembler is also capable of generating PGZ-format executables.