Skip to content

Commit

Permalink
make sure to backstop flashusableend
Browse files Browse the repository at this point in the history
  • Loading branch information
tballmsft committed Feb 27, 2025
1 parent 435accc commit 4e71bbc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pxtcompiler/emitter/hexfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1019,9 +1019,11 @@ ${hexfile.hexPrelude()}
let b = mkProcessorFile(target)
b.emit(src);

let flashUsableEnd = target.flashUsableEnd ? target.flashUsableEnd : target.flashEnd

src = `; Interface tables: ${bin.itFullEntries}/${bin.itEntries} (${Math.round(100 * bin.itFullEntries / bin.itEntries)}%)\n` +
`; Virtual methods: ${bin.numVirtMethods} / ${bin.numMethods}\n` +
b.getSource(!peepDbg, bin.numStmts, target.flashUsableEnd);
b.getSource(!peepDbg, bin.numStmts, flashUsableEnd);

throwAssemblerErrors(b)

Expand Down
2 changes: 1 addition & 1 deletion pxtlib/emitter/assembler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ namespace ts.pxtc.assembler {
let totalEnd = (lenTotal + this.baseOffset - 1) & 0xffffff

if (flashUsableEnd && totalEnd >= flashUsableEnd) {
const e = new Error(lf("program too big by {0} bytes!", totalEnd - flashUsableEnd));
const e = new Error(lf("program too big by {0} bytes!", totalEnd - flashUsableEnd + 1));
(e as any).ksErrorCode = 9283;
throw e;
}
Expand Down

0 comments on commit 4e71bbc

Please sign in to comment.