djrm wrote: ↑Sat Aug 31, 2024 8:14 am
I tried changing the compre from unsigned to signed and this has improved things in most cases, certainly the bug as described is fixed but there are other faults or side effects too.
A new morning here in NZL.
I'm not sure I agree with changing to a
signed comparison for the X address value.
As I saw it, this is simply a 16-bit overflow problem.
Specifically, I would expect that changing to a signed 16-bit compare would just move the overflow problem from $FFFF to $7FFF ??
The HSDTA routine is written to output lines of 16 memory locations, on a 16 boundary START ADDRESS, until we are higher or same (on each 16 boundary), when compared to the passed END ADDRESS.
Analyzing this issue again this morning, it seems to me that the root issue would be best resolved if both the passed START ADDRESS and END ADDRESS were passed as on a 16 boundary (instead of just the START ADDRESS being on a 16 boundary!).
This logic correctly follows with the function of HSDTA. i.e. Output 16 byte blocks on 16 byte boundaries!
As an example, if you do:
Code: Select all
D F000 10
0 1 2 3 4 5 6 7 8 9 A B C D E F
F000 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
You get the same result (of course), as with:
Code: Select all
D F000 8
0 1 2 3 4 5 6 7 8 9 A B C D E F
F000 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
i.e. One 16 byte block displayed.
Likewise, I notice our "display the reset vectors" issued is resolved simply by self-rounding the specified size up to the next 16 boundary.
Code: Select all
D FFF0 10
0 1 2 3 4 5 6 7 8 9 A B C D E F
FFF0 FF D4 FF D8 FF DC FF E0 FF E4 FF E8 FF EC F8 37 ...............7
All is good!
So, in summary, I'd now probably leave HSDTA as is, and instead go back to CDISP, where I'd round up the retreived COUNT (or END ADDRESS), to the next 16 boundary. This would then align the END ADDRESS passed to HSDTA, with how it currently forces the START ADDRESS to a 16 BOUNDRY!
Doing this would resolve the "runaway wrap-around" issue we currently experience.
I note this however does leave one remaining "possible flaw", being that a specified
Count which causes an
Address Wrap, results in the listing ending early at the top of memory.
e.g.
Code: Select all
D FFE0 40
0 1 2 3 4 5 6 7 8 9 A B C D E F
FFE0 6E 9D BF E8 6E 9D BF E6 6E 9D BF E4 6E 9D BF E2 n...n...n...n...
But, I don't actually see this remaining "possible flaw" as actually a real issue. As there is certainly some logic to not actually wrapping, when displaying to the top of memory.
Note: The wrap does occur if the "wrap-around" Count value is provided with a START ADDRESS in the last 16 bytes of memory, as the first 16 boundary END ADDRESS
comparison happens when X has just overflowed back to zero (so is less than END ADDRESS on first compare).
i.e.
Code: Select all
D FFF0 40
0 1 2 3 4 5 6 7 8 9 A B C D E F
FFF0 FF D4 FF D8 FF DC FF E0 FF E4 FF E8 FF EC F8 37 ...............7
0 1 2 3 4 5 6 7 8 9 A B C D E F
0000 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 UUUUUUUUUUUUUUUU
0010 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 UUUUUUUUUUUUUUUU
0020 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 UUUUUUUUUUUUUUUU
Okay, it's Sunday here, so I should now have my morning coffee and relax.