mirror of https://git.sr.ht/~rabbits/uxn
Browse Source
Unchecked `.System/expansion` commands can cause segmentation faults. We should of course reject banks >= `RAM_PAGES`, but we also have to account for addresses pointing past the end of the (last) bank. For this, we have several options: - Clamp the address to the end of the memory. - Clamp the address to the end of the bank. - Wrap the address to stay in the same bank. I chose wrapping to make expansion banks easiest to implement on 16-bit machines and when memory banks are not contiguous. Wrapping is also how `STA` and `LDA` are implemented. Since out-of-bounds banks are now ignored. ROMs can write a byte to a memory bank and read it back to detect if the bank exists. This also fixes an unintuitive off-by-one in the `cpyr` command that caused the `system.expansion.tal` example to break.main
2 changed files with 28 additions and 14 deletions
Loading…
Reference in new issue