Monday, May 30, 2016

8051 Program - 2s complement dptr

; Description:
; Subtract 'DPTR' From 0, Setting Carry If DPTR Underflows
;
; Entry Requirements:
; DPTR Has Value To Perform 2's Complement On
;
; On Exit:
; DPTR = 0 - DPTR
;
; Affected:
; PSW.CY
;
; Stack:
; 1 Bytes, Not Including Space Used By Called Routines
;
; Comments:
; None
UTIL_DPTR2C:
push acc ; Make Sure Acc Gets Saved
clr c ; Clear For SUBB
clr a ; Clear For Subtract
subb a,dpl ; Subtract
mov dpl,a ; Move Back To DPL
clr a ; Clear For Subtract
subb a,dph ; 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 acc from dptr   |   8051 Program - subtract ba from 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