CPU Functions
C500 Family
Semiconductor Group
2-7
1998-04-01
Example 1 : Using only One Datapointer (Code for a C501)
Initialization Routine
MOV
LOW(SRC_PTR), #0FFH
;Initialize shadow_variables with source_pointer
MOV
HIGH(SRC_PTR), #1FH
MOV
LOW(DES_PTR), #0A0H
;Initialize shadow_variables with destination_pointer
MOV
HIGH(DES_PTR), #2FH
Table Look-up Routine under Real Time Conditions
;
Number of cycles
PUSH
DPL
;Save old datapointer
2
PUSH
DPH
;
2
MOV
DPL, LOW(SRC_PTR)
;Load Source Pointer
2
MOV
DPH, HIGH(SRC_PTR)
;
2
;INC
DPTR
Increment and check for end of table (execution time
;CJNE
É
not relevant for this consideration)
Ð
MOVC
A,@DPTR
;Fetch source data byte from ROM table
2
MOV
LOW(SRC_PTR), DPL
;Save source_pointer and
2
MOV
HIGH(SRC_PTR), DPH
;load destination_pointer
2
MOV
DPL, LOW(DES_PTR)
;
2
MOV
DPH, HIGH(DES_PTR)
;
2
INC
DPTR
;Increment destination_pointer
;(ex. time not relevant)
Ð
MOVX
@DPTR, A
;Transfer byte to destination address
2
MOV
LOW(DES_PTR), DPL
;Save destination_pointer
2
MOV
HIGH(DES_PTR),DPH
;
2
POP
DPH
;Restore old datapointer
2
POP
DPL
;
2
;
Total execution time (machine cycles) : 28