;############################################################################# ;# VAULT INFORMATION SERVICES - 8052 CODE EXAMPLE # ;# (C) Copyright 1997 by Vault Information Services # ;# # ;# This code fragment is provided to the public free of charge and WITHOUT # ;# OF ANY KIND, NEITHER EXPRESS OR IMPLIED. This code is offered as an # ;# example of 8052 programming. VIS extends no warranty regarding its # ;# functionality or fitness for a specific purpose.;# # ;# The user may utilize this code in any way he/she sees fit, including # ;# using it in his/her own program, commercial or otherwise. However, by # ;# using this code the user states his/her acceptance of the above and # ;# holds VIS indemnified against any and all claims that may arise due to # ;# the use or misuse of this code. # ;#---------------------------------------------------------------------------# ;# PURPOSE OF CODE FRAGMENT: The following code fragment includes a function # ;# called "DEC_DPTR." DEC_DPTR, when executed, will perform the exact # ;# opposite of the "INC DPTR" 8052 instruction--it will decrement the value # ;# in DPTR by one. No other registers or flags will be affected. # ;############################################################################# DEC_DPTR: XCH A,DPL ;Exchange A for DPL DEC A ;Decrement A (which is DPL) CJNE A,#0FFh,_dec_dptr2 ;If A (DPL) is not #0FFh, continue normally DEC DPH ;If A=FFh, we need to decrement DPH _dec_dptr2: XCH A,DPL ;Exchange A for DPL (thus saving DPL and restoring A) RET END