[Coco] 6809 example

William Astle lost at l-w.net
Sat Jan 17 04:41:46 EST 2004


Apologies if I misquoted anyone. I reordered the comments so it flowed
sensibly.

On Sat, 17 Jan 2004, Robert Gault wrote:

> Bob Emery wrote:
> > --- Robert Gault <robert.gault at worldnet.att.net> wrote:
<snip>
> >>10 WIDTH32: FOR I=0TO511:POKEI+&H400,RND(0)*9+48:NEXT
> >>20 REM BUBBLE SORT
> >>30 FORX=&H400 TO &H5FE
> >>40 A=PEEK(X):B=PEEK(X+1):IF B>A THEN POKEX,B:POKEX+1,A:Y=1
> >>60 NEXT
> >>70 PASS=PASS+1
> >>80 IF Y<>0 THEN 30
> >>90 GOTO 90
<snip>
> > Shouldn't there be a Y=0: at the beginning of line 30? ;-)
> > Otherwise PASS will always max out since the flag isn't being reset.
<snip>
> No, because Disk Basic always zeros out variable on RUN. If you jump
> into the middle of a program with GOTOxyz there might be a problem. In
> any case, that is a point I was trying to make in this comparison. High
> level languages take care of initial conditions and loop counters
> (amongst other things), low level languages don't.

Actually, Y is the "changed" flag, right? If you don't reset it between
passes, every pass will end with the flag set. You'll never break out of
the sorting passes until something triggers a runtime error or the user
breaks the program.

For the record, the program will give exactly the same visual as with the
flag reset between passes, though.

-- 
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--- !O
!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