@@ -9,10 +9,11 @@ import (
9
9
10
10
// Constants definitions of IntelHex record types
11
11
const (
12
- _DATA_RECORD byte = 0 // Record with data bytes
13
- _EOF_RECORD byte = 1 // Record with end of file indicator
14
- _ADDRESS_RECORD byte = 4 // Record with extended linear address
15
- _START_RECORD byte = 5 // Record with start linear address
12
+ _DATA_RECORD byte = 0 // Record with data bytes
13
+ _EOF_RECORD byte = 1 // Record with end of file indicator
14
+ _EXTENDED_RECORD byte = 2 // Record with end of file indicator
15
+ _ADDRESS_RECORD byte = 4 // Record with extended linear address
16
+ _START_RECORD byte = 5 // Record with start linear address
16
17
)
17
18
18
19
// Structure with binary data segment fields
@@ -33,6 +34,7 @@ type Memory struct {
33
34
dataSegments []* DataSegment // Slice with pointers to DataSegments
34
35
startAddress uint32 // Start linear address
35
36
extendedAddress uint32 // Extended linear address
37
+ offset uint32 // Extended offset inside same linear address
36
38
eofFlag bool // End of file record exist flag
37
39
startFlag bool // Start address record exist flag
38
40
lineNum uint // Parser input line number
@@ -211,7 +213,7 @@ func (m *Memory) parseIntelHexRecord(bytes []byte) error {
211
213
switch record_type := bytes [3 ]; record_type {
212
214
case _DATA_RECORD :
213
215
a , data := getDataLine (bytes )
214
- adr := uint32 (a ) + m .extendedAddress
216
+ adr := uint32 (a ) + m .extendedAddress + m . offset
215
217
err = m .AddBinary (adr , data )
216
218
if err != nil {
217
219
return err
@@ -222,6 +224,12 @@ func (m *Memory) parseIntelHexRecord(bytes []byte) error {
222
224
return newParseError (_RECORD_ERROR , err .Error (), m .lineNum )
223
225
}
224
226
m .eofFlag = true
227
+ case _EXTENDED_RECORD :
228
+ //Extended 8086 Segment Record
229
+ m .offset , err = getExtendedSegmentAddress (bytes )
230
+ if err != nil {
231
+ return newParseError (_RECORD_ERROR , err .Error (), m .lineNum )
232
+ }
225
233
case _ADDRESS_RECORD :
226
234
m .extendedAddress , err = getExtendedAddress (bytes )
227
235
if err != nil {
0 commit comments