Problems on Moving Data

Problems

Write programs that will accomplish the desired tasks listed below, using as few lines of code as possible. Use only opcodes that have been covered up to this chapter. 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 Flh 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. Set Timer 1 to A23Dh.

7. Copy the contents of DPTR to registers R0 (DPL) and R1 (DPH).

8. Copy the data in external RAM location 0123h to TL0 and the data in external RAM location 0234h to TH0.

9. 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.

10. Set the SP register to 07h and PUSH the SP register on the stack; predict what number is PUSHed to address 08h.

11. Exchange the contents of the B register and external RAM address 02CFh.

12. Rotate the bytes in registers R0 to R3; copy the data in R0 to R 1, R 1 to R2, R2 to R3, and R3 to R0.

13. Copy the external code byte at address 007Dh to the SP.

14. Copy the data in register R5 to external RAM address 032Fh.

15. . Copy the internal code byte at address 0300h to external RAM address 0300h.

16. Swap the bytes in timer 0; put TL0 in TH0 and TH0 in TL0.

17. Store DPTR in external RAM locations 0123h (DPL) and 02BCit (DPH).

18. 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.

19. Store the contents of register R3 at the internal RAM address contained in R2. (Be sure the address in R2 is legal.)

20. Store the contents of RAM location 20h at the address contained in RAM location 08h.

21. Store register A at the internal RAM location address in register A.

22. Copy program bytes 0100h to 0102h to internal RAM locations 20h to 22h.

23. Copy the data on the pins of port 2 to the port 2 latch.

24. PUSH the contents of the B register to TMOD.

25. Copy the contents of external code memory address 0040h to IE.

26. Show that a set of XCH instructions executes faster than a PUSH and POP when saving the contents of the A register,

Leave a comment

Your email address will not be published. Required fields are marked *