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 / ARRAYE.ZZ0 / ARRAYE.Z80
Text File  |  2000-06-30  |  2KB  |  75 lines

  1. ;Library Name: ARRAYLIB
  2. ;Module Name: ABITOP
  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 abitop
  28. ;This module contains the following routines:
  29.     public arresbit,arsetbit,artstbit
  30.  
  31. ;routines to set, reset, or test a bit.
  32. ;on entry:
  33. ;    a  = bit number (0-7)
  34. ;    hl = address of the byte
  35. ;on exit:
  36. ;    hl, de are preserved
  37. ;    b  = 46h(test) or 0c6h(set) or 86h(res)
  38. ;if z,    c = a = 0
  39. ;if nz,    c = a = 0ffh
  40. ; the z/nz returns are significant only when
  41. ; the test operation is performed.
  42.  
  43. ;these routines work by synthesizing the opcode
  44. ;for a z80 'cb' instruction.
  45.  
  46. arresbit:    ;entry point to reset a bit
  47.     ld    b,86h
  48.     jr    makop
  49.  
  50. arsetbit:    ;entry point to set a bit
  51.     ld    b,0c6h
  52.  
  53. makop:    rlc    a        ;rotate the bit number
  54.     rlc    a        ;into the 3-4-5
  55.     rlc    a        ;position in the accumulator
  56.     or    a,b
  57.     ld    (opcode),a    ;install the opcode
  58.     db    0cbh        ;and execute the instruction
  59. opcode:    db    0        ;..to do a bit, res, or set
  60.     ret
  61.  
  62. artstbit:    ;entry point to test a bit
  63.     ld    b,46h
  64.     call    makop        ;do the test
  65.     ld    c,0ffh        ;adjust regs c and a
  66.     ld    a,c
  67.     ret    nz
  68.     inc    c
  69.     ld    a,c
  70.     ret
  71.  
  72. ;*************************************
  73.  
  74.     end
  75.