In article <01b26faa$1acd2480$87d18dce@paulrsm>, "Paul R. Santa-Maria" wrote: > The bank select register is mapped into the //e's memory space at > location $C073 (49267). The programmer can select one of 48 > valid banks by writing the bank number into this location. > (Chapter 7 provides the bank numbers for various memory > configurations.) Once you make the bank selection, soft switches > built into the //e firmware function as they normally would. > This allows data transfer from main memory to auxiliary memory > and vice versa. > Available Banks > > The following subroutine will find all valid banks, determine the > size of RamWorks memory, and save the results into BankTbl. > BankTbl will have the number of 64K banks found, followed by the > table of valid bank numbers. Keep in mind that the bank numbers > are not necessarily linear. For example: 'BankTbl:08 00 01 02 03 > 04 05 06 07'indicates a 512K RamWorks containing banks 0 through 7. > > BankSel EQU $C073 > MaxMem EQU 3*16 ;Maximum desired, 3 megabytes > ;in this example > > *Write bank number to each bank > STA $C009 ;Store in alternate zero page > LDY #$7F ;Valid banks range $00 to $7F > FindBanks > STY BankSel ;Go through each bank > STY $00 ;Store the bank number in $00 > TYA ;Then store bank number EOR'ed > EOR #$FF ;with $FF in $01 for a > STA $01 ;Second self-check > DEY ;do next bank down > BPL FindBanks ;if bank <>00 (last bank handled > ;was bank01) The code is understandable so far. Store $7F in the BankSel softswitch (select the highest possible bank) Store bank number ($7F) in $00 (Alternate Zero Page), EOR bank number with $FF and store it in $01 (Alternate Zero Page) The code will decrement the Y register and loop (until it reaches zero), so next $7E is stored in the BankSel softswitch. It goes from banks $7F to $01 and stores the bank number in $00, and the bank number EOR'ed with $FF in $01. This is then read out from the banks in the below code to see if you can retrieve the bank number and the EOR'ed bank number from the bank... If you can read the correct bank number and EOR'ed version, then the bank is real (It exists, it can be written to and read from)... If what you read from $00 and $01 is not the bank number and EOR'ed version, then you are reading from a bank that doesn't exist. > *Read them back to find valid banks and save in table > LDA #$00 ;start in bank 00 > TAY > TAX > FindThem > STY BankSel ;Search through all banks > STA BankSel+3 Here's where the manual gets a bit fuzzy. BankSel=$C073. What is BankSel+3 ($C076), and what is the purpose for hitting that softswitch? In the first section of code which stored the ID bytes into $00 and $01 of the alternate zero page there was no reference to BankSel+3 when the code was switching through the banks. That is my comment/inquiry. What is BankSel+3 ($c076), what does it do, and why does a programmer have to hit that switch when Reading, and not writing to the extra banks? > CPY $00 ;check bank number (in $00) > BNE NotOne ;If bank number is not in $00, > ;then the bank does not exist. > TYA > EOR #$FF ;EOR the contents of $00 with $FF > ; > CMP $01 ;Check second double-check > BNE NotOne ;not equal to bank# eor'ed with $FF > ;, not a bank > INX ;use to index table > TYA ;Found valid bank-save in table > STA BankTbl,X ;store bank number in table > CPX #MaxMem ;Found all banks to be used > BCS Done > NotOne > INY ;Go through all valid bank ranges > BPL FindThem > *Ending routine > Done > LDA #$00 ;Reset to video bank > STA BankSel > STA $C008 ;use main Zero page (re-set machine ;to 'usable' state. > STX BankTbl ;Size of Ram card > LDA #$FF > STA BankTbl+1,X ;Mark end of table > JMP Continue > > BankTbl DS MaxMem+2 > Continue EQU * Sent via Deja.com http://www.deja.com/ Before you buy.