Monday, May 30, 2016

8051 Program - subtract acc from dptr

; Description:
; Subtract Acc From DPTR, Setting Carry If DPTR Underflows
;
; Entry Requirements:
; DPTR Has Value
; Acc Has Value To Subtract
;
; On Exit:
; DPTR = DPTR - Acc, CY Set Accordingly
;
; Affected:
; PSW.CY, DPTR
;
; Stack:
; 1 Bytes, Not Including Space Used By Called Routines
;
; Comments:
; Value Of CY On Entry Does Not Affect Result
;
UTIL_SUBBAD:
push acc ; Make Sure Acc Gets Saved
clr c ; Clear For SUBB
xch a,dpl ; Swap
subb a,dpl ; Subtract
mov dpl,a ; Move Back To DPL
mov a,dph ; Get DPH
subb a,#000h ; If Carry Set, This Will Decrement
mov dph,a ; Move Back To DPH
pop acc ; Recover Original 'A'
ret ; Return To Caller


Source: Assorted Utilities, John C. Wren 11/23/96



Related topics:
8051 Program - add acc to dptr   |   8051 Program - add ba to dptr   |   8051 Program - subtract ba from dptr   |   8051 Program - 2s complement dptr   |   8051 Program - decrement dptr   |   8051 Program - memory subroutines   |   8051 Program - math subroutines   |   8051 Program - conversion subroutines

List of topics: 8051

No comments:

Post a Comment