Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/15/05 13:05
Read: times


 
#101124 - only four bits
Responding to: ???'s previous message
hi,

Erik Malund said:
U8 P1_shadow
to write
;; modify the bits as needed in P1_shadow
mov P1,P1_shadow


Well, but then this MOV instruction modifyes all 8 bits of P1 while we need to write only low nibble. Indeed if we use P1_shadow as additional byte which keeps all bits to be wrote to port1 then this is correct.

My idea was:
MOV  A,P1        ; load current state of bits 0...3
XRL  A,pin_value ; mask bits which will not be changed
ANL  A,#0x0F     ; mask high nibble
XRL  P1,A        ; change not masked bits

The only one trouble may be is that during MOV A,P1 it reads not latch but pins` states and if they are overloaded by any reason then this piece of code fails (reads 0 instead 1).

Regards,
Oleg

List of 23 messages in thread
TopicAuthorDate
Week puzzle IV            01/01/70 00:00      
   In my opinion            01/01/70 00:00      
      no            01/01/70 00:00      
         Bufff!! then TRB            01/01/70 00:00      
            Me and my shadow, walking down the aven            01/01/70 00:00      
               You & your shadow            01/01/70 00:00      
                  http://www.coleporter.org/            01/01/70 00:00      
                     it's a hint            01/01/70 00:00      
   Well            01/01/70 00:00      
      you got it            01/01/70 00:00      
         Just OR with ones            01/01/70 00:00      
            how?            01/01/70 00:00      
   a simple solution:            01/01/70 00:00      
      not atomic            01/01/70 00:00      
         atomic not possible in general !            01/01/70 00:00      
   My solution!            01/01/70 00:00      
      Wrong            01/01/70 00:00      
      not atomic            01/01/70 00:00      
         Ok, here is the shadow            01/01/70 00:00      
            only four bits            01/01/70 00:00      
               2 Hints!            01/01/70 00:00      
                  Oh boy, do you need some bible time            01/01/70 00:00      
                  re: 2 Hints!            01/01/70 00:00      

Back to Subject List