Difference between revisions of "Testing for sideways RAM"
(Initial page.) |
m (Slight formatting changes.) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Category:6502]][[Category:Programming]] | [[Category:6502]][[Category:Programming]] | ||
− | The standard way to test if a sideways ROM/RAM bank contains RAM is to try to | + | The standard way to test if a sideways ROM/RAM bank contains RAM is to try |
− | change the binary version number at &8008. If you can change it, it must be RAM, | + | to change the binary version number at &8008. If you can change it, it must |
− | if you can't change it, it must be ROM (or empty). You use the binary version | + | be RAM, if you can't change it, it must be ROM (or empty). You use the |
− | number as that is defined as only ever displayed and not affecting the operation | + | binary version number as that is defined as only ever displayed and not |
− | of any code. For example, if you changed &8000 and the test code failed to | + | affecting the operation of any code. For example, if you changed &8000 and |
− | restore it (eg, Break was pressed) then you would be left with non-functioning | + | the test code failed to restore it (eg, Break was pressed) then you would be |
− | code at &8000. | + | left with non-functioning code at &8000. |
===Testing for sideways RAM=== | ===Testing for sideways RAM=== | ||
Line 21: | Line 21: | ||
.RomTestDone | .RomTestDone | ||
− | The test is done twice as with some systems the data bus floats so that an empty | + | The test is done twice as with some systems the data bus floats so that an |
− | ROM socket looks like it is RAM. Testing twice and testing a different location | + | empty ROM socket looks like it is RAM. Testing twice and testing a different |
− | allows the data bus to settle so an empty socket is seen as empty. | + | location allows the data bus to settle so an empty socket is seen as empty. |
− | This routine finishes with Y holding 0,1 for ROM,RAM, giving zero for non-writable | + | This routine finishes with Y holding 0,1 for ROM,RAM, giving zero for |
− | memory and non-zero for writable memory. | + | non-writable memory and non-zero for writable memory. |
===Testing for EEPROM=== | ===Testing for EEPROM=== | ||
− | + | It is possible to use EEPROMs (Electrically Erasable Programmable ROMs) with | |
− | Programmable ROMs) with BBCs/Masters/Electrons. | + | BBCs/Masters/Electrons, |
+ | <ref>[http://mdfs.net/Archive/BBCMicro/2008/07/24/144852.htm EEPROM writing in SW rom bank?]</ref> | ||
<ref>[http://www.stardot.org.uk/forums/viewtopic.php?f=3&t=7393 EEPROM - the Holy Grail of Sideways Rom?]</ref> | <ref>[http://www.stardot.org.uk/forums/viewtopic.php?f=3&t=7393 EEPROM - the Holy Grail of Sideways Rom?]</ref> | ||
<ref>[http://www.stardot.org.uk/forums/viewtopic.php?f=3&t=6280 P.R.E.S. New and Original AP6]</ref> | <ref>[http://www.stardot.org.uk/forums/viewtopic.php?f=3&t=6280 P.R.E.S. New and Original AP6]</ref> | ||
− | + | but when testing when EEPROM is present you have to be careful as whenever a | |
− | made to the EEPROM it effectively vanishes for 20,000 instruction cycles while it | + | write is made to the EEPROM it effectively vanishes for 20,000 instruction |
− | processes the write. | + | cycles while it processes the write. |
<ref>[http://www.atmel.com/images/doc0006.pdf AT28C256 32Kx8 EEPROM data sheet]</ref> | <ref>[http://www.atmel.com/images/doc0006.pdf AT28C256 32Kx8 EEPROM data sheet]</ref> | ||
− | So, you must make sure that the EEPROM isn't inadvertantly called during this | + | So, you must make sure that the EEPROM isn't inadvertantly called during |
− | write process and must wait until the write process finishes and the EEPROM | + | this write process and must wait until the write process finishes and the |
− | contents are visible again. | + | EEPROM contents are visible again. |
\ Code to test for sideways RAM or EEPROM | \ Code to test for sideways RAM or EEPROM | ||
Line 49: | Line 50: | ||
LDY #0 :\ Preload Y=0 for ROM | LDY #0 :\ Preload Y=0 for ROM | ||
LDA &8008:EOR #&AA:STA &8008 :\ Modify version byte | LDA &8008:EOR #&AA:STA &8008 :\ Modify version byte | ||
+ | NOP :\ Wait for floating bus to settle | ||
CMP &8008:PHP :\ EQ=RAM, NE=ROM/EEPROM/empty | CMP &8008:PHP :\ EQ=RAM, NE=ROM/EEPROM/empty | ||
EOR #&AA:STA &8008 :\ Restore byte | EOR #&AA:STA &8008 :\ Restore byte | ||
Line 61: | Line 63: | ||
PLP :\ Restore IRQs | PLP :\ Restore IRQs | ||
− | This routine finishes with Y holding 0,1,2 for ROM,RAM,EEPROM, giving zero for | + | This routine finishes with Y holding 0,1,2 for ROM,RAM,EEPROM, giving zero |
− | non-writable memory and non-zero for some form of writable memory. Other values | + | for non-writable memory and non-zero for some form of writable memory. Other |
− | could be used, for example the AP6 support ROM uses 0, 'R' and 'E'. | + | values could be used, for example the AP6 support ROM uses 0, 'R' and 'E'. |
==References== | ==References== |
Latest revision as of 17:55, 12 November 2017
The standard way to test if a sideways ROM/RAM bank contains RAM is to try to change the binary version number at &8008. If you can change it, it must be RAM, if you can't change it, it must be ROM (or empty). You use the binary version number as that is defined as only ever displayed and not affecting the operation of any code. For example, if you changed &8000 and the test code failed to restore it (eg, Break was pressed) then you would be left with non-functioning code at &8000.
Testing for sideways RAM
\ Code to test for sideways RAM \ ----------------------------- \ This code must run from main memory \ The bank to be tested must be paged in \ Returns Y=0,1 for ROM,RAM LDY #0 :\ Preload Y=0 for ROM LDA &8008:EOR #&AA:STA &8008 :\ Modify version byte CMP &AAAA:CMP &8008:BNE RomTestDone :\ NE=ROM or empty EOR #&AA:STA &8008 :\ Restore byte INY :\ Y=1 for RAM .RomTestDone
The test is done twice as with some systems the data bus floats so that an empty ROM socket looks like it is RAM. Testing twice and testing a different location allows the data bus to settle so an empty socket is seen as empty.
This routine finishes with Y holding 0,1 for ROM,RAM, giving zero for non-writable memory and non-zero for writable memory.
Testing for EEPROM
It is possible to use EEPROMs (Electrically Erasable Programmable ROMs) with BBCs/Masters/Electrons, [1] [2] [3] but when testing when EEPROM is present you have to be careful as whenever a write is made to the EEPROM it effectively vanishes for 20,000 instruction cycles while it processes the write. [4] So, you must make sure that the EEPROM isn't inadvertantly called during this write process and must wait until the write process finishes and the EEPROM contents are visible again.
\ Code to test for sideways RAM or EEPROM \ --------------------------------------- \ This code must run from main memory \ The bank to be tested must be paged in \ Returns Y=0,1,2 for ROM,RAM,EEPROM PHP:SEI :\ Disable IRQs, prevent background ROM calls LDY #0 :\ Preload Y=0 for ROM LDA &8008:EOR #&AA:STA &8008 :\ Modify version byte NOP :\ Wait for floating bus to settle CMP &8008:PHP :\ EQ=RAM, NE=ROM/EEPROM/empty EOR #&AA:STA &8008 :\ Restore byte .RomTestLp LDA &8008:EOR &8008:BEQ RomTestOk :\ Bytes match ASL A:BPL RomTestOk :\ Empty socket, bit 6 not toggling LDY #2:BNE RomTestLp :\ Toggling, must be EEPROM/empty, Y=2 .RomTestOk PLP:BNE RomTestNotRam :\ NE from earlier, ROM or EEPROM or empty LDY #1 :\ EQ from earlier, must be RAM, Y=1 .RomTestNotRam PLP :\ Restore IRQs
This routine finishes with Y holding 0,1,2 for ROM,RAM,EEPROM, giving zero for non-writable memory and non-zero for some form of writable memory. Other values could be used, for example the AP6 support ROM uses 0, 'R' and 'E'.