MEGA65 / mega65-rom-public

MEGA65 ROM public issue reporting
4 stars 0 forks source link

BSAVE of Memory Location over $FFFF Breaks Monitor Loads and Saves #96

Closed johnwayner closed 7 months ago

johnwayner commented 7 months ago

Test Environment (required)

Describe the bug Saving memory with BSAVE causes subsequent Load/Verify/Save commands using BSMON to fail. The upper 2 bytes of the address saved persist and are applied to the BSMON commands.

This will actually break any usage of the KERNAL LOAD or SAVE functions if those callers do not manually set specific zero page locations before making the call. BSMON is just the easiest way to demonstrate the fact that BSAVE isn't cleaning up after itself.

To Reproduce

  1. Save some high memory location using BSAVE

    BSAVE"BS2",P($8000000) TO P($8000010)
  2. Enter the Monitor

  3. Load that same file (or any file really) to a location below $FFFF (I have another bug I'll be filing soon to deal with BSMON load/save issues to addresses over $FFFF).

    L"BS2",8 8000
  4. Inspect memory to see that the memory stored into the file was not loaded to the address specified:

    M8000 8010
  5. Inspect memory at the address it was actually loaded (use the higher 2 bytes from the BSAVE command):

    M8008000 8008010

Expected behavior Addresses used by BSAVE should have no impact on future calls the KERNAL Load and Save functions.

Screenshots Bad behavior:

Screenshot 2023-11-14 at 2 13 23 PM

Expected behavior:

Screenshot 2023-11-14 at 2 04 04 PM

Additional context BLOAD doesn't have this issue because it clears the higher bytes of EAL (the zero page location used to store the load address). BSAVE should do this for SAL and EAL (the start and end addresses), but it doesn't.