home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / JSAGE / ZSUS / PROGPACK / ARRAYS10.LBR / ARRAYD.ZZ0 / ARRAYD.Z80
Text File  |  2000-06-30  |  3KB  |  84 lines

  1. ;Library Name: ARRAYLIB
  2. ;Module Name: SERVICE
  3. ;Author: Al Hawley
  4. ;Date: 31 Mar 1987
  5. ;Version number: 1.0c
  6.  
  7. ;Version History:
  8.     
  9. ;Program Function: ARRAYLIB is a collection of subroutines which
  10. ;    implement the management of byte arrays in programs written
  11. ;    for Z80 or HD64180 based computers. This module is one of the
  12. ;    set, and may require the presence of others.
  13.  
  14. ;***************************************************
  15. ;        COPYRIGHT NOTICE
  16. ;ARRAYLIB is copyright by A. E. Hawley on March 4, 1987.
  17. ;It may be freely distributed, but it must not be sold 
  18. ;either separately or as part of a package without the 
  19. ;written consent of the author.  The author may be reached 
  20. ;via electronic mail at the Ladera Z-Node in Los Angeles,
  21. ;213-670-9465, or by Voice Phone at: 213-649-3575
  22. ;
  23. ;***************************************************
  24.  
  25.     MACLIB    ARRHDR
  26.  
  27.     name service
  28. ;This module contains the following routines:
  29.     public arvisiti,arrvisit,visit
  30.  
  31. arvisiti:
  32. ;Stores the address of a subroutine to perform
  33. ;on array elements. The subroutine should preserve
  34. ;all registers.
  35. ;input: hl = subroutine address
  36. ;exit: all registers preserved
  37.  
  38.     ld    (faddr),hl    ;store the subroutine address
  39.     ret
  40.  
  41. arrvisit:
  42. ;visit all bytes in an address range, performing
  43. ;a specified function on the contents of each address.
  44. ;on entry, hl = first address
  45. ;       de = last address
  46. ;data in support of the function may be in reg a and bc.
  47. ;on exit, hl = last address+1, de and bc are preserved
  48. ;the function to be performed is specified by passing
  49. ;its address to ARRVISIT by a call to arvisiti before
  50. ; calling ARRVISIT. when a new function is appropriate,
  51. ; arvisiti is called again.
  52.  
  53. ;note that if arvisiti has never been called, this routine
  54. ; will return having done nothing.
  55.  
  56.     push    de        ;test for end >= start
  57.     ex    de,hl
  58.     or    a        ;reset cy
  59.     sbc    hl,de        ;end - start
  60.     ex    de,hl        ;recover start in hl
  61.     pop    de        ;..and end in de
  62.     ld    a,3        ;error code if needed
  63.     ret    c        ;ret if start > end
  64.  
  65. ;This entry is for use when the above error checking
  66. ;is not required, usually having already been done.
  67. visit:    push    hl        ;save, so called routine
  68.     push    de        ;..can use 'em
  69. fcall:    call    visitx        ;bc is available for returning
  70. faddr    equ    fcall+1        ;..data from called function
  71.     pop    de
  72.     pop    hl
  73.     xor    a
  74.     push    hl        ;test for done
  75.     sbc    hl,de
  76.     pop    hl
  77.     inc    hl        ;bump array address
  78.     jr    c,visit        ;loop through address range
  79. visitx:    ret
  80.  
  81. ;**********************************************
  82.  
  83.     end
  84.