Determining if a CoCo has 32KiB or 64KiB RAM
From Wikistix
Since the question has come up a few times, and CoCo's with 32KiB RAM do apparently exist, the following program should determine if your Tandy Color Computer really has only 32KiB or the full 64KiB RAM.
10 CLEAR200,&H7DFF
20 A=&H7E00
30 FOR I=0TO50:READB$:POKEA+I,VAL("&H"+B$):NEXTI
40 DEFUSR0=&H7E00
50 IFUSR0(0)=0THENPRINT"32K"ELSEPRINT"64K"
60 DATA7F,FF,DF,30,8D,00,2B,86
70 DATAFF,6F,84,A7,89,80,00,6D
80 DATA84,26,15,30,89,80,00,6F
90 DATA84,6D,84,26,0B,A7,84,A1
100 DATA84,26,05,CC,00,FF,20,03
110 DATACC,00,00,7F,FF,DE,BD,B4
120 DATAF4,39,00
The ML routine works by first hiding the ROM, then checking that the upper 32KiB RAM is not just mirrored from the lower 32KiB RAM (which is the case in xroar). It then also checks that the upper RAM can hold a zero or 255 value. The one physical 32KiB machine I'm aware of returned 255 ($ff) for all bytes in the upper 32KiB.
( 64ktest.asm):00001 org $7e00
7E00 7FFFDF ( 64ktest.asm):00002 clr $ffdf
7E03 308D002B ( 64ktest.asm):00003 leax byte,pcr
7E07 86FF ( 64ktest.asm):00004 lda #$ff
7E09 6F84 ( 64ktest.asm):00005 clr ,x
7E0B A7898000 ( 64ktest.asm):00006 sta $8000,x
7E0F 6D84 ( 64ktest.asm):00007 tst ,x
7E11 2615 ( 64ktest.asm):00008 bne k32
7E13 30898000 ( 64ktest.asm):00009 leax $8000,x
7E17 6F84 ( 64ktest.asm):00010 clr ,x
7E19 6D84 ( 64ktest.asm):00011 tst ,x
7E1B 260B ( 64ktest.asm):00012 bne k32
7E1D A784 ( 64ktest.asm):00013 sta ,x
7E1F A184 ( 64ktest.asm):00014 cmpa ,x
7E21 2605 ( 64ktest.asm):00015 bne k32
7E23 CC00FF ( 64ktest.asm):00016 ldd #$ff
7E26 2003 ( 64ktest.asm):00017 bra bas
7E28 CC0000 ( 64ktest.asm):00018 k32 ldd #0
7E2B 7FFFDE ( 64ktest.asm):00019 bas clr $ffde
7E2E BDB4F4 ( 64ktest.asm):00020 jsr $b4f4
7E31 39 ( 64ktest.asm):00021 rts
7E32 00 ( 64ktest.asm):00022 byte fcb 0