Conflicting uses of the A register

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

Conflicting uses of the A register

Making my way through this chapter and this paragraph means little sense to me. It says...

“To prevent conflicting use of the A-register, in well written programs a C-instruction that may cause a jump should not contain a reference to M”

Is this rule preventing some kind of looping condition or something, where the next instruction is a pointer to the current instruction? If so why not just say that? Or am I completely wrong?
Reply | Threaded
Open this post in threaded view

Re: Conflicting uses of the A register

This is referring to an instruction like
This would read RAM[A] and if it was non-zero, jump to ROM address A.

This does not cause any particular problem with the hardware, it is just extremely unlikely to be what you want to do. It would only occur in "trick" code.  For instance, I saw a student's Fill program that kept a counter in R0 and used something like
to decrement the counter and restart the program.  Using a normal RAM variable this would have been something like

There is another instruction that looks like it is reading an address from RAM and jumping to the address that was read (jumping via a code pointer).
But by the strict definition of the instructions, this loads the PC with the current value of A, and simultaneously loads A with the new value read from RAM[A]. (The CPUEmulator does it differently!)

Any instruction that modifies A should also not be used with a jump option.