!pr1
Finding Memory Size in ProDOS..............Bob Sander-Cederlof

On page 6-63 of Beneath Apple ProDOS there is a small piece of code designed to determine how much memory there is:

       LDA $BF98
       ASL
       ASL
       BIT 0
       BPL SMLMEM      48K
       BVS MEM128      128K
       ...             otherwise 64K

The code will not work.  The BIT 0 will test bits 7 and 6 of memory location $0000, which have nothing whatsoever to do with how much memory is in your machine.  What was intended was to test bits 7 and 6 of the A-register, or in other words bits 5 and 4 of $BF98.  Here is one way you can do that:

       LDA $BF98
       ASL
       ASL
       ASL
       BCC SMLMEM      48K
       BMI MEM128      128K
       ...             OTHERWISE 64K

Notice that not only does this perform the test correctly, it is also one byte shorter!

If you insist on using the same number of bytes, here is another way to test those bits:

       LDA $BF98
       AND #%00110000  ISOLATE BITS 5 AND 4
       CMP #%00100000
       BCC SMLMEM      48K
       BNE MEM128      128K
       ...             OTHERWISE 64K

If any of you have discovered any other problems with the sample code in this book, pass them along.
