.lf 1 ./man/man5/srec_intel.5
'\" t
.\" srecord - manipulate eprom load files
.\" Copyright (C) 1998, 2000, 2001, 2006-2011 Peter Miller
.\"
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 3 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program. If not, see
.\" .
.\"
.ds n) srec_intel
.TH \*(n) 5 SRecord "Reference Manual"
.SH NAME
srec_intel \- Intel Hexadecimal object file format specification
.if require_index \{
.XX "srec_intel(5)" "Intel Hexadecimal object file format specification"
.\}
.SH DESCRIPTION
This format is also known as the \fIIntel MCS\[hy]86 Object\fP format.
.PP
This document describes the hexadecimal object file format for the Intel
8\[hy]bit, 16\[hy]bit, and 32\[hy]bit microprocessors. The hexadecimal
format is suitable as input to PROM programmers or hardware emulators.
.PP
Hexadecimal object file format is a way of representing an absolute
binary object file in ASCII. Because the file is in ASCII instead of
binary, it is possible to store the file is non\[hy]binary medium such
as paper\[hy]tape, punch cards, etc.; and the file can also be displayed
on CRT terminals, line printers, etc.. The 8\[hy]bit hexadecimal
object file format allows for the placement of code and data within
the 16\[hy]bit linear address space of the Intel 8\[hy]bit processors.
The 16\[hy]bit hexadecimal format allows for the 20\[hy]bit segmented
address space of the Intel 16\[hy]bit processors. And the 32\[hy]bit
format allows for the 32\[hy]bit linear address space of the Intel
32\[hy]bit processors.
.PP
.TS
tab(;);
lf(CW) c c l.
\-\-address\-length=2;\[lq]i8hex\[rq];16\[hy]bit;
\-\-address\-length=3;\[lq]i16hex\[rq];20\[hy]bit;segmented
\-\-address\-length=4;\[lq]i32hex\[rq];32\[hy]bit;linear
.TE
.PP
The hexadecimal representation of binary is coded in ASCII alphanumeric
characters. For example, the 8\[hy]bit binary value 0011\[hy]1111 is 3F in
hexadecimal. To code this in ASCII, one 8\[hy]bit byte containing the
ASCII code for the character '3' (0011\[hy]0011 or 0x33) and one 8\[hy]bit
byte containing the) ASCII code for the character 'F' (0100\[hy]0110 or
0x46) are required. For each byte value, the high\[hy]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.
.PP
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 record are:
.TP 2n
\(bu
Data Record (8\[hy], 16\[hy], or 32\[hy]bit formats)
.TP 2n
\(bu
End of File Record (8\[hy], 16\[hy], or 32\[hy]bit formats)
.TP 2n
\(bu
Extended Segment Address Record (16\[hy] or 32\[hy]bit formats)
.TP 2n
\(bu
Start Segment Address Record (16\[hy] or 32\[hy]bit formats)
.TP 2n
\(bu
Extended Linear Address Record (32\[hy]bit format only)
.TP 2n
\(bu
Start Linear Address Record (32\[hy]bit format only)
.SS General Record Format
.TS
allbox,tab(;);
le le le le le le.
T{
Record
.br
Mark
T};T{
Record
.br
Length
T};T{
Load
.br
Offset
T};T{
Record
.br
Type
T};Data;T{
Check
.br
sum
T}
.TE
.TP 8n
Record Mark.
Each record begins with a Record Mark field containing 0x3A, the ASCII
code for the colon (\[lq]:\[rq]) character.
.TP 8n
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.
.TP 8n
Load Offset
Each record has a Load Offset field which specifies the 16\[hy]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 (\[lq]0000\[rq] or 0x30303030).
This field is two byte, represented as four hexadecimal characters.
.TP 8n
Record Type
.RS
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:
.TP 3n
0
Data Record
.TP 3n
1
End of File Record
.TP 3n
2
Extended Segment Address Record
.TP 3n
3
Start Segment Address Record
.TP 3n
4
Extended Linear Address Record
.TP 3n
5
Start Linear Address Record
.RE
.TP 8n
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.
.TP 8n
Checksum
Each record ends with a Checksum field that contains the ASCII hexadecimal
representation of the two's complement of the 8\[hy]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.
.SS Extended Linear Address Record
(32\[hy]bit format only)
.TS
allbox,tab(;);
ce ce ce ce ce ce.
T{
Record
.br
Mark
.br
(\[lq]:\[rq])
T};T{
Record
.br
Length
.br
(2)
T};T{
Load
.br
Offset
.br
(0)
T};T{
Record
.br
Type
.br
(4)
T};T{
ULBA (2
.br
bytes)
T};T{
Check
.br
sum
T}
.TE
.PP
The 32\[hy]bit Extended Linear Address Record is used to specify bits 16\[hy]31
of the Linear Base Address (LBA), where bits 0\[hy]15 of the LBA are zero.
Bits 16\[hy]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, ... \fIn\fP). This offset addition
is done) modulo 4G (\fIi.e.\fP 32\[hy]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:
.RS
(LBA + DRLO + DRI) MOD 4G
.RE
where:
.RS
.TP 5m
DRLO
is the Load Offset field of a Data Record.
.TP 5m
DRI
is the data byte index within the Data Record.
.RE
When an Extended Linear Address Record defines the value of LBA,
it may appear anywhere within a 32\[hy]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:
.TP 8n
Record Mark
This field contains 0x3A, the hexadecimal encoding of the ASCII colon
(\[lq]:\[rq]) character.
.TP 8n
Record Length
The field contains 0x3032, the hexadecimal encoding of the ASCII
characters \[lq]02\[rq], which is the length, in bytes, of the ULBA data
information within this record.
.TP 8n
Load Offset
This field contains 0x30303030, the hexadecimal encoding of the ASCII
characters \[lq]0000\[rq], since this field is not used for this record.
.TP 8n
Record Type
This field contains 0x3034, the hexadecimal encoding of the ASCII
character \[lq]04\[rq], which specifies the record type to be an Extended
Linear Address Record.
.TP 8n
ULBA
This field contains four ASCII hexadecimal digits that specify the 16\[hy]bit
Upper Linear Base Address value. The value is encoded big\[hy]endian (most
significant digit first).
.TP 8n
Checksum
This field contains the check sum on the Record Length, Load Offset,
Record Type, and ULBA fields.
.SS Extended Segment Address Record
(16\[hy] or 32\[hy]bit formats)
.TS
allbox,tab(;);
ce ce ce ce ce ce.
T{
Record
.br
Mark
.br
(\[lq]:\[rq])
T};T{
Record
.br
Length
.br
(2)
T};T{
Load
.br
Offset
.br
(0)
T};T{
Record
.br
Type
.br
(2)
T};T{
USBA (2
.br
bytes)
T};T{
Check
.br
sum
T}
.TE
.PP
The 16\[hy]bit Extended Segment Address Record is used to specify bits 4\[hy]19
of the Segment Base Address (SBA), where bits 0\[hy]3 of the SBA are zero.
Bits 4\[hy]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, ... \fIn\fP). This offset
addition is done modulo 64K (\fIi.e.\fP 16\[hy]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:
.RS
SBA + ((DRLO + DRI) MOD 64K)
.RE
where:
.RS
.TP 5m
DRLO
is the LOAD OFFSET field of a Data Record.
.TP 5m
DRI
is the data byte index within the Data Record.
.RE
.PP
When an Extended Segment Address Record defines the value of SBA,
it may appear anywhere within a 16\[hy]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.
.PP
The contents of the individual fields within the record are:
.TP 8n
Record Mark
This field contains 0x3A, the hexadecimal encoding of the ASCII colon
(\[lq]:\[rq]) character.
.TP 8n
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.
.TP 8n
Load Offset
This field contains 0x30303030, the hexadecimal encoding of the ASCII
characters '0000', since this field is not used for this record.
.TP 8n
Record Type
This field contains 0x3032, the hexadecimal encoding of the ASCII
character \[lq]02\[rq], which specifies the record type to be an Extended
Segment Address Record.
.TP 8n
USBA
This field contains four ASCII hexadecimal digits that specify the
16\[hy]bit Upper Segment Base Address value. The field is encoded
big\[hy]endian (most significant digit first).
.TP 8n
Checksum
This field contains the check sum on the Record length, Load Offset,
Record Type, and USBA fields.
.SS Data Record
(8\[hy], 16\[hy] or 32\[hy]bit formats)
.TS
allbox,tab(;);
ce ce ce ce ce ce.
T{
Record
.br
Mark
.br
(\[lq]:\[rq])
T};T{
Record
.br
Length
T};T{
Load
.br
Offset
T};T{
Record
.br
Type
T};Data;T{
Check
.br
sum
T}
.TE
.PP
The Data Record provides 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\[hy]bit and
32\[hy]bit case and segmented in the 16\[hy]bit case) for each byte of data is
described in the discussions of the Extended Linear Address Record and
the Extended Segment Address Record.
.PP
The contents of the individual fields within the record are:
.TP 8n
Record Mark
This field contains 0x3A, the hexadecimal encoding of the ASCII colon
(\[lq]:\[rq]) character.
.TP 8n
Record Length
The field contains two ASCII hexadecimal digits that specify the number
of data bytes in the record. The maximum value is 255 decimal.
.TP 8n
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.
.TP 8n
Record Type
This field contains 0x3030, the hexadecimal encoding of the ASCII
character \[lq]00\[rq], which specifies the record type to be a Data Record.
.TP 8n
Data
This field contains pairs of ASCII hexadecimal digits, one pair for each
data byte.
.TP 8n
Checksum
This field contains the check sum on the Record Length, Load Offset,
Record Type, and Data fields.
.PP
\f[B]Note:\fP 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.
.TP 8n
linear
If a record starts just short of 2**32, and would finish after 2**32,
the later part of the record wraps around to address 0.
TP 8n
segment
If a record starts just for of a 2**16 boundary, and would finish after
that 2**16 boundary, the later part of the record wraps around to
address 0 within the same segment (\f[B]not\fP the next segment).
.PP
The \f[I]srec_cat\fP(1) program will never output records such as these,
it will always produce separate records on output.
.SS Start Linear Address Record
(32\[hy]bit format only)
.TS
allbox,tab(;);
ce ce ce ce ce ce.
T{
Record
.br
Mark
.br
(\[lq]:\[rq])
T};T{
Record
.br
Length
.br
(4)
T};T{
Load.
.br
Offset
.br
(0)
T};T{
Record
.br
Type
.br
(5)
T};T{
EIP (4
.br
bytes)
T};T{
Check
.br
sum
T}
.TE
.PP
The Start Linear Address Record is used to specify the execution start
address for the object file. The value given is the 32\[hy]bit linear
address for the EIP register. Note that this record only specifies
the code address within the 32\[hy]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.
.PP
The Start Linear Address Record can appear anywhere in a 32\[hy]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.
.PP
The contents of the individual fields within the record are:
.TP 8n
Record mark
This field contains 0x3A, the hexadecimal encoding of the ASCII colon
(\[lq]:\[rq]) character.
.TP 8n
Record length
The field contains 0x3034, the hexadecimal encoding of the ASCII
characters \[lq]04\[rq], which is the length, in bytes, of the EIP register
content within this record.
.TP 8n
Load Offset
This field contains 0x30303030, the hexadecimal encoding of the ASCII
characters \[lq]0000\[rq], since this field is not used for this record.
.TP 8n
Record Type
This field contains 0x3035, the hexadecimal encoding of the ASCII
character \[lq]05\[rq], which specifies the record type to be a Start Linear
Address Record.
.TP 8n
EIP
This field contains eight ASCII hexadecimal digits that specify the
32\[hy]bit EIP register contents. The field is encoded big\[hy]endian (most
significant digit first).
.TP
Checksum
This field contains the check sum on the Record length, Load Offset,
Record Type, and EIP fields.
.SS Start Segment Address Record
(16\[hy] or 32\[hy]bit formats)
.TS
allbox,tab(;);
ce ce ce ce ce ce ce.
T{
Record
.br
Mark
.br
(\[lq]:\[rq])
T};T{
Record
.br
Length
.br
(4)
T};T{
Load.
.br
Offset
.br
(0)
T};T{
Record
.br
Type
.br
(3)
T};T{
CS (2
.br
bytes)
T};T{
IP (2
.br
bytes)
T};T{
Check
.br
sum
T}
.TE
.PP
The Start Segment Address Record is used to specify the execution
start address for the object file. The value given is the 20\[hy]bit
segment address for the CS and IP registers. Note that this record only
specifies the code address within the 20\[hy]bit segmented address space of
the 8086/80186. The Start Segment Address Record can appear anywhere
in a 16\[hy]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.
.PP
The contents of the individual fields within the record are:
.TP 8n
Record Mark
This field contains 0x3A, the hexadecimal encoding of the ASCII colon
(\[lq]:\[rq]) character.
.TP 8n
Record Length
The field contains 0x3034, the hexadecimal encoding of the ASCII
characters \[lq]04\[rq], which is the length, in bytes, of the CS and IP
register contents within this record.
.TP 8n
Load Offset
This field contains 0x30303030, the hexadecimal encoding of the ASCII
characters \[lq]0000\[rq], since this field is not used for this record.
.TP 8n
Record Type
This field contains 0x3033, the hexadecimal encoding of the ASCII
character '03', which specifies the record type to be a Start Segment
Address Record.
.TP 8n
CS
This field contains four ASCII hexadecimal digits that specify the 16\[hy]bit
CS register contents. The field is encoded big\[hy]endian (most significant
digit first).
.TP 8n
IP
This field contains four ASCII hexadecimal digits that specify the 16\[hy]bit
IP register contents. The field is encoded big\[hy]endian (most significant
digit first).
.TP 8n
Checksum
This field contains the check sum on the Record length, Load Offset,
Record Type, CS, and IP fields.
.SS End of File Record
(8\[hy], 16\[hy], or 32\[hy]bit formats)
.TS
allbox,tab(;);
ce ce ce ce ce.
T{
Record
.br
Mark
.br
(\[lq]:\[rq])
T};T{
Record
.br
Length
.br
(0)
T};T{
Load
.br
Offset
.br
(0)
T};T{
Record
.br
Type
.br
(1)
T};T{
Check
.br
sum
.br
(0xFF)
T}
.TE
.PP
The End of File Record specifies the end of the hexadecimal object file.
.PP
The contents of the individual fields within the record are:
.TP 8n
Record mark
This field contains 0x3A, the hexadecimal encoding of the ASCII colon
(\[lq]:\[rq]) character.
.TP 8n
Record Length
The field contains 0x3030, the hexadecimal encoding of the ASCII
characters \[lq]00\[rq]. Since this record does not contain any Data bytes,
the length is zero.
.TP 8n
Load Offset
This field contains 0x30303030, the hexadecimal encoding of the ASCII
characters \[lq]0000\[rq], since this field is not used for this record.
In ancient times, i8hex used this for the start address record.
.TP 8n
Record Type
This field contains 0x3031, the hexadecimal encoding of the ASCII
character \[lq]01\[rq], which specifies the record type to be an End of File
Record.
.TP 8n
Checksum
This field contains the check sum an the Record Length, Load Offset,
and Record Type fields. Since all the fields are static, the check
sum can also be calculated statically, and the value is 0x4646, the
hexadecimal encoding of the ASCII characters \[lq]FF\[rq].
.SS Size Multiplier
In general, binary data will expand in sized by approximately 2.3 times
when represented with this format.
.\" ------------------------------------------------------------------------
.br
.ne 2i
.SH EXAMPLE
Here is an example Intel hex file.
It contains the data \[lq]Hello, World\[rq] to be loaded at address 0.
.RS
.nf
.ft CW
:0D00000048656C6C6F2C20576F726C640AA1
:00000001FF
.ft P
.fi
.RE
.\" ------------------------------------------------------------------------
.br
.ne 2i
.SH REFERENCE
This information comes (very indirectly) from
.I "Microprocessors and Programmed Logic,"
Second Edition,
Kenneth L. Short,
1987,
Prentice\[hy]Hall,
ISBN 0\[hy]13\[hy]580606\[hy]2.
.PP
http://en.wikipedia.org/wiki/Intel_HEX
.\" ------------------------------------------------------------------------
.ds n) srec_cat
.lf 1 ./man/man1/z_copyright.so
.\"
.\" srecord - manipulate eprom load files
.\" Copyright (C) 1998, 2006-2009 Peter Miller
.\"
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 3 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program. If not, see
.\" .
.\"
.br
.ne 1i
.SH COPYRIGHT
.lf 1 ./etc/version.so
.ds V) 1.58.D001
.ds v) 1.58
.ds Y) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
.lf 23 ./man/man1/z_copyright.so
.I \*(n)
version \*(v)
.br
Copyright
.if n (C)
.if t \(co
\*(Y) Peter Miller
.br
.PP
The
.I \*(n)
program comes with ABSOLUTELY NO WARRANTY;
for details use the '\fI\*(n) \-VERSion License\fP' command.
This is free software
and you are welcome to redistribute it under certain conditions;
for details use the '\fI\*(n) \-VERSion License\fP' command.
.br
.ne 1i
.SH AUTHOR
.TS
tab(;);
l r l.
Peter Miller;E\[hy]Mail:;pmiller@opensource.org.au
/\e/\e*;WWW:;http://miller.emu.id.au/pmiller/
.TE
.lf 709 ./man/man5/srec_intel.5
.SS Derivation
This manual page is derived from a file marked as follows:
.PP
Intel
Hexadecimal Object File
Format Specification;
Revision A, 1/6/88
.PP
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. 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. The publication of this specification should not
be construed as a commitment on Intel's part to implement any product.