| ??? 05/09/03 23:19 Read: times |
#45138 - RE: Port status and bit status Responding to: ???'s previous message |
No.
MOV A,P1 All bits on port 1 are copied to the accu. LOOP: CJNE A,#01H,LOOP If the contents of the accu is not 1, check the accu again. Since the accu does not change by itself, you will probably end up in an infinite loop. A CPU is not human. It does not do what you would want it to do, and it does not remember its last step. What you want to do would code as: loop: cjne p1,#0,loop although i would call it bad practice to voluntarily lock yourself up in a loop which excludes any other sort of activity. To find out which bit on port 1 was responsible for it not being 0 will require further steps. Also, learn to think in "negative logic". That is: 1 is off, 0 is on. This corresponds much better with how at least the 8051's ports are constructed. |



