UMBC | CMSC 391 -- Programming Microcontrollers |
mov DPTR, #4000h ; put the address 4000 into the data pointer movx @DPTR, 0h ; set address 4000h to 0.
When used with another register, you get indexing.
2000: .org 0x2000 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Equates ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Code ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; begin: ;; indirect mode: ;; 2 bytes/1 cycle + 1 byte/1 cycle ;; = 3/2 2000: 78 D0 mov R0, #0D0h 2002: E6 mov A, @R0 ; Get the PSW ;; register mode ;; 2 bytes/ 1 cycle 2003: E5 D0 mov A, PSW 2005: 90 40 00 mov DPTR, #4000h 2008: E5 00 mov A, 0 200A: F0 movx @DPTR, A ;; indexing can be done in two ways ;; Note that A is used as both a part of the ;; source and a part of the destination and ;; must be reinitialized for the next step. 200B: 90 40 00 mov DPTR, #4000h 200E: 74 00 mov A, #0 ;clr A would be better 2010: 93 movc A, @A+DPTR ;; or use just a simple pointer and increment ;; for the next step. 2011: 90 40 00 mov DPTR, #4000h 2014: E0 movx A, @DPTR 2015: A3 inc DPTR 2016: 22 ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;