Skip to content

Commit be2a6be

Browse files
committed
Support different lenght of extended address
1 parent baab252 commit be2a6be

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

gohex.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import (
99

1010
// Constants definitions of IntelHex record types
1111
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
15+
_ADDRESS_RECORD byte = 4 // Record with extended linear address
16+
_START_RECORD byte = 5 // Record with start linear address
1617
)
1718

1819
// Structure with binary data segment fields
@@ -222,6 +223,9 @@ func (m *Memory) parseIntelHexRecord(bytes []byte) error {
222223
return newParseError(_RECORD_ERROR, err.Error(), m.lineNum)
223224
}
224225
m.eofFlag = true
226+
case _EXTENDED_RECORD:
227+
//Extended 8086 Segment Record
228+
fallthrough
225229
case _ADDRESS_RECORD:
226230
m.extendedAddress, err = getExtendedAddress(bytes)
227231
if err != nil {

helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func getExtendedAddress(bytes []byte) (adr uint32, err error) {
5252
if binary.BigEndian.Uint16(bytes[1:3]) != 0 {
5353
return 0, errors.New("incorrect address field in extended linear address line")
5454
}
55-
adr = uint32(binary.BigEndian.Uint16(bytes[4:6])) << 16
55+
adr = uint32(binary.BigEndian.Uint16(bytes[4:6])) << (1 << bytes[3])
5656
return adr, nil
5757
}
5858

0 commit comments

Comments
 (0)