ASSEMBLY LANGUAGE PROGRAMMING PART ONE: 512K OR 128K? Have you ever wanted to be able to detect how much memory was in a CoCo3 so as to avoid asking that annoying question, "Is this a 512K machine?"? If so, this article may solve that problem. In order to be able to detect the amount of memory in a CoCo3 one must know something about the MMU. In a 128K CoCo3 the 128K is mirrored in four places, blocks $00-$0F, blocks $10-$1F, blocks $20-$2F, and blocks $30-$3F. This means that physical addresses $00000, $20000, $40000, and $60000 will always contain that same value on a 128K CoCo3 while they will contain different values (potentially) on a 512K CoCo3. You can probably imagine by now the basic outline of how we can detect whether a CoCo3 has 128K or 512K. We can just write a value to physical memory $00000 as see if it shows up in physical memory $60000. In theory that will work but what if it is a 512K machine which just happens to have the value you wrote to $00000 in $60000. This would then return an incorrect result. To get around this problem, we could write one value to $00000 then write a different value to $60000. Then, if the value from $60000 shows up in $00000 we know that the result is accurate. (We will assume that the machine doesn't have a weird amount of memory like 256K since those are not standard) The file PART1.ASM contains some code I cobbled together to accomplish the task just described. The code may be a bit difficult to follow so I'll describe the basic flow. First, I saved the registers I use on the stack. I then proceeded to disable interrupts so the computer didn't crash when the procedure runs. I then put memory block $00 into logical block 0 and put memory block $30 into logical block 1. I then get the contents of $00000 and $60000 and save them so I can restore the contents of memory later. Next, I store a 0 in $00000 and then store a $55 in $60000. I then check $00000 if to see if it is $55. If it is then I assume that we have a 128K machine. Otherwise, I assume that it is a 512K machine. Once that is determined, I set the carry flag for 512K machine and clear it for a 128K machine. I also restore the contents of the memory locations and reenable the interrupts after restoring the MMU registers to their original state. I then restore the registers I used and return to the calling procedure. The listing is commented to a degree and a little study of it should reveal how it works. I do not claim that this is the best way to do this, but I am pretty certain that it works. The program can be assembled and executed from basic if you include the following at the end: 00400 START BSR GMSIZE 00410 BCC START0 00420 LDD #512 00430 BRA START1 00440 START0 LDD #128 00450 START1 JMP $BDCC 00460 END START This prints the size of memory detected on the screen. This should also illustrate how to use the subroutine. Until next time, have fun.