Skip to content

Commit 6510f80

Browse files
universal-hex: Fix issue in block format converting Extended Segmented Address record to Linear.
Also add tests for the "sections" format.
1 parent 312e125 commit 6510f80

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

src/__tests__/universal-hex.spec.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,31 @@ describe('Test iHexToCustomFormatBlocks()', () => {
268268
expect(resultFFFF).toEqual(expectedFFFF.join(''));
269269
});
270270

271+
it('It converts Extended Segmented Address records to Linear.', () => {
272+
const hexStr32 =
273+
':020000020000FC\n' +
274+
':20F38000257016202EDF70BD002803D00E49C860002070470E207047002803D00A4908617B\n' +
275+
':20F3A000002070470E20704710B507484068002807D08047002803D000221146FFF76CFF3A\n' +
276+
':020000023000CC\n' +
277+
':203F40006A4623C210A82A46FF21808A0C9B02F0F1F9002802D0FFF7A4F8EFE66846007C6C\n';
278+
const expected32 =
279+
':020000040000FA\n' +
280+
':0400000A9903C0DEB8\n' +
281+
':20F3800D257016202EDF70BD002803D00E49C860002070470E207047002803D00A4908616E\n' +
282+
':20F3A00D002070470E20704710B507484068002807D08047002803D000221146FFF76CFF2D\n' +
283+
':020000040003F7\n' +
284+
':203F400D6A4623C210A82A46FF21808A0C9B02F0F1F9002802D0FFF7A4F8EFE66846007C5F\n' +
285+
':2000000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4\n' +
286+
':2000000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4\n' +
287+
':1C00000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4\n' +
288+
':0000000BF5\n';
289+
290+
const result32 = uh.iHexToCustomFormatBlocks(hexStr32, 0x9903);
291+
292+
expect(result32).toEqual(expected32);
293+
expect(result32.length).toEqual(512);
294+
});
295+
271296
it('EoF record placed after an unpadded last block if it fits', () => {
272297
const hexStr =
273298
':020000040000FA\n' +
@@ -861,6 +886,45 @@ describe('Test iHexToCustomFormatSection()', () => {
861886
expect(resultFFFF).toEqual(expectedFFFF.join(''));
862887
});
863888

889+
it('It converts Extended Segmented Address records to Linear.', () => {
890+
const hexStr32 =
891+
':020000020000FC\n' +
892+
':20F2A000C860BFF34F8FFEE70400FA0500ED00E010B5002904D0002211461046FFF7ECFF6F\n' +
893+
':20F2C00000F010F810BD10B50021024A0846FFF761FF10BDB1F2030010B508461146FCF7C3\n' +
894+
':20F2E000C3FF10BDF8B5384C2078002837D02069002807D00026E068002805D00025002E41\n' +
895+
':20F3000004D013E00126F6E70125F8E7684651DF052806D0002806D000221146FFF7BCFF14\n' +
896+
':20F3200004E0012602E0216900988847002D12D1608869460880A06861DF052806D000284D\n' +
897+
':20F3400006D000221146FFF7A7FF04E0012502E0E168A0688847002ED8D0002DCFD0F8BD5F\n' +
898+
':16F3600070B5002901D08C0701D0072070BD164C0125A160628055\n' +
899+
':20F38000257016202EDF70BD002803D00E49C860002070470E207047002803D00A4908617B\n' +
900+
':20F3A000002070470E20704710B507484068002807D08047002803D000221146FFF76CFF3A\n' +
901+
':020000023000CC\n' +
902+
':203F40006A4623C210A82A46FF21808A0C9B02F0F1F9002802D0FFF7A4F8EFE66846007C6C\n';
903+
const expected32 =
904+
':020000040000FA\n' +
905+
':0400000A9903C0DEB8\n' +
906+
':20F2A00DC860BFF34F8FFEE70400FA0500ED00E010B5002904D0002211461046FFF7ECFF62\n' +
907+
':20F2C00D00F010F810BD10B50021024A0846FFF761FF10BDB1F2030010B508461146FCF7B6\n' +
908+
':20F2E00DC3FF10BDF8B5384C2078002837D02069002807D00026E068002805D00025002E34\n' +
909+
':20F3000D04D013E00126F6E70125F8E7684651DF052806D0002806D000221146FFF7BCFF07\n' +
910+
':20F3200D04E0012602E0216900988847002D12D1608869460880A06861DF052806D0002840\n' +
911+
':20F3400D06D000221146FFF7A7FF04E0012502E0E168A0688847002ED8D0002DCFD0F8BD52\n' +
912+
':16F3600D70B5002901D08C0701D0072070BD164C0125A160628048\n' +
913+
':20F3800D257016202EDF70BD002803D00E49C860002070470E207047002803D00A4908616E\n' +
914+
':20F3A00D002070470E20704710B507484068002807D08047002803D000221146FFF76CFF2D\n' +
915+
':020000040003F7\n' +
916+
':203F400D6A4623C210A82A46FF21808A0C9B02F0F1F9002802D0FFF7A4F8EFE66846007C5F\n' +
917+
':2000000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4\n' +
918+
':2000000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4\n' +
919+
':1C00000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4\n' +
920+
':0000000BF5\n';
921+
922+
const result32 = uh.iHexToCustomFormatSection(hexStr32, 0x9903);
923+
924+
expect(result32).toEqual(expected32);
925+
expect(result32.length).toEqual(1024);
926+
});
927+
864928
it('EoF record placed after a fully padded section', () => {
865929
const hexStr =
866930
':020000040000FA\n' +

src/universal-hex.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ function iHexToCustomFormatBlocks(iHexStr: string, boardId: number): string {
7878
} else if (recordType === ihex.RecordType.ExtendedLinearAddress) {
7979
currentExtAddr = record;
8080
} else if (recordType === ihex.RecordType.ExtendedSegmentAddress) {
81-
currentExtAddr = ihex.convertExtSegToLinAddressRecord(record);
81+
record = ihex.convertExtSegToLinAddressRecord(record);
82+
currentExtAddr = record;
8283
} else if (recordType === ihex.RecordType.EndOfFile) {
8384
endOfFile = true;
8485
break;

0 commit comments

Comments
 (0)