[Coco] decode as a debugging tool

Wayne Campbell asa.rand at gmail.com
Tue Jun 13 01:44:17 EDT 2017


When I started writing DCom back in the early 90s, I had a vision of a
utility that could become a programming tool, capable of helping to debug
I-Code as well as being able to restore lost source code. I have never lost
that vision, but have recently begun to see its utility in ways I had not
thought about before.

I used decode to look at the I-Code of createDB. I found that the DMA (data
memory allocation) did not validate. Looking at the vars, vdt and dsat
files generated by decode I found that I had one variable dimensioned by
use (a REAL), and a few other variables that had been dimensioned but not
used. It was the unused variables (including two arrays) that caused the
DMA not to validate.The by use REAL was due to me not remembering to add
the variable to the INTEGER dimension statement. If not for using decode, I
might not have ever noticed or found these things. By removing the unused
variables I can make the data storage requirement smaller, and the same
with making the REAL an INTEGER, and that alone will make the code more
efficient.

I know that sometimes it is preferred to keep some unused variables in the
file for future use. My recommendation is one of two things. You can place
those variables in a comment line so they will be kept in the source code
without adding unnecessary data space to the procedure, or you can add
assignment statements to the top of the procedure that will allow the
variables to be seen by decode as used (a reference to the data memory they
occupy). The first saves space, the second uses the extra space but keeps
the variables in the I-Code so that decode will recognize them if/when you
use it.

-- 
Wayne

The Structure of I-Code
http://www.cocopedia.com/wiki/index.php/The_Structure_of_I-Code

decode
http://cococoding.com/wayne/


More information about the Coco mailing list