Difference between revisions of "Talk:TREK7"

From Computer History Wiki
Jump to: navigation, search
(Divide by zero bug; comments)
 
(Effect and cause of "divide by zero" bug added)
Line 2: Line 2:
  
 
The article mentions an "obstinate ... 'divide by zero' problem that has been plaguing the code for decades hindering any successful game". Curiousity is piqued - what was the bug, what were the circumstances that provoked it, and what were the results when it was? (I'm assuming a fatal total failure, for the latter?) It sounds like the code most have been subtracting one quantity from another, and using the difference to divide something - without checking to see if the difference was 0? [[User:Jnc|Jnc]] ([[User talk:Jnc|talk]]) 22:06, 25 March 2023 (CET)
 
The article mentions an "obstinate ... 'divide by zero' problem that has been plaguing the code for decades hindering any successful game". Curiousity is piqued - what was the bug, what were the circumstances that provoked it, and what were the results when it was? (I'm assuming a fatal total failure, for the latter?) It sounds like the code most have been subtracting one quantity from another, and using the difference to divide something - without checking to see if the difference was 0? [[User:Jnc|Jnc]] ([[User talk:Jnc|talk]]) 22:06, 25 March 2023 (CET)
 +
 +
 +
That's what happened:
 +
%SYSTEM-F-FLTDIV_F, arithmetic fault, floating divide by zero at PC=0001060C, PS L=03C00024
 +
%TRACE-F-TRACEBACK, symbolic stack dump follows
 +
 
 +
module name    routine name    line  relative PC  absolute PC
 +
 +
                HORTA              21      0000012C    0001060C
 +
                ATACK              59      00000280    0001A600
 +
                FOR$MAIN          321      00000D3D    0001013D
 +
 +
and the FORTRAN line causing it was:
 +
 +
SINA=FLOAT(ITAR-ISTR)/X
 +
 +
As a first step I put in the line:
 +
 +
IF(X.EQ.0)X=0.1
 +
 +
just before the division takes place to stop division by zero, but that was just a stupid workaround and not the real solution.
 +
 +
About a month later I found the causing bug in subroutine <code>ATACK</code>: <code>IF(MIN.EQ.21)GO TO 106</code> instead of <code>IF(MIN.EQ.21)GO TO 108</code>.
 +
 +
I found it by chance and luck - not by systematic approach ...
 +
 +
So a simple misread jump target caused so much trouble.
 +
 +
There is a lot of "spaghetti code" in the TREK7 sources, which makes understanding and debugging an arduous job! [[User:Vaxorcist|Vaxorcist]] ([[User talk:Vaxorcist|talk]]) 09:20, 26 March 2023 (CEST)
  
 
==Comments==
 
==Comments==
  
 
The mention of scarce comments reminded me about a favourite MIT story about an obscure comment - perhaps the only comment in a program! So, instruction (I don't think it was a line number - this predates BASIC) 1827 had the comment "LVB RIP". What? Eventually (this ''was'' long before the Internet, too :-) the penny dropped - Ludwig van Beethoven died in 1827! Or maybe it was 'JSB RIP' on instruction 1750 - that actually sounds more likely, now that I think about it - old-time hackers were more fans of Bach than Beethoven! I tried to find this story online, but couldn't. I think I read it in an old copy of the Hacker's Dictionary.  [[User:Jnc|Jnc]] ([[User talk:Jnc|talk]]) 22:06, 25 March 2023 (CET)
 
The mention of scarce comments reminded me about a favourite MIT story about an obscure comment - perhaps the only comment in a program! So, instruction (I don't think it was a line number - this predates BASIC) 1827 had the comment "LVB RIP". What? Eventually (this ''was'' long before the Internet, too :-) the penny dropped - Ludwig van Beethoven died in 1827! Or maybe it was 'JSB RIP' on instruction 1750 - that actually sounds more likely, now that I think about it - old-time hackers were more fans of Bach than Beethoven! I tried to find this story online, but couldn't. I think I read it in an old copy of the Hacker's Dictionary.  [[User:Jnc|Jnc]] ([[User talk:Jnc|talk]]) 22:06, 25 March 2023 (CET)
 +
 +
:I wish someone would counter-check my comments on the TREK7 sources and add (at least some of) the ones still missing. [[User:Vaxorcist|Vaxorcist]] ([[User talk:Vaxorcist|talk]]) 09:20, 26 March 2023 (CEST)

Revision as of 08:20, 26 March 2023

Divide by zero bug

The article mentions an "obstinate ... 'divide by zero' problem that has been plaguing the code for decades hindering any successful game". Curiousity is piqued - what was the bug, what were the circumstances that provoked it, and what were the results when it was? (I'm assuming a fatal total failure, for the latter?) It sounds like the code most have been subtracting one quantity from another, and using the difference to divide something - without checking to see if the difference was 0? Jnc (talk) 22:06, 25 March 2023 (CET)


That's what happened:

%SYSTEM-F-FLTDIV_F, arithmetic fault, floating divide by zero at PC=0001060C, PS L=03C00024
%TRACE-F-TRACEBACK, symbolic stack dump follows
 
module name     routine name     line   relative PC  absolute PC

                HORTA              21      0000012C     0001060C
                ATACK              59      00000280     0001A600
                FOR$MAIN          321      00000D3D     0001013D

and the FORTRAN line causing it was:

SINA=FLOAT(ITAR-ISTR)/X

As a first step I put in the line:

IF(X.EQ.0)X=0.1

just before the division takes place to stop division by zero, but that was just a stupid workaround and not the real solution.

About a month later I found the causing bug in subroutine ATACK: IF(MIN.EQ.21)GO TO 106 instead of IF(MIN.EQ.21)GO TO 108.

I found it by chance and luck - not by systematic approach ...

So a simple misread jump target caused so much trouble.

There is a lot of "spaghetti code" in the TREK7 sources, which makes understanding and debugging an arduous job! Vaxorcist (talk) 09:20, 26 March 2023 (CEST)

Comments

The mention of scarce comments reminded me about a favourite MIT story about an obscure comment - perhaps the only comment in a program! So, instruction (I don't think it was a line number - this predates BASIC) 1827 had the comment "LVB RIP". What? Eventually (this was long before the Internet, too :-) the penny dropped - Ludwig van Beethoven died in 1827! Or maybe it was 'JSB RIP' on instruction 1750 - that actually sounds more likely, now that I think about it - old-time hackers were more fans of Bach than Beethoven! I tried to find this story online, but couldn't. I think I read it in an old copy of the Hacker's Dictionary. Jnc (talk) 22:06, 25 March 2023 (CET)

I wish someone would counter-check my comments on the TREK7 sources and add (at least some of) the ones still missing. Vaxorcist (talk) 09:20, 26 March 2023 (CEST)