multiplexing using assembly

foTONICS

Sep 30, 2011
332
Joined
Sep 30, 2011
Messages
332
Hey guys,

I've been teaching myself PICS by going through this tutorial website someone on here posted a while ago www.googligum.com. and I find it extremely useful and informative.

Attached is a screenshot of a section of code used to increment the value of some digits (being sent to a 7-seg display). I understand the movlw .10 and movlw .6 commands and even the xor part (testing if the result is zero) but why skip right to the end of the subroutine?

if my one's place rolls over wouldn't you want to update the tens place? or am I just reading this code wrong?
 

Attachments

  • assembly.jpg
    assembly.jpg
    55.5 KB · Views: 130
Last edited:

foTONICS

Sep 30, 2011
332
Joined
Sep 30, 2011
Messages
332
Under the xorwf ones,w

shouldn't it be 'btfsc' instead of 'btfss'?
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Say you are incrementing the number 15. Once you have incremented the 5 you are done, you don't have to increment the 1. That is why it skips to the end of the subroutine when the result of incrementing the ones is not 10. Now, if it is 19, after you increment the 9, you get 10 and you want to set that to zero, then increment the 1 to get 2, so it continues to increment the next digit.

btfss is correct. When you xor the number with .10, it will be zero only if the number is 10. That means the Z bit is set, so the btfss skips the goto to the end of the subroutine.

Bob
 

foTONICS

Sep 30, 2011
332
Joined
Sep 30, 2011
Messages
332
so when I xor two numbers that are the same my Z bit goes high?
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Yep.

0 xor 0 = 0
1 xor 1 = 0
0 xor 1 = 1
1 xor 0 = 1

So when you xor the same number you get all zeros as a result.

bob
 

foTONICS

Sep 30, 2011
332
Joined
Sep 30, 2011
Messages
332
oh ok, that's my problem then, I thought that if my result was 0 'Z' would clear and if it was 1 it would set
 
Top