Monday, May 30, 2016

8051 Program - replace 0x00 with ETX in string

; Description:
; Search Data Memory DPTR Points To Until A 0x00 Is Found, Or R0 Is 0,
; And Replace With An ETX. DPTR Points To Data, R0 Contains Maximum
; Length To Search
;
; Entry Requirements:
; DPTR Points To A 0 Terminated String In External Memory
; R0 Contains Maximum Length To Search
;
; On Exit:
; R0 = 0
;
; Affected:
; PSW.Z, PSW.P, Acc, DPTR, R0
;
; Stack:
; 2 Bytes, Not Including Space Used By Called Routines
;
; Comments:
; None
;
ETX equ 3 ; ASCII ETX Character
UTIL_PUT_ETX:
push dph ; Save DPH
push dpl ; Save DPL
;
loop1:movx a,@dptr ; Get Character
jz loop2 ; If 0, Replace And Exit
inc dptr ; Next Location
djnz r0,loop1 ; Repeat For R0 Bytes
;
loop2:mov a,#ETX ; ETX Character
movx @dptr,a ; Store It
;
pop dpl ; Recover DPL
pop dph ; Recover DPH
ret ; Return To Caller


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



Related topics:
8051 Program - locate 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