Question

Assume that a switch is connected to pin P1.4 and a value stored in R5. Write a program that checks that status of the switch continuously, if the switch is ON decrement the value of R5 and send the value to P2 and the complement to P3. The program stops when the value of R5 reaches zero. 3. Write a program to add contents of 5 memory locations from location 40H onwards. The program then stores the result in R6 and sends it P2. If the final carry, after adding all of the values, equals to1 then set the bit 2AH in the memory 4. Write a program that reads a number from 8 switches connected to P2 then counts number of 1s in that number to display it as a binary number on 8 LEDs connected to 5. P3. Include a subroutine in your program to do the task of counting the 1s.
0 0
Add a comment Improve this question Transcribed image text
Answer #1


1)
AGAIN: JB P1.4 OVER // IF P1.4 IS 0 JUMP TO OVER
DJNZ R5 AGAIN // JUMP TO AGAIN IF R5 NOT EQUAL TO 0
  
OVER : DEC R5 // DECREMENT R5
MOV A,R5
MOV P2,A
CPL A // COMPLEMENT A
MOV P3,A AGAIN

2)
BACK: MOV RO #40H // RAM STARTING FROM 40H LOCATION
mov R1 #05 // 5 ITERATIONS
CLR A
ADD A, @RO // ADDITION
INC R0
DJNZ R1,
MOV R6,A // SAVE SUM INTO R6
MOV P2,A
JC JUMP
END
JUMP : SETB 2AH // SETTING


*Untitled Document (/Desktop) - gedit En 4D) 1:30 AM Open ▼ Save 1) AGAIN: JB P1.4 OVER IF P1.4 IS JUMP TO OVER DJNZ R5 AGAIN

Add a comment
Know the answer?
Add Answer to:
Assume that a switch is connected to pin P1.4 and a value stored in R5. Write...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Note: The question needs to be answered in "C Programming Languange ". And after the question fin...

    Note: The question needs to be answered in "C Programming Languange ". And after the question find 3 pages for needed informations. Spring CE4717 Language Processors Q1. Consider the following LEx program. return R1 return R2 return R3 return R4 return R5; return R6; IA-2a-z)[A-Za-z0-9]- -2 10-91+ 10-9a-EA-FI Ihi] [01] [01] 이삐 t Vtin) int main (void) int tcode; do f tcode -yylex()i printf ("token type td \"%s\"\n", tcode, yytext); ) while (tcode)i return 0; i. Explain the steps needed...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT