Unit 3 Assignment

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

1.

Take 10 bytes of data from RAM locations 45H to 54H, add 02 to each of them and save the
result in data RAM locations 79H down to 70H.
2. Assuming that ROM space starting at 250H contains “America”, WAP to transfer the bytes
into RAM locations starting at 40H.
3. Assume that the on-chip ROM has a message. Write a program to copy it from code space
into the upper memory space starting at address 80H. Also, as you place a byte in upper
RAM, give a copy to P0.
4. Write a program to add two 32-bit numbers. Let the 32 bit numbers be 01453BC0H and
56C705FEH and let them be stored in RAM locations as shown below:
40H C0
41H 3B
42H 45H
43H 01H

50H FEH
51H 05H
52H C7
53 6H
Show the results at 60H onwards.

5. Assume that 5 BCD data items are stored in RAM locations starting at 40H, as shown below.
Write a program to find the sum of all the numbers. The result must be in BCD.
40= (71)
41= (11)
42= (65)
43= (59)
44= (37)

6. Show how the 8051 does the following calculations:


(a) Add +46 and -114
(b) Add -37 and -82
(c) Subtract -29 from +69
(d) Subtract -69 from -39

7. What is the role of OV flag? Discuss the condition when is the OV flag is set? Give some
examples.

8. Write a program to get hex data in the range of 00 – FFH from port 1 and convert it to
decimal. Save it in R7, R6 and R5.

9. In a semester, a student has to take six courses. The marks of the student (out of 25) are
stored in RAM locations 47H onwards. Find the average marks and output it on port 1.
10. Write a program to read the temperature and test it for the value 75. According to the test
results, place the temperature value into the registers indicated by the following.

11. Ten hex numbers are stored in RAM locations 50H onwards. WAP to find the biggest
number in the set. The biggest no should be saved in 60H.

12. WAP to check if the character string of length 7, stored a in RAM locations 50H onwards is a
palindrome. If it is, output ‘Y’ to P1.

13. WAP to transfer value 41H serially (one bit at a time) via pin P2.1. Put two highs at the start
and end of the data. Send the byte LSB first.

14. WAP to bring in data in serial form and send it out in parallel form.

15. Assume that register A has packed BCD. Write a program to convert packed BCD to two
ASCII numbers and place them in R2 and R6.

16. Assume that the lower three bits of P1 are connected to three switches. WAP to send the
following characters to P2 based on the status of the switches.
000 ‘0’
001 ‘1’
010 ‘2’
011 ‘3’
100 ‘4’
101 ‘5’
110 ‘6’
111 ‘7’

17. Assume that we have 4 bytes of hexadecimal data: 25H, 56H, 3FH and 52H.
(a) Find the checksum byte
(b) Perform the checksum operation to ensure data integrity
(c) If the second byte 56H has been changed to 22H, show how checksum detects the error.

18. WAP in assembly to convert hexadecimal number to ASCII.

You might also like