Monday, May 30, 2016

8051 Program - locate ETX in string

; Description:
; If An ETX Is Found, Return With DPTR Pointing To It, And CY == 0. If
; No ETX Found, Return DPTR Pointing At One Byte Past End, And CY == 1.
;
; Entry Requirements:
; DPTR Points To External Memory
; R0 Contains Maximum Length To Search
;
; On Exit:
; CY == 0 Indicates ETX Found, DPTR Points To ETX
; CY == 1 Indicated ETX Not Found, DPTR = DPTR + R0
;
; Affected:
; PSW.CY, PSW.Z, PSW.P, Acc, DPTR, R0
;
; Stack:
; 1 Bytes, Not Including Space Used By Called Routines
;
; Comments:
; None
;
ETX equ 3 ; ASCII ETX Character
UTIL_FIND_ETX:
push 0 ; Save R0
;
loop1:movx a,@dptr ; Get Character
cjne a,#ETX,temp ; If ETX, Skip
temp:jmp loop2 ;
inc dptr ; Next Location
djnz r0,loop1 ; Repeat Up To R0
;
pop 0 ; Recover R0
setb c ; ETX Not Found
ret ; Return To Caller
;
loop2:pop 0 ; Recover R0
clr c ; ETX Found
ret ; Return To Caller


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



Related topics:
8051 Program - replace 0x00 with ETX in string   |   8051 Program - remove trailing spaces   |   8051 Program - return length of string   |   8051 Program - memory subroutines   |   8051 Program - math subroutines   |   8051 Program - conversion subroutines

List of topics: 8051

No comments:

Post a Comment