;**************************************************************************** ;* By Reg Drake Jan 31/2000, regdrake@yahoo.com ;* ;* SELDPTR is POSTCARD ware. If you use it, drop me a line @ regdrake@yahoo.com ;* feel free to use, modify, share it. If it works, great. ;* if it fails, write your own. If it causes you great ;* emotional / physical / financial harm, it's your problem. ;* If you share it, please keep this message intact. ;* ;* I'm using Version 1.2K of MetaLink's old freeware compiler ;* ;* If you want more DPTR's you can easily modify the code to allow for ;* up to 128 DPTR's. However this would require 257 bytes of XRAM. ;* Things to look for : XRAM useage = #of DPTR's X 2 + 1 ;* Change ANL A,#007h to match your new # of DPTR's ;* Therefore good choices are 4, 8, 16, 32. . . you get the picture ;* Change all PDPTRM + 16's to PDPTRM + #of DPTR's X 2 ;**************************************************************************** ;Place the following section where ever you define your memory. ;Note the memory allocated is in external RAM. (Thanks to Waferscale's PSD813F2 in my case :) XSEG PDPTRM: DS 17 ;17 byte Pseudo DPTR buffer, allows for emulating 8 DPTR's ;Place the following section in your MACRO definition file, or where ever you normally ;place your macros ;**************************************************************************** ;* Select Datapointer ;* By Reg Drake , Jan 31/2000, regdrake@yahoo.com ;* Purpose: ;* This macro calls the sub SELDPTR after preserving the ACC & PSW this makes ;* the use of multiple datapointers relatively painless ;**************************************************************************** SDP MACRO NEWDPTR push PSW ;saving registers before calling push ACC mov ACC,#NEWDPTR ;passing parameter to sub call SELDPTR ;go and do the actual swap. this call saves lots of space ;rather than including the function is linear form here. pop ACC pop PSW ENDM ;The following section should be included in your source code. ;**************************************************************************** ;* By Reg Drake Jan 31/2000, regdrake@yahoo.com ;* ;* SELDPTR is POSTCARD ware. If you use it, drop me a line @ regdrake@yahoo.com ;* feel free to use, modify, share it. If it works, great. ;* if it fails, write your own. If it causes you great ;* emotional / physical / financial harm, it's your problem. ;* If you share it, please keep this message intact. ;* ;* SELDPTR Emulates 8 DPTR's (0 - 7) by swapping the real DPTR out to ;* XRAM when not needed. No initialization is required for this ;* function. simply select a DPTR before using. ;* To Call Load ACC with desired DPTR, call ;* Returns Old DPTR is saved, new has arrived. The contents of ACC are ;* indeterminate ;**************************************************************************** SELDPTR: push ACC ;Save the destination DPTR push DPH ;store the existing DPTR temporarily in the stack push DPL mov DPTR,#PDPTRM + 16 ;point to current selection movx A,@DPTR ;get the value back anl A,#007h ;limit the value to 0 - 7 rl A ;X 2 mov DPTR,#PDPTRM ;load up base of buffer add A,DPL ;add to DPL, overflow goes to the carry flag mov DPL,A ;save result, carry flag still set rlc A ;rotate the carry into bit location 0 on ACC anl A,#001h ;limit ACC so it's just the carry flag add A,DPH ;and add the carry to DPH mov DPH,A ;and save it back ! You just performed a 8 + 16 with ;no jumps / decisions! pop ACC ;getting back the current DPL in order to save it movx @DPTR,A ;saved inc DPTR pop ACC ;getting back the current DPH in order to save it movx @DPTR,A ;saved old DPTR mov DPTR,#PDPTRM + 16 ;we are going to first save the new selection pop ACC ;get the new DPTR anl A,#007h ;limit it to 0 - 7 right off the bat movx @DPTR,A ;and save. rl A ;X 2 mov DPTR,#PDPTRM ;load up base of buffer add A,DPL ;add to DPL, overflow goes to the carry flag mov DPL,A ;save result, carry flag still set rlc A ;rotate the carry into bit location 0 on ACC anl A,#001h ;limit ACC so it's just the carry flag add A,DPH ;and add the carry to DPH mov DPH,A ;and save it back ! You just performed a 8 + 16 with ;no jumps / decisions! movx A,@DPTR ;get new DPL push ACC ;temporary save to stack inc dptr movx A,@DPTR ;get new DPH push ACC ;temporary save to stack pop DPH ;restoring new DPTR to the actual DPTR pop DPL ret ;all done !