Jump to content
  • 0
Sign in to follow this  
Damaniel

Question about switching memory banks

Question

Hopefully this isn't too dumb of a question, but I'm still relatively new to both 6502 assembly and the X16.  I'm doing some experimentation with swapping RAM banks in assembly.  The current documentation states that the RAM bank can be selected by writing the page number to $00 (in zero page), but the way that everyone else is doing it - and the only way that actually works - is to write the page number to $9F61.  Outside of looking at other peoples' source, I haven't found any clue as to why $9F61 is used (other than it being defined as part of the 'other external I/O devices' portion of the memory map).  Which option will be the correct behavior be on actual hardware?

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0
20 minutes ago, Damaniel said:

Hopefully this isn't too dumb of a question, but I'm still relatively new to both 6502 assembly and the X16.  I'm doing some experimentation with swapping RAM banks in assembly.  The current documentation states that the RAM bank can be selected by writing the page number to $00 (in zero page), but the way that everyone else is doing it - and the only way that actually works - is to write the page number to $9F61.  Outside of looking at other peoples' source, I haven't found any clue as to why $9F61 is used (other than it being defined as part of the 'other external I/O devices' portion of the memory map).  Which option will be the correct behavior be on actual hardware?

The difference is that the documentation is effectively referring to emulator r38, which isn't out yet but would be up-to-date with the latest technical design decisions of the X16 if it were. Most people, on the other hand, are programming against emulator r37, where the ROM and RAM banks are selected on register $9F60 and $9F61, respectively.

On real hardware and on future releases of the emulator, $00 and $01 will be correct.

  • Like 3

Share this post


Link to post
Share on other sites
  • 0
58 minutes ago, StephenHorn said:

The difference is that the documentation is effectively referring to emulator r38, which isn't out yet but would be up-to-date with the latest technical design decisions of the X16 if it were. Most people, on the other hand, are programming against emulator r37, where the ROM and RAM banks are selected on register $9F60 and $9F61, respectively.

On real hardware and on future releases of the emulator, $00 and $01 will be correct.

I figured it was something like that.  I'll just make sure my code is structured to be r38 ready.

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)
9 hours ago, Damaniel said:

I haven't found any clue as to why $9F61 is used (other than it being defined as part of the 'other external I/O devices' portion of the memory map).

The previous board design wired the extra address lines in the High RAM to a port in a VIA interface chip. That's the register address of that port. There are eight sets of I/O register addresses at $9F00, $9F20, ... $9FE0, so $9F61 was the $01 register address in the fourth set of I/O register addresses.

 The new design uses dedicated latches for the extra address lines for the High RAM and Flash ROM, and writes the latches at the same time that you write to address $0000 or $0001.

That change frees up one interface chip to provide a User Port.

 

Edited by BruceMcF
  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites
  • 0

Thanks for these answers.  I didn't know the rationale behind these changes... and though I've seen documentation for r38, I scratched my head wondering if it's a typo.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

Please review our Terms of Use