Trouble with mult.asm

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

Trouble with mult.asm

Z470
This post was updated on .
I've been messing with this for hours and I can't figure out why it won't work...

I'm basically trying to put this code into asm:

while(R0 > 0)
{
   R2=R2+R1;
   R0--;
}

This is what I've come up with. It compiles and runs fine, but keeps throwing comparison errors. Is there something obvious that I'm not seeing?

Removed code...

Thanks for any help...
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with mult.asm

cadet1620
Administrator
Your program appears correct and runs for me and passes the test script when assembled with the supplied assembler.

Try deleting your .hack file and reassembling to make sure that your .hack file is up to date.

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

Re: Trouble with mult.asm

Z470
Okay I deleted everything and tried it again, got it to work. Thanks for the help.
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with mult.asm

p.konrad
Hi
I tried it the same way but I didn't get rid of the comparison failures deleting the .hack file.

Could it be that decrementing R0 directly causes the problem?

Maybe someone could check my code... it could also be possible that I made an essential mistake that I don't see right now...

thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with mult.asm

cadet1620
Administrator
p.konrad wrote
Hi
I tried it the same way but I didn't get rid of the comparison failures deleting the .hack file.

Could it be that decrementing R0 directly causes the problem?
Directly decrementing R0 will cause comparison failure.  You can prevent this by putting '*' in the R0 column in the .cmp file.
|  RAM[0]  |  RAM[1]  |  RAM[2]  |
|**********|       0  |       0  |
|**********|       0  |       0  |
etc.
Better would be to copy RAM[0] to RAM[3] and use it as your counter.

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

Re: Trouble with mult.asm

p.konrad
thanks, I'll try the latter first ;)
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with mult.asm

p.konrad
it worked without problems, thanks again :)