diff options
Diffstat (limited to '')
| -rw-r--r-- | demo/src/intelhex.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/demo/src/intelhex.ts b/demo/src/intelhex.ts new file mode 100644 index 0000000..ba5d6c8 --- /dev/null +++ b/demo/src/intelhex.ts @@ -0,0 +1,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); + } + } + } +} |
