srec_intel(5)
π srec_intel(5) π
okay bestie, welcome to srec_intel(5) β the Intel Hexadecimal object file format specification, and yes it's as iconic as it sounds π
β¨ NAME β¨
srec_intel β Intel Hexadecimal object file format specification π
πΈ DESCRIPTION πΈ
So this format also goes by the name Intel MCSβ86 Object format (iykyk).
This doc describes the hexadecimal object file format for the Intel 8βbit, 16βbit, and 32βbit microprocessors. The hexadecimal format is literally suitable as input to PROM programmers or hardware emulators. slay.
Hexadecimal object file format is a way of representing an absolute binary object file in ASCII. And because the file is in ASCII instead of binary, you can store it on nonβbinary medium such as paperβtape, punch cards, etc. β and the file can also be displayed on CRT terminals, line printers, etc. (we love a format that works everywhere π). The 8βbit hexadecimal object file format allows for the placement of code and data within the 16βbit linear address space of the Intel 8βbit processors. The 16βbit hexadecimal format allows for the 20βbit segmented address space of the Intel 16βbit processors. And the 32βbit format allows for the 32βbit linear address space of the Intel 32βbit processors.
The mapping is giving:
--address-length=2ββi8hexββ 16βbit--address-length=3ββi16hexββ 20βbit segmented--address-length=4ββi32hexββ 32βbit linear
The hexadecimal representation of binary is coded in ASCII alphanumeric characters. For example, the 8βbit binary value 0011β1111 is 3F in hexadecimal. To code this in ASCII, one 8βbit byte containing the ASCII code for the character '3' (0011β0011 or 0x33) and one 8βbit byte containing the ASCII code for the character 'F' (0100β0110 or 0x46) are required. For each byte value, the highβorder hexadecimal digit is always the first digit of the pair of hexadecimal digits. This representation (ASCII hexadecimal) requires twice as many bytes as the binary representation. trade-off queen π
A hexadecimal object file is blocked into records, each of which contains the record type, length, memory load address and checksum in addition to the data. There are currently six (6) different types of records that are defined, not all combinations of these records are meaningful, however. The records are:
- Data Record (8β, 16β, or 32βbit formats)
- End of File Record (8β, 16β, or 32βbit formats)
- Extended Segment Address Record (16β or 32βbit formats)
- Start Segment Address Record (16β or 32βbit formats)
- Extended Linear Address Record (32βbit format only)
- Start Linear Address Record (32βbit format only)
π¦ General Record Format π¦
Every single record is built from these fields, in this exact order bestie:
- Record Mark
- Record Length
- Load Offset
- Record Type
- Data
- Check sum
π Record Mark
Each record begins with a Record Mark field containing 0x3A, the ASCII code for the colon (β:β) character.
π Record Length
Each record has a Record Length field which specifies the number of bytes of information or data which follows the Record Type field of the record. This field is one byte, represented as two hexadecimal characters. The maximum value of the Record Length field is hexadecimal 'FF' or 255.
π Load Offset
Each record has a Load Offset field which specifies the 16βbit starting load offset of the data bytes, therefore this field is only used for Data Records. In other records where this field is not used, it should be coded as four ASCII zero characters (β0000β or 0x30303030). This field is two byte, represented as four hexadecimal characters.
π Record Type
Each record has a Record Type field which specifies the record type of this record. The Record Type field is used to interpret the remaining information within the record. This field is one byte, represented as two hexadecimal characters. The encoding for all the current record types are:
0β Data Record1β End of File Record2β Extended Segment Address Record3β Start Segment Address Record4β Extended Linear Address Record5β Start Linear Address Record
π Data
Each record has a variable length Data field, it consists of zero or more bytes encoded as pairs of hexadecimal digits. The interpretation of this field depends on the Record Type field.
π Checksum
Each record ends with a Checksum field that contains the ASCII hexadecimal representation of the two's complement of the 8βbit bytes that result from converting each pair of ASCII hexadecimal digits to one byte of binary, from and including the Record Length field to and including the last byte of the Data field. Therefore, the sum of all the ASCII pairs in a record after converting to binary, from the Record Length field to and including the Checksum field, is zero. math ate, no crumbs π
π₯ Extended Linear Address Record π₯
(32βbit format only)
Field layout, in order, bestie: Record Mark (β:β), Record Length (2), Load Offset (0), Record Type (4), ULBA (2 bytes), Check sum.
The 32βbit Extended Linear Address Record is used to specify bits 16β31 of the Linear Base Address (LBA), where bits 0β15 of the LBA are zero. Bits 16β31 of the LBA are referred to as the Upper Linear Base Address (ULBA). The absolute memory address of a content byte in a subsequent Data Record is obtained by adding the LBA to an offset calculated by adding the Load Offset field of the containing Data Record to the index of the byte in the Data Record (0, 1, 2, ... n). This offset addition is done modulo 4G (i.e. 32βbits from 0xFFFFFFFF to 0x00000000) results in wrapping around from the end to the beginning of the 4G linear address defined by the LBA. The linear address at which a particular byte is loaded is calculated as:
(LBA + DRLO + DRI) MOD 4G
where:
DRLOis the Load Offset field of a Data Record.DRIis the data byte index within the Data Record.
When an Extended Linear Address Record defines the value of LBA, it may appear anywhere within a 32βbit hexadecimal object file. This value remains in effect until another Extended Linear Address Record is encountered. The LBA defaults to zero until an Extended Linear Address Record is encountered. The contents of the individual fields within the record are:
β Record Mark
This field contains 0x3A, the hexadecimal encoding of the ASCII colon (β:β) character.
β Record Length
The field contains 0x3032, the hexadecimal encoding of the ASCII characters β02β, which is the length, in bytes, of the ULBA data information within this record.
β Load Offset
This field contains 0x30303030, the hexadecimal encoding of the ASCII characters β0000β, since this field is not used for this record.
β Record Type
This field contains 0x3034, the hexadecimal encoding of the ASCII character β04β, which specifies the record type to be an Extended Linear Address Record.
β ULBA
This field contains four ASCII hexadecimal digits that specify the 16βbit Upper Linear Base Address value. The value is encoded bigβendian (most significant digit first). π
β Checksum
This field contains the check sum on the Record Length, Load Offset, Record Type, and ULBA fields.
π Extended Segment Address Record π
(16β or 32βbit formats)
Field layout, in order: Record Mark (β:β), Record Length (2), Load Offset (0), Record Type (2), USBA (2 bytes), Check sum.
The 16βbit Extended Segment Address Record is used to specify bits 4β19 of the Segment Base Address (SBA), where bits 0β3 of the SBA are zero. Bits 4β19 of the SBA are referred to as the Upper Segment Base Address (USBA). The absolute memory address of a content byte in a subsequent Data Record is obtained by adding the SBA to an offset calculated by adding the Load Offset field of the containing Data Record to the index of the byte in the Data Record (0, 1, 2, ... n). This offset addition is done modulo 64K (i.e. 16βbits from 0xFFFF to 0x0000 results in wrapping around from the end to the beginning of the 64K segment defined by the SBA). The address at which a particular byte is loaded is calculated as:
SBA + ((DRLO + DRI) MOD 64K)
where:
DRLOis the LOAD OFFSET field of a Data Record.DRIis the data byte index within the Data Record.
When an Extended Segment Address Record defines the value of SBA, it may appear anywhere within a 16βbit hexadecimal object file. This value remains in effect until another Extended Segment Address Record is encountered. The SBA defaults to zero until an Extended Segment Address Record is encountered.
The contents of the individual fields within the record are:
π«Ά Record Mark
This field contains 0x3A, the hexadecimal encoding of the ASCII colon (β:β) character.
π«Ά Record Length
The field contains 0x3032, the hexadecimal encoding of the ASCII characters '02', which is the length, in bytes, of the USBA data information within this record.
π«Ά Load Offset
This field contains 0x30303030, the hexadecimal encoding of the ASCII characters '0000', since this field is not used for this record.
Record Typeβ this field contains0x3032, the hexadecimal encoding of the ASCII character β02β, which specifies the record type to be an Extended Segment Address Record. iconic little type tag, no cap β¨USBAβ this field contains four ASCII hexadecimal digits that specify the 16βbit Upper Segment Base Address value. The field is encoded bigβendian (most significant digit first).Checksumβ this field contains the check sum on theRecord length,Load Offset,Record Type, andUSBAfields.
πΎ Data Record πΎ
(8β, 16β or 32βbit formats)
ββββββββββ¬βββββββββ¬βββββββββ¬βββββββββ¬βββββββββ¬βββββββββ
β Record β Record β Load β Record β Data β Check β
β Mark β Length β Offset β Type β β sum β
β (β:β) β β β β β β
ββββββββββ΄βββββββββ΄βββββββββ΄βββββββββ΄βββββββββ΄βββββββββ
The Data Record gives you a set of hexadecimal digits that represent the ASCII code for data bytes that make up a portion of a memory image. The method for calculating the absolute address (linear in the 8βbit and 32βbit case and segmented in the 16βbit case) for each byte of data is described in the discussions of the Extended Linear Address Record and the Extended Segment Address Record. thatβs the whole vibe: itβs the record that actually carries the bytes, bestie π
The contents of the individual fields within the record are:
Record Markβ this field contains0x3A, the hexadecimal encoding of the ASCII colon (β:β) character.Record Lengthβ the field contains two ASCII hexadecimal digits that specify the number of data bytes in the record. The maximum value is255decimal.Load Offsetβ this field contains four ASCII hexadecimal digits representing the offset from the LBA (see Extended Linear Address Record see Extended Segment Address Record) defining the address which the first byte of the data is to be placed.Record Typeβ this field contains0x3030, the hexadecimal encoding of the ASCII character β00β, which specifies the record type to be a Data Record.Dataβ this field contains pairs of ASCII hexadecimal digits, one pair for each data byte.Checksumβ this field contains the check sum on theRecord Length,Load Offset,Record Type, andDatafields.
Note: care must be taken when the addresses with an record span the end of addressing. The behaviour is different for linear and segmented addressing modes. this is the part where you sit up straight, bestie π«Ά
- linear β if a record starts just short of
2**32, and would finish after2**32, the later part of the record wraps around to address0. - TP 8n segment β if a record starts just for of a
2**16boundary, and would finish after that2**16boundary, the later part of the record wraps around to address0within the same segment (not the next segment). yes, βTP 8n segmentβ β we are keeping the originalβs chaos π
The srec_cat(1) program will never output records such as these, it will always produce separate records on output.
π Start Linear Address Record π
(32βbit format only)
ββββββββββ¬βββββββββ¬βββββββββ¬βββββββββ¬βββββββββ¬βββββββββ
β Record β Record β Load. β Record β EIP (4 β Check β
β Mark β Length β Offset β Type β bytes) β sum β
β (β:β) β (4) β (0) β (5) β β β
ββββββββββ΄βββββββββ΄βββββββββ΄βββββββββ΄βββββββββ΄βββββββββ
The Start Linear Address Record is used to specify the execution start address for the object file. The value given is the 32βbit linear address for the EIP register. Note that this record only specifies the code address within the 32βbit linear address space of the 80386. If the code is to start execution in the real mode of the 80386, then the Start Segment Address Record should be used instead, since that record specifies both the CS and IP register contents necessary for real mode. like, choose your address-space era wisely β¨
The Start Linear Address Record can appear anywhere in a 32βbit hexadecimal object file. If such a record is not present in a hexadecimal object file, a loader is free to assign a default execution start address.
The contents of the individual fields within the record are:
Record markβ this field contains0x3A, the hexadecimal encoding of the ASCII colon (β:β) character.Record lengthβ the field contains0x3034, the hexadecimal encoding of the ASCII characters β04β, which is the length, in bytes, of the EIP register content within this record.Load Offsetβ this field contains0x30303030, the hexadecimal encoding of the ASCII characters β0000β, since this field is not used for this record.Record Typeβ this field contains0x3035, the hexadecimal encoding of the ASCII character β05β, which specifies the record type to be a Start Linear Address Record.EIPβ this field contains eight ASCII hexadecimal digits that specify the 32βbit EIP register contents. The field is encoded bigβendian (most significant digit first).Checksumβ this field contains the check sum on theRecord length,Load Offset,Record Type, andEIPfields.
πΈ Start Segment Address Record πΈ
(16β or 32βbit formats)
ββββββββββ¬βββββββββ¬βββββββββ¬βββββββββ¬βββββββββ¬βββββββββ¬βββββββββ
β Record β Record β Load. β Record β CS (2 β IP (2 β Check β
β Mark β Length β Offset β Type β bytes) β bytes) β sum β
β (β:β) β (4) β (0) β (3) β β β β
ββββββββββ΄βββββββββ΄βββββββββ΄βββββββββ΄βββββββββ΄βββββββββ΄βββββββββ
The Start Segment Address Record is used to specify the execution start address for the object file. The value given is the 20βbit segment address for the CS and IP registers. Note that this record only specifies the code address within the 20βbit segmented address space of the 8086/80186. The Start Segment Address Record can appear anywhere in a 16βbit hexadecimal object file. If such a record is not present in a hexadecimal object file, a loader is free to assign a default start address. segmented-address main character energy, fr fr π¦
The contents of the individual fields within the record are:
Record Markβ this field contains0x3A, the hexadecimal encoding of the ASCII colon (β:β) character.Record Lengthβ the field contains0x3034, the hexadecimal encoding of the ASCII characters β04β, which is the length, in bytes, of the CS and IP register contents within this record.Load Offsetβ this field contains0x30303030, the hexadecimal encoding of the ASCII characters β0000β, since this field is not used for this record.Record Typeβ this field contains0x3033, the hexadecimal encoding of the ASCII character'03', which specifies the record type to be a Start Segment Address Record.CSβ this field contains four ASCII hexadecimal digits that specify the 16βbit CS register contents. The field is encoded bigβendian (most significant digit first).IPβ this field contains four ASCII hexadecimal digits that specify the 16βbit IP register contents. The field is encoded bigβendian (most significant digit first).Checksumβ this field contains the check sum on theRecord length,Load Offset,Record Type,CS, andIPfields.
π¦ End of File Record π¦
(8β, 16β, or 32βbit formats)
ββββββββββ¬βββββββββ¬βββββββββ¬βββββββββ¬βββββββββ
β Record β Record β Load β Record β Check β
β Mark β Length β Offset β Type β sum β
β (β:β) β (0) β (0) β (1) β (0xFF) β
ββββββββββ΄βββββββββ΄βββββββββ΄βββββββββ΄βββββββββ
The End of File Record specifies the end of the hexadecimal object file. the final boss of the file, periodt π
The contents of the individual fields within the record are:
Record markβ this field contains0x3A, the hexadecimal encoding of the ASCII colon (β:β) character.Record Lengthβ the field contains0x3030, the hexadecimal encoding of the ASCII characters β00β. Since this record does not contain any Data bytes, the length is zero.Load Offsetβ this field contains0x30303030, the hexadecimal encoding of the ASCII characters β0000β, since this field is not used for this record. In ancient times,i8hexused this for the start address record. lore drop πRecord Typeβ this field contains0x3031, the hexadecimal encoding of the ASCII character β01β, which specifies the record type to be an End of File Record.Checksumβ this field contains the check sum on theRecord Length,Load Offset, andRecord Typefields. Since all the fields are static, the check sum can also be calculated statically, and the value is0x4646, the hexadecimal encoding of the ASCII characters βFFβ.
β¨ Size Multiplier β¨
In general, binary data will expand in sized by approximately 2.3 times when represented with this format. yes, βin sized byβ β the original said it like that, and weβre not fixing the vibe π
π₯ EXAMPLE π₯
Here is an example Intel hex file. It contains the data βHello, Worldβ to be loaded at address 0.
:0D00000048656C6C6F2C20576F726C640AA1
:00000001FF
π REFERENCE π
This information comes (very indirectly) from Microprocessors and Programmed Logic, Second Edition, Kenneth L. Short, 1987, PrenticeβHall, ISBN 0β13β580606β2.
http://en.wikipedia.org/wiki/Intel_HEX
π COPYRIGHT π
srec_cat version 1.65
Copyright (C) 1998... Peter Miller
The srec_cat program comes with ABSOLUTELY NO WARRANTY; for details use the srec_cat -VERSion License command. This is free software and you are welcome to redistribute it under certain conditions; for details use the srec_cat -VERSion License command. read the license, bestie β itβs giving legal realness π
π MAINTAINER π
okay so bestie, if you ever need to yell at someone about this page, these are your people π:
- Scott Finneran β EβMail:
scottfinneran@yahoo.com.au - Peter Miller β EβMail:
pmiller@opensource.org.au
π§ Derivation
ngl, this whole manual page did not get summoned out of thin air β it's derived from a file, and that file is marked, in its own words, like this:
Intel Hexadecimal Object File Format Specification; Revision A, 1/6/88
and then there's the disclaimer that comes attached to it, which, bestie, you need to read, because it's the whole "we're not promising anything" moment. Here's what it says, real talk:
- Disclaimer: Intel makes no representation or warranties with respect to the contents hereof and specifically disclaims any implied warranties of merchantability or fitness for any particular purpose. π«Ά (translation: no promises, no guarantees, don't come for them.)
- Further, Intel reserves the right to revise this publication from time to time in the content hereof without obligation of Intel to notify any person of such revision or changes. π₯ so yeah β it can change under your feet and they don't owe you a heads-up, iykyk.
- The publication of this specification should not be construed as a commitment on Intel's part to implement any product. π literally just because it's written down doesn't mean they're gonna build it.
β that's not me being dramatic, that's the actual disclaimer, bestie β every word of it matters, no cap.
πΈ and that's a wrap! this whole thing came to you from the SRecord reference manual β page srec_intel(5) β so if you're citing it, credit SRecord, and check the date/version stamped on the page you're reading, 'cause that's the glow-up edition you've got in your hands. β¨π go forth and slay those hex records, you absolute icon ππ¦π
π¦ where this page comes from
- opensuse-leap 16.0: srecord 1.65.0-bp160.1.12 Β· GPL-3.0-or-later
- opensuse-leap 16.0: srecord 1.65.0-bp160.1.12 Β· GPL-3.0-or-later
- opensuse-leap 16.0: srecord 1.65.0-bp160.1.12 Β· GPL-3.0-or-later
- opensuse-leap 16.0: srecord 1.65.0-bp160.1.12 Β· GPL-3.0-or-later
- Copyright (C) 1998, 2000, 2001, 2006-2011 Peter Miller
- Copyright (C) 1998, 2006-2009, 2014 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms