Difference between revisions of "Executable binary file"

From C256 Foenix Wiki
Jump to navigation Jump to search
(PGX)
(PGX)
Line 14: Line 14:
 
| 0 || 3 || "PGZ" || Signature
 
| 0 || 3 || "PGZ" || Signature
 
|-
 
|-
| 4 || 1 || $01 || CPU
+
| 3 || 1 || $01 || CPU
 
|-
 
|-
| 5 || 3 || $010000 || Destination Address
+
| 4 || 4 || $010000 || Destination Address
 
|-
 
|-
 
| 8 || - || $00 $01 $02 ... || The data to load
 
| 8 || - || $00 $01 $02 ... || The data to load

Revision as of 08:43, 9 August 2021

The F_RUN and F_LOAD kernel calls supports multiple binary formats. If you try to load a file in one of these formats without specifying a starting address, it will be loaded into the locations specified in the file. If you try to run a file in one of these formats, the file will be loaded into memory and executed.

PGX

PGX is a simple, single segment format akin to Commodore's PRG format. The file starts with an eight byte header, followed by the contents to be loaded into memory. The header consists of three parts:

  • The first three bytes are the ASCII codes for "PGX", serving as a file type signature.
  • The fourth byte is the CPU code, indicating the target CPU. Currently, only the value $01 is supported and designates that the 65816 is the target CPU.
  • The final four bytes of the header are the starting destination address in little-endian format. This address will be the location to store the first byte of the data (which is the ninth byte of the file).
Offset Count Example Purpose
0 3 "PGZ" Signature
3 1 $01 CPU
4 4 $010000 Destination Address
8 - $00 $01 $02 ... The data to load

PGZ

PGZ is a multi-segment file format that can load data into multiple areas in memory. The format is derived from binary format used by Western Design Center's C compiler.

  • The first byte of the PGZ format is the ASCII code for "Z". This serves as the file type signature.
  • Next comes any number of segments, each following right after the previous segment with no separator. Each segment has the following format:
    • Three bytes of address, in little endian format. This is the starting address for writing the data of the segment.
    • Three bytes indicating the size of the segment, in little endian format.
    • The bytes of data in the segment (same number of bytes as specified in the size).
  • If final segment has a size of $000000 and no data bytes, then address specifies the starting address of the executable.