Design a circuit to detect when 3 and only 3 bits are set
out of 8 bits.(eg. o0101100)

Answer Posted / gautam bhattacharya

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

Is This Answer Correct ?    0 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Describe to me some bad code you've read or inherited lately.

432


What is the significance of watchdog timer in es?

436


Describe a pattern that is not the factory pattern? How is it used and when?

440


Tell me what are real-time embedded systems?

426


What are the different types of buses used by the embedded systems?

464






Explain me what is semaphore?

452


Explain the difference between "set" logic, and "procedural" logic. When would you use each one and why?

431


What is the difference between hard real-time and soft real-time os?

429


Explain some of the commonly found errors in embedded systems?

443


How to implement a fourth order butter worth lp filter at 1 khz if sampling freuency is 8 khz?

477


What is refactoring? Name three common refactorings.

546


Explain the differences between analytical and computational modeling?

431


Explain how does combination of functions reduce memory requirements in embedded systems?

429


What are the uses of the keyword static?

485


What is a inode?

480