Flat binary format, contains no formatting, metadata or other info. The program code is placed in the file in the order it is assembled.
When assembling flat files, any includes normally should go at the bottom of the file, this is only a recommendation.
The use of .org macros will change the generation address, but not the order of the code in the binary file.
Simple text based format that allows addressable loading and a program entry address.
All values in s19 are uppercase ASCII and numbers, data are stored as sequential bytes (big endian) as two hex digits each.
All data are broken into "records" which can contain up to 254 bytes each, typical records will be shorter. Each record consists of: ASCII "S", a digit indicating record type, a byte length - 2 hex digits, variable size fields.
The first field is the address field, it is normally 2 bytes long, 3 bytes for S2,S8 records, 4 bytes for S3 and S9 records.
Next is the data field, the size of the data field is (length - 1) - address_bytes
After the data field is a one byte checksum field, this is computed by adding up the length and all other fields, taking the least significant byte and inverting the bits (ones complement).
The file is a sequence of records, seperated by newlines. All records must have a checksum. These are the record types:
- S0 metadata or version string
- S1,S2,S3 actual program data and addresses (which kind depends on address size).
- S5 a count of previous S1,S2,S3 records, count stored in 16 bit address field + checksum.
- S7,S8,S9 optional, program start address, just an address checksum fields, no data.
A versatile and extendable format, but also more complex. Designed for 32 bit machines.
For CPU architectures that use less than 32 bits, the 32 bit spec is used, but all the high bits of addresses are set to 0 and ignored.
Offset (hex) | Length (bytes) | Field | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
00 | 4 | Magic | Big endian byte string that identifies the file (0x7F454C46) | ||||||||||||||||||||||||
04 | 1 | Endianness | Either 1 - little endian or 2 - big endian | ||||||||||||||||||||||||
05 | 1 | Wordsize | This field defines the address word size. For processors with addresses less than 32 bits: a 32 bit option is used with extra bits set to 0.
It also defines the size of individual words stored at each address. Values are as follows:
| ||||||||||||||||||||||||
06 | 1 | Version | Normally set to 0x01 | ||||||||||||||||||||||||
07 | 1 | osabitype | user definable OS type, set to 0x5E by default. | ||||||||||||||||||||||||
08 | 1 | osabiver | user definable, set to 0x00 by default. | ||||||||||||||||||||||||
09 | 7 | padding | unused, set to 0 | ||||||||||||||||||||||||
Values below are stored in the endianness of the target machine. | |||||||||||||||||||||||||||
10 | 2 | exetype | Executable type
| ||||||||||||||||||||||||
12 | 2 | arch | Architecture/CPU type. WaveAsm will support the following values for arch:
| ||||||||||||||||||||||||
14 | 4 | eversion | default 0x00000001 | ||||||||||||||||||||||||
18 | n=addrsize (see above) | entry | beginning address of program execution | ||||||||||||||||||||||||
18+n | n | phstart | absolute file offset to start of program header | ||||||||||||||||||||||||
18+2n | n | shstart | absolute file offset to start of sections header | ||||||||||||||||||||||||
18+3n | 4 | flags | unused | ||||||||||||||||||||||||
1C+3n | 2 | headersz | size of this header: dec 40+3n; hex 0x28+3n | ||||||||||||||||||||||||
1E+3n | 2 | phsz | size of program header | ||||||||||||||||||||||||
20+3n | 2 | phct | entries in program header | ||||||||||||||||||||||||
22+3n | 2 | shsz | size of section header | ||||||||||||||||||||||||
24+3n | 2 | shct | entries in section header | ||||||||||||||||||||||||
26+3n | 2 | shsnindx | index of sections entry with section names. |
The program header consists of an array of entries. The count entries and starting file offset are in the main header. Each entry in the program header table optionally points to a segment in the file with data.
Offset (hex) | Length (bytes) | Field | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
00 | 4 | type |
| ||||||||||||
04 | 4 | offset | file offset that segment starts at | ||||||||||||
08 | 4 | vaddr | Virtual memory address segment should be loaded at | ||||||||||||
0C | 4 | paddr | Physical memory address segment should be loaded at. (if applicable) | ||||||||||||
10 | 4 | filesz | Size of segment in file | ||||||||||||
14 | 4 | memsz | amount of memory to be allocated for segment | ||||||||||||
18 | 4 | flags | Bit mask of options
| ||||||||||||
1C | 4 | align | The alignment that should be used for the segment. A value of 0 or 1 means no alignment, other values must be a power of 2 |
The typical ELF file generated by WaveAsm consists (minimally) of the main header, followed a two or more entries program header table. A 2 entry section table (the null section and string table). Then program segment(s).