Thanks James Cameron for the info, I was not sure how to respond to a
arctile. The flow chart was done in ten minutes (through my lunch break)
and didn't have did really think about the design. Over the next week, I
going to do a better layout and with alot more information.
Anyway, another question (still regarding to the password routine code):
1. What is the best way of checking if all inputs from PORT B are not high?
2. What is the best way of checking the value from PORT B against the
working register to see if they are the same?
>Hi Friends
>
>Thanks James Cameron for the info, I was not sure how to respond to a
>arctile. The flow chart was done in ten minutes (through my lunch break)
>and didn't have did really think about the design. Over the next week, I
>going to do a better layout and with alot more information.
>
>Anyway, another question (still regarding to the password routine code):
>
>1. What is the best way of checking if all inputs from PORT B are not high?
comf PORTB,w ; complement bits, 0xFF -> 0x00
bnz ALL_NOT_HIGH ; bnz <label> is same as btfss STATUS,Z / goto
<label>
>
>2. What is the best way of checking the value from PORT B against the
>working register to see if they are the same?
xorwf PORTB,w ; W = W ^ PORTB, if same result is 0.
bz MATCH
On Thu, 26 Nov 1998 13:30:39 +0000 Paul Phillips
<.....paul.phillipsKILLspam@spam@CONSYSE.CO.UK> writes:
>Hi Friends
>
>Thanks James Cameron for the info, I was not sure how to respond to a
>arctile. The flow chart was done in ten minutes (through my lunch
>break)
>and didn't have did really think about the design. Over the next
>week, I
>going to do a better layout and with alot more information.
>
>Anyway, another question (still regarding to the password routine
>code):
>
>1. What is the best way of checking if all inputs from PORT B are not
>high?
In other words, to see if one or more bits of PORTB are low? There's an
easy way to do that:
comf PORTB,w ;Sets Z flag if PORTB =
11111111
skpnz ;Skips if one or more bits are low.
Of course, the value in W is changed.
>2. What is the best way of checking the value from PORT B against the
>working register to see if they are the same?
xorwf PORTB,w
skpz ;Skips if PORTB = W
Note that this routine also changes the value in W.
The xor method above can also be used to test only some of the bits in
PORTB by ANDLW'ing the result in W with a mask (containing ones
corresponding to the bits to be tested) before the SKPZ.
Also of course these tests work on RAM locations as well as ports. It
may be an advantage to read the port only once and make a copy to RAM for
further tests in case the hardware connected to the port changes the
value in the middle of a sequence of tests.
___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]
Hello Paul & PIC.ers,
..
>Date: Thu, 26 Nov 1998 13:30:39 +0000
>From: Paul Phillips <paul.phillipsKILLspamCONSYSE.CO.UK>
>Subject: Checking of BIT Values
>
><snippo>
>Anyway, another question (still regarding to the password routine code):
>
>1. What is the best way of checking if all inputs from PORT B are not high?
..
yey. mmm. Do you mean:-
(a) port_b = 00000000b ;ie not one input is HI
or,
(b) port_b = 00000001b to 11111110b ;ie some, but not all, are HI
?
If (a), then the easiest I know is:
movf port_b,same ;this returns zero bit set i
f port_b = 0
btfss status,z
goto not_zero_case
goto zero_case
If (b), then the result of above ((a) operation) would be opposite.
..
>
>2. What is the best way of checking the value from PORT B against the
>working register to see if they are the same?
..
subwf port_b,w ; zero bit gets set if port_b = w
btfss status,z
goto wasnt_equal
goto was_equal
..
Hope this improves the light.
..
Best regards, John
..
email from John Sanderson at
JS Controls, PO Box 1887, Boksburg 1460, Rep. South Africa
Manufacturer & purveyor of laboratory force testing apparatus
and related products and services.
Tel/fax: Johannesburg 893 4154 Cellphone 082 453 4815