[Coco] GOTO and code maintainability

John Donaldson johnadonaldson at sbcglobal.net
Tue Sep 8 10:41:50 EDT 2009


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
 


Gene Heskett wrote:
> 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 
> stack housekeeping.
>
> 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.
>
>   
>> John Donaldson
>>
>> 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
>>> colleagues.
>>>
>>> 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
>>> programming?
>>>
>>>                           - Aaron
>>>       
>
>
>   


-- 



More information about the Coco mailing list