[Coco] GOTO and code maintainability
gene.heskett at verizon.net
Mon Sep 7 22:43:55 EDT 2009
On Monday 07 September 2009, John Donaldson wrote:
>Is not a GOTO the same thing as a JMP or BRA command in Assembly??? I
>have used JMP and BRA commands many times in Assembly programs.
Essentially yes, John. The problem hits when you have executed a BSR to go
hit a subroutine, which puts the return addy on the stack. You subroutine
may also use the stack for anything it wants to save or reference later.
Your subroutine is done so you do a return. That is fine _unless_ the
subroutine didn't clean up the stack. If data is left on the stack, then the
return op will pull that data and stick in the program counter and off to
byby land you go. 99% of any programs crashes are, I would wager, faulty
I learned a lot writing in assembly, and the first lesson, 100x more
important than any other, is that the coder, and the coder alone, is
responsible for stack housekeeping.
'vfy' is as stable as I could make it, I spent the last month after getting
the code correct, sticking calls to os9p4, aka F$regdump in it to trace the
fact that the stack was what I thought it was regardless of the paths
actually taken as that code executed.
If anyone has ever made it crash, I want to hear about it. I haven't so far.
>Aaron Banerjee wrote:
>> All of us have at least at one point in time either used, or tried to
>> figure out code containing GOTO statements. In a recent programming
>> environment I was in, GOTO (or it's equivalent in whatever language we
>> happened to be programming) was expressly forbidden -- no exceptions
>> no matter what.
>> Just to be an irritant, I chucked a single GOTO (to make a polling
>> loop) in a relatively simple program, which totally confused my
>> Given that it isn't abused, I don't see why GOTO makes code any less
>> maintainable than other obviscation techniques, such as polymorphism
>> (which, while useful, if abused can lead to very multiple inheritance
>> or exception-based program control. At least GOTO tells you where it
>> is going....
>> Has anyone else run into this type of "GOTO intolerance" while
>> - Aaron
"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.
A good scapegoat is hard to find.
A guilty conscience is the mother of invention.
-- Carolyn Wells
More information about the Coco