Mon, 17 Oct 2011, 21:04


A student writes:

> Hello,
> I apologize if this is a question that has been previously answered 
> in lecture, but I've been going through the program for Sunday and 
> came across a problem. I want to change the condition codes for a 
> branch to test for the values in a specific register. For example, 
> I want to test if R3 is positive, but the condition code is still set 
> for values in R1. Could you just perform an LDR or an ADD with 
> immediate value of zero with the value in R3 to change the condition codes?
> Thanks for your help,
> <<name withheld to protect the student who knows the condition codes as they
  are do not have the values he needs>>

I am not sure I understand your question, but I will try.

I think you are asking how to set the condition codes to reflect the contents 
of R3 so you can then execute a branch instruction based on the value in R3.

I think you realize that the condition codes reflect the contents of the last
register that was loaded, which in this case is not R3.  So you need to do
something that will set the condition codes based on R3 without changing 
anything else.

How about: ADD R3,R3,#0  ?

Nothing gets changed EXCEPT the condition codes now reflect the contents of R3.

OK?  Does that answer your question?  If not, please ask me again.

Yale Patt