A and D Register Confusion

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

A and D Register Confusion

javalilly
I am working on the fill.asm and I don't understand why if I do

@-1
D=A

I get a "can't continue past line" error, but if I just do

D=-1 it fills in just fine.

I've read the book, but I am still not understanding. All I'm doing is using an A instruction to the D register right?

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

Re: A and D Register Confusion

ybakos
Take a look at section 4.2.2. A instructions must only use "non-negative numbers or a symbol referring to such a number."

Your challenge is to indeed fill the screen memory with negative ones. And you can use the constant -1 in Hack assembly. But not in the A instruction. (Hint: you don't need to use an A instruction to store the constant -1 since Hack assembly allows you to use the constant value -1 explicitly, just as you demonstrate with D=-1.)
Reply | Threaded
Open this post in threaded view
|

Re: A and D Register Confusion

javalilly
ybakos wrote
Take a look at section 4.2.2. A instructions must only use "non-negative numbers or a symbol referring to such a number."

Your challenge is to indeed fill the screen memory with negative ones. And you can use the constant -1 in Hack assembly. But not in the A instruction. (Hint: you don't need to use an A instruction to store the constant -1 since Hack assembly allows you to use the constant value -1 explicitly, just as you demonstrate with D=-1.)
Got it. Thanks a lot!