[Color Computer] [Coco] Bug in FOR NEXT ?

William Astle lost at l-w.ca
Sat Jun 3 12:02:47 EDT 2006


Roger Taylor wrote:
> At 05:31 AM 6/3/2006, you wrote:
>> On 6/3/06, Willard Goosey <goosey at virgo.sdc.org> wrote:
>>> >Date: Thu, 1 Jun 2006 17:59:41 -0500
>>> >From: Frank Pittel <fwp at deepthought.com>
>>> >
>>> >I always that the loop counter was "undefined" outside the loop.
>>>
>>> That's a Pascal-ism, actually.
>>>
>>> The thing that surprised ME when I ran across it in BASIC is that
>>> FOR-NEXT loops always go through the loop at least once, even in cases
>>> like:
>>> 10 A=0
>>> 20 FOR B=1 TO A
>>> 30 REM DO SOMETHING
>>> 40 NEXT B
>>>
>>> Willard
>>> -- 
>> Yes, it's not obvious that the test is made in the NEXT statement, not
>> in the FOR statement. That's caught quite a few people. The Pascal
>> "Repeat ... Until" and "While" statements make it a bit more obvious
>> where the test is going to occur.
>>
>> Ken
> 
> 
> Before the CoCo 3, I used to add my own commands to BASIC and Extended
> BASIC.  In fact, before I had an Extended BASIC CoCo, I would try to
> create some of the ECB commands and add them to Color BASIC.  If I could
> just recover all of my old cassette tapes I would find stuff like this
> including a huge set of commands I wrote that I would call Super BASIC
> or something like that.  In other words, my own custom set of BASIC
> commands that were not available in any CoCo.  Time has gone by and I've
> forgotten all of them, but I had some neat ones.
> 
> I'm not sure if there is room in a CoCo 3 for more commands (if not,
> maybe a few unused one could be overwritten), but it would be easy to
> add new ones to BASIC and ECB/Disk BASIC.
> 
> Maybe somebody could create a REPEAT/UNTIL and WHILE/ENDWHILE set of
> commands and offer this as a LOADMable binary or a BASIC program that
> does the entire patch including the switch the all-RAM mode if needed, etc.

There's room for a half dozen or so in the regular command tokens.
Someone actually did use them for a few commands. It appeared in a
Rainbow magazine at one point. (REPEAT/UNTIL, BEEP, and a couple others).

In the CC3, however, it is possible to add a fair bit of stuff to basic
with a few tricks. One is to trap the decode of secondary tokens and
then use some of them as commands, similar to how Extended Basic traps
it for the TIMER= command. And, you can put most of the code for this
stuff in the left over space from the broken DLOAD command, at the top
of the DISK ROM, at the top of the CC3 basic, and so on. It can even be
LOADMable that way. I remember doing this at one point.

Now the classic method of adding commands no longer works in the CC3 but
since the CC3 runs in RAM mode already, you can actually just patch over
what you need to.

IIRC, the trick to getting everything installed correctly from a LOADM
is using a multi-block binary file that loads at different addresses.
You then load all your code to the addresses where it will live and then
an initialization routine that, for example, traps the command
interpretation loop and runs the initialization then restores the
command interpretation loop to its original code. (You probably would
want to do it this way to prevent funky stuff happening with interrupts
or borking the loading process in the middle or what have you.)

-- 
William Astle
finger lost at l-w.net for further information

Geek Code V3.12: GCS/M/S d- s+:+ !a C++ UL++++$ P++ L+++ !E W++ !N w---
!D !M PS PE V-- Y+ PGP t+@ 5++ X !R tv+@ b+++@ !DI D? G e++ h+ y?



More information about the Coco mailing list