[Coco] GOTO and code maintainability

Gene Heskett gene.heskett at verizon.net
Tue Sep 8 13:00:15 EDT 2009


On Tuesday 08 September 2009, John Donaldson wrote:
>Gene,
>   I agree with your logic. The problem I see is that almost ALL
>assemblers on,  what ever processor it runs on has both these commands.
>Even the old PDP8/11's I use to program on had them. I question is "If
>they are so BAD why were they invented in the first place and why does
>even the  MSDOS assembler still have them. I would have thought that
>assemblers would have evolved to the point that  you did not  need them
>anymore.
>
>John Donaldson

Chuckle, I too have to admit that it has been occasionally difficult to do 
something without a goto in both C or B09.

But goto's aren't known by that name in assembler.  Stack housekeeping in 
assembly makes lots of folks write code that is actually bigger because they 
don't make use of re-usable subroutines.  Some of my later stuff does do 
this, and because its re-usable code, the executable is smaller.  The call 
overhead can make it slower if used to excess like is done in rzsz for the 
crc checking.  I'll get to that again below.

But a nights sleep on the problem usually gives me an idea of how to re-
arrange the code that is actually a more readable format and that makes the 
need for the goto disappear.  Not always of course, but often enough the 
phenomena has gotten my attention.  Whether that works for others or not 
depends on the individuals thought/dream processes I think.

Our C compiler (using cprep19 and with all the accessory utils, like 
ansifront.12, cnoy, copt2 etc) can generally deal with a goto if the src code 
stays under 30k or so, and this was an area I only ran into once, in rzsz.  
It did have size limits of course although the improvements I made to the 
last, cprep19 preprocessor module of it were sufficient to allow me to build 
rzsz-3.36 with it, and that total src was a bit over 34k for either rz or sz 
IIRC.  I don't recall if there were goto's used in Chuck Foresbergs rzsz code 
or not, too many years since I last built that particular utility.  Its on 
rtsi, or was at one time.  If not there now, let me know and I'll see if I 
can send it up again,  I know it works flawlessly between the coco3 and this 
linux boxes version of sz or rz when I'm logged into it with minicom from 
here.

This is a file moving utility that really could use some help, it still does 
the crc calculations a byte at a time, and it should not.  Using the table 
lookup crc function (that BTW doubled its cps speed), it really should only 
do this once for every 256 byte block sent.  I think that would enhance its 
speed quite a bit, which on a stock coco is just over 450 cps on any 
connection speed above 4800, rising to about 725 cps on a nitros9/6309 
machine using a 9600 baud setting.  By doing the crc check as a single call 
that looped over the buffer without all that call overhead, I'd think that 
1000 cps on a 6809 coco might be reachable, and 1500 cps or better on a 
6309/nitros9 machine.

OTOH, like kermit, it can by diligent effort, move a perfect copy of a file 
over a 40 mile stretch of un-insulated, wet barbed wire fence if it had to.  
Both of those protocols were designed to work over less than perfect analog 
circuits from the ground up.  It takes a really broken phone circuit, one you 
almost couldn't talk over to make rzsz actually give up.

One other thing about that rzsz code, it checks to see by what name it was 
invoked, and will switch to xmodem or ymodem protocols if invoked as sx or 
sy!  They aren't nearly as robust a protocol, but with a good circuit...

So one can use a disk editor (dEd) to make directory entries that are named 
sx, sy that actually point to the sz executable's fd sector in the last 3 
bytes of the directory entry, ditto for rx & ry.  Just don't forget to add 
$20 to the length of the directory for each such link created, and increment 
the link count in the fd sector for the file.  I was always going to write a 
utility to do that, but never got a round tuit, my fault of course, an amiga 
got in the way.

Os9/nitros9 handles what is called a hardlink in linux flawlessly as long as 
the link counts in the fd are maintained, unless someone has removed that 
code, not knowing what it was for.

FWIW, I exercised those xmodem and ymodem protocols too before uploading it 
all those years ago.  They work.

I suspect that the hardlink ability is a little known fact about os9 though. 
:)

Your trivia facts for the day. :)

[...]

-- 
Cheers, Gene
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
The NRA is offering FREE Associate memberships to anyone who wants them.
<https://www.nrahq.org/nrabonus/accept-membership.asp>

Truthful, adj.:
	Dumb and illiterate.
		-- Ambrose Bierce, "The Devil's Dictionary"



More information about the Coco mailing list