Mult.asm comparison failures

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

Mult.asm comparison failures

Tom1984
I am very confused as to what is happening with the CPU Emulator when I run my Mult.asm against the test script.

As far as I can tell, my assembly code is correct for the task, as if I load my Mult.asm, enter the same values for R0 and R1 used in the script, and run through the program step-by-step, the expected product as specified is stored in R2 at the end of the program. However, when I run the program against the supplied Mult.tst script, I get a comparison error.

Any ideas would be greatly appreciated!

Thanks
Tom

Reply | Threaded
Open this post in threaded view
|

Re: Mult.asm comparison failures

Tom1984
I have noticed that the CPU Emulator is removing 6 lines from my assembly code when I run it against the test script. I'm not sure if this is expected behaviour (perhaps it removes lines that are redundant?) or if this might explain the problem...
Reply | Threaded
Open this post in threaded view
|

Re: Mult.asm comparison failures

cadet1620
Administrator
Tom1984 wrote
I have noticed that the CPU Emulator is removing 6 lines from my assembly code when I run it against the test script. I'm not sure if this is expected behaviour (perhaps it removes lines that are redundant?) or if this might explain the problem...
The simulator should not be removing any code.  Make sure that the .tst file you are loading is in the same directory as your source code.  I've confused myself more than a few times; I have a tree of student files and sometimes the student's reported bug doesn't match the actual bug that's occurring 8-(

Also, if it looks like your program isn't running to completion, you may need to increase the numbers in the "repeat" statements in the Mult.tst file; they are rather small.

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

Re: Mult.asm comparison failures

Tom1984
Thanks for your suggestions Mark.

I am using the default directory setup created when extracting the .zip archive, so my .tst and .asm are both within the same directory at the CPU Emulator.

Increasing the number of repeats in mult.tst didn't get around the problem, so just to see what would happen I ran my mult.asm through the assembler to load the outputted mult.hack file into the CPU Emulator. When I ran this against the script the CPU Emulator keep all of the code in, and the comparison ended successfully.

Since running mult.hack, if I load my original mult.asm file again and run the script, it also runs OK.  I have no idea why this would be, but it might be worth a try if you are reading this thread because you have had a similar issue.
Reply | Threaded
Open this post in threaded view
|

Re: Mult.asm comparison failures

cadet1620
Administrator
Aha! If you look at the Mult.tst script, you will see that it loads Mult.hack, not Mult.asm. Indeed, step 2 on page 74 says, "Use the supplied assembler..."

This explains why loading your Mult.asm directly worked but running the test failed. Now that you've run the assembler, the test will pass.

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

Re: Mult.asm comparison failures

Tom1984
Ah. That makes perfect sense now.

Thanks again for your help and patience with my schoolboy error Mark!