home *** CD-ROM | disk | FTP | other *** search
- ;Library Name: ARRAYLIB
- ;Module Name: SERVICE
- ;Author: Al Hawley
- ;Date: 31 Mar 1987
- ;Version number: 1.0c
-
- ;Version History:
-
- ;Program Function: ARRAYLIB is a collection of subroutines which
- ; implement the management of byte arrays in programs written
- ; for Z80 or HD64180 based computers. This module is one of the
- ; set, and may require the presence of others.
-
- ;***************************************************
- ; COPYRIGHT NOTICE
- ;ARRAYLIB is copyright by A. E. Hawley on March 4, 1987.
- ;It may be freely distributed, but it must not be sold
- ;either separately or as part of a package without the
- ;written consent of the author. The author may be reached
- ;via electronic mail at the Ladera Z-Node in Los Angeles,
- ;213-670-9465, or by Voice Phone at: 213-649-3575
- ;
- ;***************************************************
-
- MACLIB ARRHDR
-
- name service
- ;This module contains the following routines:
- public arvisiti,arrvisit,visit
-
- arvisiti:
- ;Stores the address of a subroutine to perform
- ;on array elements. The subroutine should preserve
- ;all registers.
- ;input: hl = subroutine address
- ;exit: all registers preserved
-
- ld (faddr),hl ;store the subroutine address
- ret
-
- arrvisit:
- ;visit all bytes in an address range, performing
- ;a specified function on the contents of each address.
- ;on entry, hl = first address
- ; de = last address
- ;data in support of the function may be in reg a and bc.
- ;on exit, hl = last address+1, de and bc are preserved
- ;the function to be performed is specified by passing
- ;its address to ARRVISIT by a call to arvisiti before
- ; calling ARRVISIT. when a new function is appropriate,
- ; arvisiti is called again.
-
- ;note that if arvisiti has never been called, this routine
- ; will return having done nothing.
-
- push de ;test for end >= start
- ex de,hl
- or a ;reset cy
- sbc hl,de ;end - start
- ex de,hl ;recover start in hl
- pop de ;..and end in de
- ld a,3 ;error code if needed
- ret c ;ret if start > end
-
- ;This entry is for use when the above error checking
- ;is not required, usually having already been done.
- visit: push hl ;save, so called routine
- push de ;..can use 'em
- fcall: call visitx ;bc is available for returning
- faddr equ fcall+1 ;..data from called function
- pop de
- pop hl
- xor a
- push hl ;test for done
- sbc hl,de
- pop hl
- inc hl ;bump array address
- jr c,visit ;loop through address range
- visitx: ret
-
- ;**********************************************
-
- end
-