Still cann't compelete fill.asm

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

Still cann't compelete fill.asm

lcy
I finished Mult.asm by myself, but I still can't compelete "fill.asm".
I read some people's code in github, but I can't understand them.
I think I don't understand the A and M clearly, could you give me some suggesitions or hints?

Reply | Threaded
Open this post in threaded view
|

Re: Still cann't compelete fill.asm

ybakos
Understanding how A and M work together can be tricky at first, but keep working at it, you'll get it!

Remember that Memory has a bunch of registers in it, each with an address. 0, 1, 2... and so on. When you want to store something in Memory, you use the mnemonic M. But when you say M, the machine needs to know which register in M you want to store something in. Is it register 0? Register 343?

To determine where in M you want to store something, the machine "looks at A". It reads whatever value is in the A register, and says, "Ah, ok, you mean register # in M," where # is whatever number happens to be stored in A.

In other words, the specific meaning of M is dependent on A. M means memory, but a specific address in memory. Which address? The one stored in A.

Reply | Threaded
Open this post in threaded view
|

Re: Still cann't compelete fill.asm

cadet1620
Administrator
In reply to this post by lcy
lcy wrote
I finished Mult.asm by myself, but I still can't compelete "fill.asm".
I read some people's code in github, but I can't understand them.
I think I don't understand the A and M clearly, could you give me some suggesitions or hints?
You can e-mail me directly
   
Send me your Mult.asm and what you have so far for Fill.asm and I will give you some suggestions.

Also, read this guide I've been working on and see if it helps.

--Mark

lcy
Reply | Threaded
Open this post in threaded view
|

Re: Still cann't compelete fill.asm

lcy
In reply to this post by ybakos
Very clearly.
But I still have questions like:
@i
A=M  

What happened? I think when I use the "@" the machine will  find the address of i , so the A=M is not right,because I change the registers' address.
(If in the @KBD , I didn't press any key, the M[A] equals 0 ,then the A will be pointer to address 0? )

 
Reply | Threaded
Open this post in threaded view
|

Re: Still cann't compelete fill.asm

cadet1620
Administrator
"@i" sets the A register to the address of "i",
"A=M" sets the A register to RAM[A], which is the value if "i".

C-instructions first compute the value on the right side of the '=', then store that computed value into the destination.

In the case of "A=M", the A register is changed after RAM[A] was read.

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

Re: Still cann't compelete fill.asm

lcy
Wow!Amazing!I understand it!