Odd mult.tst issue

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

Odd mult.tst issue

JustinM
I plugged in some register values manually for R0 and R1 (something like 91 and 303) and the program calculated the correct value (which was stored in R2).

When I run my program against mult.tst, it works fine until it completes the 3x1 test. After that I notice that R2 does not get cleared (it stays at 3), which causes the result of the 4x2 test to be 11, which of course throws a comparison failure.

Since it works properly when I plug in manual values, I don't see how this could be the program I wrote. It's also a very simple program. Anyone see this before?
Reply | Threaded
Open this post in threaded view
|

Re: Odd mult.tst issue

cadet1620
Administrator
JustinM wrote
After that I notice that R2 does not get cleared (it stays at 3), which causes the result of the 4x2 test to be 11, which of course throws a comparison failure.
You have found the problem with your code. This is a classic "uninitialized variable" bug.

To be a correct multiplication algorithm, your program must clear R2 before it starts the loop that adds to R2.

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

Re: Odd mult.tst issue

JustinM
Oh the irony... once I saw that the test script was plugging in values, look at what I did...

        //@R2
        //M=0 // @R2 = 0

Thanks Mark!