[Coco] Basic09 discompiler ?

Wayne Campbell asa.rand at gmail.com
Thu Apr 29 19:58:15 EDT 2021


Decode tries to deal with complex types. But there are many issues.
Fortunately, the registers type is fairly easy. If it's the only type
statement in your code all you have to do is simply reconstruct it. You can
tell by where you made the call as to which register you were using.
Typically, the register packet will only have used A and B of the byte
registers and X and Y of the integer registers. So if your type statement
in the resulting output of decode shows one or two byte fields and or one
or two integer fields, you can pretty much bet that it's A and B on the
byte fields and X and Y on the integer fields. Also, you can determine
which integer or byte variable was used to hold the call code by looking at
the statement that assigns the call code to the variable.

If you want, I can go into detail about the problem with the type
statements and why decode does not properly deal with them, but that may be
more than you care to know.

What I usually do when I run into the registers type is simply replace the
generic code produced by decode with:

TYPE REG=cc,a,b,dp:BYTE; x,y,u:INTEGER
DIM regs:REG

Then I go to where I make a system call and change the references to the
generic variable that was created by decode to whatever the register is
that is being used, for example

C0001.b001 becomes
regs.a

and C0001.i003 becomes
regs.u

The actual generic variable names may be different from these examples. It
depends on the order in which the variable was defined in decode.

Also, if you're not sure which register was used, such as maybe register U
was used, you can always check the reference to see which register is
defined in the system call that was being made.

Yes, this does involve a little bit of work. But to me it's much easier
than trying to rewrite the code, and somewhat easier than trying to modify
an old version of the code to match the newer version. As I said, your
instructions will be correct. There may be a few exceptions where a
particular bug has not occurred yet and I don't know about it to fix it.
But as far as I know, all of the instructions will be properly constructed.
The only problems are with the type statements.

There is one other thing. I have found that it is common to accidentally
name a variable incorrectly in your code and not notice it. As a result,
you end up with variables that are REAL type where the original variable
was a integer or a byte, or even another real. Decode can help you find
those because it dimensions every variable that it finds. And basic09 you
can define a variable by use, meaning that you do not have to create a
dimension statement for it. If the variable has a dollar sign as the last
character, it is automatically created as a 32 character STRING. If it does
not have a dollar sign as the last character it is automatically created as
a 5 byte REAL.

I have discovered many such errors in the modules I used for testing. Most
of the time these things go unnoticed because the error just doesn't show
up. Sometimes it's about a wrong value showing up but nobody can figure out
where it is. Decode finds it because it defines a dimension statement for
that real variable that wasn't in the original code. For that reason, you
can use decode to decode your source code and then compare the dimension
statements in the original source to the dimension statements in the
constructed source to find out if you've actually created any problem
variables. If it turns out there are some variables that weren't in your
original code, then you know you have defined one or more variables
incorrectly. This was a much more common problem when we had to do
everything on the color computer and basic09's editor. It was not so easy
to spot the errors when no error code was generated.

On Thu, Apr 29, 2021, 11:24 AM <coco at jechar.ca> wrote:

>
> After viewing your youtube video I think perhaps that I will have no
> luck with decode because I do have source of an older non working
> version
> and one of the lines is.
>
> TYPE registers=cc,a,b,dp:BYTE;x,y,u:INTEGER
>
> And in your video says that you do not support Complex "TYPE" commands.
>
> If that has changed since you created the video let me know.
>
> On 2021-04-28 22:12, Wayne Campbell wrote:
> > Decode does work, but it does have caveats. It does not deal with type
> > statements correctly, and all of the variable names are generic and
> > follow
> > the format variable type followed by a number. For example, a byte
> > variable
> > maybe named something like B0001. If it contains a type statement, the
> > field names will be similar. A byte field could be named b001.
> >
> > All of the instructions will be correct, although there may be a few
> > errors
> > that have not been caught yet.
> >
> > Wayne
> >
> >
> > On Wed, Apr 28, 2021, 6:59 PM William Carlin <whcarlinjr at gmail.com>
> > wrote:
> >
> >> Charlie,
> >>
> >> There is one.  It’s called Decode by Wayne Campbell.  It can be found
> >> pretty easy online.  There is a demo of its usage on YouTube.
> >> https://youtu.be/KhT5VlElJHk
> >>
> >> It is also included in the NitrOS-9 Ease Of Use distribution in a
> >> folder
> >> of the same name off the root of the hard drive image.
> >>
> >>
> >> Respectfully,
> >>
> >> William H. Carlin, Jr
> >>
> >> > On Apr 28, 2021, at 16:43, coco at jechar.ca wrote:
> >> >
> >> >
> >> > I have a module tha works just fine but seem to have lost the source
> >> code.
> >> >
> >> > Is there a program that can generate a basic09 program from it's I
> code.
> >> >
> >> > Charlie
> >> >
> >> > --
> >> > Coco mailing list
> >> > Coco at maltedmedia.com
> >> > https://pairlist5.pair.net/mailman/listinfo/coco
> >>
> >> --
> >> Coco mailing list
> >> Coco at maltedmedia.com
> >> https://pairlist5.pair.net/mailman/listinfo/coco
> >>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>


More information about the Coco mailing list