mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-23 22:35:11 +00:00
(uxnasm) Raise error when memory is overwritten.
This commit is contained in:
parent
da4f0e70a5
commit
8b84813c6e
1 changed files with 5 additions and 0 deletions
|
@ -193,6 +193,10 @@ writebyte(Uint8 b)
|
|||
fprintf(stderr, "-- Writing in zero-page: %02x\n", b);
|
||||
return 0;
|
||||
}
|
||||
else if(p.ptr < p.length) {
|
||||
fprintf(stderr, "-- Memory overwrite: %04x -> %04x\n", p.length, p.ptr);
|
||||
return 0;
|
||||
}
|
||||
p.data[p.ptr++] = b;
|
||||
p.length = p.ptr;
|
||||
litlast = 0;
|
||||
|
@ -213,6 +217,7 @@ writelitbyte(Uint8 b)
|
|||
if(litlast) { /* combine literals */
|
||||
Uint8 hb = p.data[p.ptr - 1];
|
||||
p.ptr -= 2;
|
||||
p.length = p.ptr;
|
||||
return writeshort((hb << 8) + b, 1);
|
||||
}
|
||||
if(!writebyte(findopcode("LIT"))) return 0;
|
||||
|
|
Loading…
Reference in a new issue