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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/15/09 22:38
Read: times


 
#162445 - this might be it
Responding to: ???'s previous message
Munis Quadri said:
This is my code ,please point where I'm wrong


org 00h
loop:	mov a,p1
	mov b,p1
	anl a,#00000010b
	anl b,#00000001b
	rr a
	mov r0,b
	xrl a,r0
	jnz bits        <== What does it do here, if it's zero, that it doesn't do if it's not?
bits:	setb p2.0
	sjmp loop
	end

 


You might consider this:

org 00h
loop:	mov a,p1
	mov b,p1
	anl a,#00000010b
	anl b,#00000001b
	rr a
	mov r0,b
	xrl a,r0
	jnz bits
        sjmp here        ; ------
bits:	setb p2.0 ;              |
here:	sjmp loop        ; <-----
	end

 


Keep in mind, too, that if the two bits are the same, the result will be zero. The way you've written the code, the output will transition to '1' only once and stay that way, since the P2.0 is never cleared.
RE

List of 12 messages in thread
TopicAuthorDate
How to XOR a single bit (N00B)            01/01/70 00:00      
   Instruction set tells what is available            01/01/70 00:00      
      Code            01/01/70 00:00      
         Think about it a little bit!            01/01/70 00:00      
   CPL bit if XOR with 1; otherwise, don't            01/01/70 00:00      
      wrote this code still not working            01/01/70 00:00      
         Jumping where? And not jumping where?            01/01/70 00:00      
         this might be it            01/01/70 00:00      
         use a compiler first            01/01/70 00:00      
         XOR a bit, quite literally            01/01/70 00:00      
            ... and now, we've done his homework for him ...            01/01/70 00:00      
   schematic            01/01/70 00:00      

Back to Subject List