mult.asm: test does not pass

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

mult.asm: test does not pass

spyk
My code for mult.asm seems to work as expected in the simulator, but it will not pass the tests. It fails on the 1*3=3 case.

Could it still be some issue with the test file? I tried with the one mentioned in this post http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/Mult-tst-does-not-match-Mult-cmp-td4027015.html , but it was identical to my original.

Otherwise, maybe I can send to someone my source code to have a look?

Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: mult.asm: test does not pass

cadet1620
Administrator
There are no known problems with the test.

Each of the individual tests does not start with all RAM cleared to 0. Make sure you are initializing your variables.

If you can't find your error, feel free to email me your code.

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

Re: mult.asm: test does not pass

spyk
Hi Mark,

Thank you for your quick reply. It turned out that the code was correct, but I had to re-run it through the assembler for the tests to pass. I didn't know that was necessary - thought it re-generated the hack file automatically (it can be a bit confusing as the emulator works with the loaded asm code, while the tests run with the .hack file).

So everything works now, thank again!

Reply | Threaded
Open this post in threaded view
|

Re: mult.asm: test does not pass

mcdon.ron
In reply to this post by spyk
looks like a typo in the comments/directions of Multi.asm.  The comments say R2 refers to RAM[3], but test script's comparisions are done against RAM[2].

the lines:
// Multiplies R0 and R1 and stores the result in R2.
// (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[3], respectively.)

should read:
// Multiplies R0 and R1 and stores the result in R2.
// (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[2], respectively.)
Reply | Threaded
Open this post in threaded view
|

Re: mult.asm: test does not pass

liqiwen
YES,you are right ,sir . I have change the  RAM[3] to RAM[2] in my program and it pass the test .