10/12/04

A student writes:

     Dear Dr. Patt,
     I have written a program that I thought would work,
     but there are just a few problems. In one instruction,
     I do R2 AND R4 and store the result in R5.
     Next, I want to examine the the result to see it the
     Z and P bits are set. In order to do this, do I have
     to put what register to go to, or will it automatically
     know to examine whatever I just did? 

When the result of that AND instruction writes into R5, it sets the condition codes. If the next instruction is a branch (opcode=0000), the computer does not look at R5, it looks at the condition codes that were set by the AND instruction, so everything should be fine.

Just to reinforce this: The computer doesn't care what register was written to. The computer only cares what is in the condition codes. Of course, what is in the condition codes was put there based on what was written into R5, but the computer looks ONLY at the condition codes to figure out whether to branch or not.

Good luck with the program.

Yale Patt