Help with mult.asm (baffling errors...I'm probably missing something basic) -SOLVED

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

Help with mult.asm (baffling errors...I'm probably missing something basic) -SOLVED

Magerman
This post was updated on .
Okay, so I'm doing the exercises at the end of Ch. 4 at the moment and something strange is going on with my mult.asm program; I get Comparison Failures when I run it against the test file (i.e. doesn't give the right output). The really weird thing is that it has errored out at different points in the program without me changeing the code at all...that is to say, sometimes it clears the first four test inputs and gets stuck on the fifth, sometimes it gets stuck on the fourth instead, and sometimes it can't even get past the second input...This baffles me, since logically it should always fail at the same point right?

I've gone line by line to see what the problem was for the fifth test inputs (RAM[0] = 2 and RAM[1]=4) and again when it errored out for the second test inputs (RAM[0]=1 and RAM[1]=0), and I found that for some strange reason when I tried to set A to the value at the RAM location 1 (i.e. RAM[1]) it just set A to the constant 1 instead! The problem seems to be that even though I'm using variables when I write the code, the compiler changes the variable of "R1" (for instance), to "@1" which simply sets A to 1 rather than to whatever is at location 1. That is to say, the compiler changes "@R1" to "@1," then when it reads "@1" when RAM location 1 is set to 4, it changes A to 1 instead of 4, which led to "1x0=1" and "4x2=2"...what am I doing wrong? D=

Here is my code:

(Edit: problem has been solved, code removed from post)
Reply | Threaded
Open this post in threaded view
|

Re: Help with mult.asm (baffling errors...I'm probably missing something basic)

ivant
First of all, you should restart the emulator after each run. It's a PITA but it has some internal state and doesn't reset properly for the next run. That's why you get different errors on each run.

Now for the good news: your program is almost right! It has just one small error in it around the comparison for exiting the loop. The comment says one thing, but the program does something a little bit different.

Tell me if you still can't find it and I'll show it to you. In any case, you should remove the code from your post after your problem is solved.
Reply | Threaded
Open this post in threaded view
|

Re: Help with mult.asm (baffling errors...I'm probably missing something basic)

Magerman
Oh my god lol, found the error XD. I didn't know it worked that way, I guess now I do haha.  

Thanks for your help! =D