Monday, May 30, 2016

8051 Program - compare dptr to 16bit iram value

; Description:
; R0 Points To A 16 Bit Location To Compare To DPTR. Return CY == 1
; If DPTR > @R0, Else CY == 0 If DPTR <= @R0. The Operation Is
; @R0 - DPTR.
;
; Entry Requirements:
; DPTR With Value To Be Compared Against
; R0 Pointing To 16 Bit Location In Internal RAM To Compare
;
; On Exit:
; CY Set Accordingly
;
; Affected:
; PSW.CY, PSW.Z, PSW.P, Acc
;
; Stack:
; 0 Bytes, Not Including Space Used By Called Routines
;
; Comments:
; Might Be A Good Idea To Save The Accumulator
UTIL_UCOMPARE16:
clr c ; Clear For Subtract
inc r0 ; Point To Low Byte
mov a,@r0 ; Get Low Byte
subb a,dpl ; Subtract DPL
dec r0 ; Point To High Byte
mov a,@r0 ; Get High Byte
subb a,dph ; Subtract DPH
ret ; Return To Caller


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



Related topics:
8051 Program - increment 16bit in iram   |   8051 Program - compare dptr to ba   |   8051 Program - shift a 16 bit iram value 4 bits left   |   8051 Program - load dptr from (dptr) rom   |   8051 Program - load dptr from (dptr) xram   |   8051 Program - store r6r7 to dptr xram   |   8051 Program - exchange r0r1 and dptr   |   8051 Program - exchange r6r7 and dptr   |   8051 Program - memory subroutines   |   8051 Program - math subroutines   |   8051 Program - conversion subroutines

List of topics: 8051

No comments:

Post a Comment