Error with SimpleFunction.tst (and SimpleFunction.vm)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Error with SimpleFunction.tst (and SimpleFunction.vm)

brbecker
I'm having troubles with getting the CPUEmulator to accept the SimpleFunction.tst file. Every time I run it, I get the following error at the first step (before my asm code is even loaded!):

    In line 4, Destination expected

Line 4 is actually a comment, so I'm not sure why it would be complaining there. I've tried comparing the initial load, output-file, etc. stanza to the FibonacciSeries.tst file and don't see any non-obvious differences.

As far as I can tell, this file has been unchanged since I unpacked it from the zip file.

Also, as has been reported a few other times on this board, the SimpleFunction.vm file is missing a slash in line 1 to make a complete comment marker.
Reply | Threaded
Open this post in threaded view
|

Re: Error with SimpleFunction.tst (and SimpleFunction.vm)

cadet1620
Administrator
brbecker wrote
I'm having troubles with getting the CPUEmulator to accept the SimpleFunction.tst file. Every time I run it, I get the following error at the first step (before my asm code is even loaded!):

    In line 4, Destination expected

Line 4 is actually a comment, so I'm not sure why it would be complaining there.
"Destination expected" sounds like an assembler error message.  Check the .asm written by your VM translator. Note that the assembler can be picky about the order when there are more than one destination register in an instruction. It likes the order listed in the table in 6.2.2 (top of page 110 in the book).

Also, it's not uncommon for the line number in the error messages to be off by 1, so look up or down a line or two.
Also, as has been reported a few other times on this board, the SimpleFunction.vm file is missing a slash in line 1 to make a complete comment marker.
Thanks.  I just put the corrected file in the Announcements: New and Updated Files section.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Error with SimpleFunction.tst (and SimpleFunction.vm)

brbecker
Thanks for the rapid response. You found the problem (DA vs AD in my code). I wish the assembly syntax allowed any destination order, since it really doesn't matter.

Now, on to debugging ....
Reply | Threaded
Open this post in threaded view
|

Re: Error with SimpleFunction.tst (and SimpleFunction.vm)

Krozu
To be fair, you could make your assembler to accept these inputs.

I'm writing mine in C# and use Dictionary's to construct the machine code.
Example:
          private static Dictionary<string, string> compD = new Dictionary<string, string>{
          {"A", "110000"}, {"!D", "001101"}, {"D+1", "011111"},{"A+1", "110111"}};

          I use these to create the machine code, so in my case, i could simply add the following:
                    {"1+D", "011111"}

Doing this allows me to use 'M=D+1' or 'M=1+D'. But again, i don't follow the book in this regard, so this might not be possible for you unless you make some major changes to your code.

Do note that i have not actually tried this, so i may be wrong. However, if I'm right this could be a possible solution for you.