Difference between revisions of "Executable binary file"

From C256 Foenix Wiki
Jump to navigation Jump to search
(PGZ)
Line 26: Line 26:
  
 
* The first byte of the PGZ format is the ASCII code for "Z". This serves as the file type signature.
 
* The first byte of the PGZ format is the ASCII code for "Z". This serves as the file type signature.
 +
* Big "Z" = 24bits Addresse Pointers and Sizes. Small "z" = 32bits Addresse Pointers and Sizes.
 
* Next comes any number of segments, each following right after the previous segment with no separator. Each segment has the following format:
 
* 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 of address, in little endian format. This is the starting address for writing the data of the segment.

Revision as of 15:18, 3 March 2022

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 "PGX" 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.
  • Big "Z" = 24bits Addresse Pointers and Sizes. Small "z" = 32bits Addresse Pointers and Sizes.
  • 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.
Segment Offset Count Example Purpose
N/A 0 1 "Z" Signature
1 1 3 $010000 Address of segment #1
4 3 $000009 Size of segment #1
7 ... ... Data of Segment #1
2 16 3 $020000 Address of segment #2
19 3 $000008 Size of segment #2
22 ... ... Data of Segment #2
3 30 3 $010000 Starting address
33 3 $000000 0 to indicate start address