Question
3. Write programs by 8051 microcontroller that will accomplish the desired tasks listed below, using as few lines of code as possible. Use only opcodes
3. Write programs by 8051 microcontroller that will accomplish the desired tasks listed below, using as few lines of code as possible.
Use only opcodes that have been covered in class. Comment on each line of code.
1. Place the number 3Bh in internal RAM locations 30h to 32h
2. copy the data at internal RAM location F1h to R0 and R3
3. Set the SP at the byte address just above the last working register address
4. Exchange the contents of the SP and the PSW
5. Copy the byte at internal RAM address 27h to external RAM address 27h
6. Copy the content of DPTR to registers R0(DPL) and R1(DPH)
7. Copy the data in external RAM location 0123h to TL0 and the data in external RAM location
01234h to TH08. Copy the data in internal RAM locations 12h to 15h to internal RAM locations 20h to 23h ; copy
12h to 20h, 13h to 21h, etc. . .
9. Set the SP register to 07h and PUSH the SP register on the stack ; predict what number is PUSHED
to address 08h
10. Exchange the content of the B register and external RAM address 02CFh
11. Rotate the bytes in registers R0 to R3 ; copy the data in R0 to R1, R1 to R2, R2 to R3 and R3 to
R0
12. Copy the external code byte at address 007Dh to the SP
13. Copy the data in register R5 to external RAM address 032Fh
14. Copy the internal code byte at address 0300h to external RAM address 0300h
15. Swap the bytes in TIMER 0 ; put TL0 in TH0 and TH0 in TL0
16. Store DPTR in external RAM locations 0123h (DPL) and 02BCh (DPH)
17. Exchange both low nibbles of registers R0 and R1 ; put the low nibble of R0 in R1, and the low
nibble of R1 in R0
18. Store the content of register R3 at the internal RAM address contained in R2. (Be sure the address
in R2 is legal)
19. Store the content of RAM location 20h at the address contained in RAM location 08h
20. Store register A at the internal RAM location address in register A
21. Copy program bytes 0100h to 0102h to internal RAM locations 20h to 22h
22. Copy the data on the pins of port p2 to the port 2 latch
23. PUSH the contents of the B register to TMOD
24. Copy the contents of external code memory address 0040h to IE
25. Show a set of XCH instructions executes faster than PUSH and POP when saving the contents of
the A register.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started