blob: ba5d6c8cbf6a8d6632813eff1d0d5265200c667d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
/**
* Minimal Intel HEX loader
* Part of AVR8js
*
* Copyright (C) 2019, Uri Shaked
*/
export function loadHex(source: string, target: Uint8Array) {
for (const line of source.split('\n')) {
if (line[0] === ':' && line.substr(7, 2) === '00') {
const bytes = parseInt(line.substr(1, 2), 16);
const addr = parseInt(line.substr(3, 4), 16);
for (let i = 0; i < bytes; i++) {
target[addr + i] = parseInt(line.substr(9 + i * 2, 2), 16);
}
}
}
}
|