ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories >> Software >> Embedded-Systems >> Embedded-Systems-AllOther
 
 
 
Question
Design a circuit to detect when 3 and only 3 bits are set 
out of 8 bits.(eg. o0101100)
 Question Submitted By :: Newbie
I also faced this Question!!     Rank Answer Posted By  
 
Answer
Step 1:  Store the 8 bit value in a accumulator

Step 2:  Store 0x1 in a register0, initialize two counter  
with 0 i.e. store zero in a reg1 and reg2.

LOOP:
Step 3:  Check if AND operation between the value in
register0 and accumulator is set i.e. 1 
if yes, increment reg1 and reg2
If no, increment only reg2

step 4: Left shift the value of register0 by 1
step 5: if ( reg2 >=8), exit LOOP
                 if ( reg1 >= 3), show that 3 bit is set
        Else Go To LOOP



MOV XAR1, #Data
MOV XAR0, #0
MOV XAR2, #0

Loop:
TBIT *XAR1, #Count 
BF Loop1, NTC
INR *XAR0

Loop1:
INR *XAR2
MOV AL, *XAR1
CMP AL, #0x03
BF Loop3, EQ

MOV AL, *XAR2
CMP AL, #0x80
BF Loop, NEQ

Loop3:
EXIT
 
0
Gautam Bhattacharya
 
View All Answers
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com