3 hours ago, Elektron72 said:
Yes; it appears that the current version of MEMTOP assumes that the number of banks must be a power of two.
The behavior I've predicted is actually worse: I think it will report 2048K. After testing for the existence of bank 128 (which will succeed), it will left-shift the value in A, which will cause it to contain zero upon return (side note: a zero in A from MEMTOP indicates 256 banks).
At this point, I think it's clear that the entire MEMTOP routine needs to be rewritten. Someone should open a GitHub issue about this (I might do that later today).
If I put on my computer science hat, I would point out that a binary search has the same time complexity, O(log N), as the current implementation.
If I put on my software engineer hat, I would point out that a binary search is rather a lot of easy-to-get-wrong code just for counting available memory banks.
If I put on my computer engineer hat, I would point out that there is probably a minimum increment that could be checked, probably around 64K, which would significantly reduce the size of a linear search while still getting the right number.
Having close to zero 6502 experience, I'm not the right person to fix it in any case
?