Lets talk STATUS, Z

Status
Not open for further replies.

ChemE

New Member
Folks,

I am going through the EPE - PIC TO MOUSE DEMO (epemag.com/datafils/pic2kandm.zip) for a project that I am working on. I am trying to convert the code over to a 16F877A chip and have the PIC output a signal to a DAC. Basicly I want to have the mouse movements input into the PIC have the PIC send a signal to a DAC which will output to pots.

So now I have been going through the code trying to understand what it is doing. As you can tell I am an assembly newb so that is why I am asking for some help.

Here is the snippet of code that has propted me to ask for help:

Code:
WAITSTARTBIT:
comf PORTA, W
andlw %00000011
btfss STATUS, Z
goto WAITSTARTBIT

I understand what comf, andlw and btfss does from but I have been unable to determine how and in what way comf/andlw affect the Z bit of STATUS. I see that this code is waiting to see if Z bit is equal to 1 so that it can skip the next instruction.

My question is...


  • What will cause the Z bit to go to one?

If someone wants they could even give a more indepth lesson the the Z bit of status and if anyone is willing to teach me or want to help me code this portion of my personal project they are always welcome! ;-)
Thank you
 
Thank you Bananasiong for your reply!

So let me make sure that I understand this. If the result of w and b'00000011' equals zeros for bit 0 and 1 Z will then be one?

  • Does the Z bit only depend on bit 0 and 1?
  • What happens if I were to addlw b'00100111'?

Could someone give me a few examples of how to make Z = 1 with the andlw operater? I would like to learn about the Z bit. Thanks
 
Z bit is the Zero bit of STATUS register. Any returned value is zero will cause this bit (Z) to be set high.
Does the Z bit only depend on bit 0 and 1?
Yes, only if you AND w with b'00000011'.
What happens if I were to addlw b'00100111'?
Then it depends on bit 0, 1, 2, and 5.
 
Run the code through MPLABs simulator and watch the STATUS watch window. You can play with all sorts of code in the simulator, that's what its for.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…