Appendix 1: data pointer usage examples – Maxim Integrated MAXQ622 User Manual
Page 246

Maxim Integrated
A1-1
MAXQ612/MAXQ622 User’s Guide
APPENDIX 1: DATA POINTER USAGE EXAMPLES
IMPORTANT: MAXQ20 family pointer mode (DPC.WBS) bits and source select
(DPC.SDPS) bits should not be changed simultaneously.
Writing immediate values to DPC (e.g. MOVE DPC, #4)
without knowing the previous contents can implicitly
setup a situation where the mode and select bits are
changed simultaneously. A function call with
foo:
push
DPC
;...
move
DPC,
#4
;...
pop
DPC
ret
will, in many cases, setup a situation where mode and
select bits are changed simultaneously. If you are
ever in doubt about the contents of DPC then read the
contents, change only the desired bits using a bit mask and
write the modified value back to DPC.
NOTE:
Compilers already manage DPC correctly. These examples are intended to benefit
people that write assembly language routines, modules or applications.
NOTE: All data pointers are implemented with 17 bits, with sliding windows that expose
the upper 16 bits when the corresponding DPC.WBS is set to 1 (word mode) and expose
the lower 16 bits if the corresponding DPC.WBS is cleared to 0 (byte mode).
MAXQ 17-bit Internal Pointer Representation (DP[0], DP[1], BP[OFFS]
[, CP where applicable]):
internal bit position: 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
word mode window: ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
byte mode window: ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
If you need to preserve a pointer across an interrupt service routine
or a function call and you modify the pointer’s mode then you must
preserve all 17 bits of any pointer used. The most basic form of this
operation looks like (DP[0] example)
foo:
push DPC ; preserve DPC
move DPC, #0h ; save the
push DP[0] ; byte mode version of DP[0]
move DPC, #4h ; save the
push DP[0] ; word mode version of DP[0]
;