home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / p / z33zasm.lbr / Z33MAC.LZB / Z33MAC.LIB
Encoding:
Text File  |  1993-10-25  |  4.1 KB  |  172 lines

  1.  
  2. ; Z33MAC.LIB : Macros for use with ZCPR33
  3.  
  4. ; This code is copyright (C), 1987, by Jay P. Sage, all rights reserved.
  5.  
  6.  
  7. ; General purpose macros
  8.  
  9. putreg     macro
  10.     push    hl        ; Save registers in order
  11.     push    de
  12.     push    bc
  13.      endm
  14.  
  15. getreg     macro
  16.     pop    bc        ; Restore registers in order
  17.     pop    de
  18.     pop    hl
  19.      endm
  20.  
  21. swap     macro
  22.     rrca            ; Exchange nibbles
  23.     rrca
  24.     rrca
  25.     rrca
  26.      endm
  27.  
  28. ;----------------------------------------
  29.  
  30. ; Macro for forming option bytes
  31.  
  32. ; This macro generates a byte with bits corresponding to up to 8 option
  33. ; flags.  The bits are filled in the order of the parameters and are right
  34. ; justified in the byte.
  35.  
  36. optflag    macro    #f1,#f2,#f3,#f4,#f5,#f6,#f7,#f8
  37.  
  38. flag    defl    0        ;; initial value
  39.  
  40.     irp    #temp,#f1,#f2,#f3,#f4,#f5,#f6,#f7,#f8
  41.  
  42.      if    "#temp" ne ""
  43. flag    defl    flag shl 1
  44.      if    #temp
  45. flag    defl    flag or 1
  46.      endif    ;;temp
  47.      endif    ;;not nul temp
  48.  
  49.      endm            ;; irp
  50.  
  51.     defb    low flag
  52.  
  53.      endm            ;; optflag
  54.  
  55. ;----------------------------------------
  56.  
  57. ; Macro for directory scanning
  58.  
  59. ; This macro resolves the command token for possible directory references.
  60. ; FORM1 and FORM2 can each be either "DU" or "DIR".  FORM2 can also be null.
  61. ; The two forms are scanned for in the indicated order.
  62.  
  63. ; This macro preserves the pointer to the FCB in DE and to the next
  64. ; character in the line in HL.  On return, the FCB pointer has been restored,
  65. ; and the command string pointer is still on the stack.  The routines DUSCAN
  66. ; and DIRSCAN are called as needed.
  67.  
  68. resolve    macro    #form1,#form2
  69.  
  70. ;    local    resolved
  71.  
  72.     push    hl        ; Save pointer to command string
  73.     push    de        ; Save pointer to FCB
  74.     call    #form1scan    ; Scan for the first directory form
  75.  
  76.      if    "#form2" ne ""
  77.  
  78.     jr    z,gotit        ; Resolved successfully, so jump ahead
  79.  
  80.     pop    de        ; Restore pointers for use by second call
  81.     pop    hl
  82.     push    hl        ; Save them again
  83.     push    de
  84.     call    #form2scan    ; Scan for the second directory form
  85.  
  86.      endif    ;not nul form2
  87.  
  88. gotit:
  89.     pop    de        ; Restore pointer to FCB
  90.  
  91.      endm    ;resolve
  92.  
  93. ;-----------------------------------------------------------------------------
  94.  
  95. ; Command table entry definition macro
  96.  
  97. ; Macro to form an entry for one command in the table.  The first parameter is
  98. ; the name to be used for the command (no quotes); the second parameter is the
  99. ; flag that indicates whether or not the command is to be enabled; the third
  100. ; parameter is the wheel control flag; and the last parameter is the jump
  101. ; address to the code that carries out the command.  The command names are
  102. ; automatically padded out to the correct length (they will be truncated and
  103. ; an error message will result if a command name is too long).  The characters
  104. ; in the command name are automatically converted to upper case.
  105.  
  106. command    macro #cmdname,#enableflag,#wheelflag,#address
  107.  
  108.      if    #enableflag    ;; Generate command only if enabled
  109.  
  110. whlmask    defl    #wheelflag    ;; Initialize variables
  111. count    defl    cmdsize        ;; Initialize to size of each command name
  112.  
  113.     irpc   #char,'#cmdname'    ;; Repeat over letters in command name
  114.  
  115. count    defl    count - 1    ;; Count down characters in name
  116.  
  117.      if    [ count lt cmdsize ]
  118.  
  119.         ;; If character is lower case, convert to upper case
  120.  
  121.      if    [ '#char' ge 'a' ] and [ '#char' le 'z' ]
  122.  
  123.      if    whlmask
  124.     defm    [ '#char' and 5fh ]
  125.      else    ;;not whlmask
  126.     defb    [ '#char' and 5fh ]
  127.      endif    ;;whlmask
  128.  
  129.      else    ;;not lower case
  130.  
  131.      if    whlmask
  132.     defm    '#char'     ;; If controlled by wheel, set high bit
  133.      else    ;;not whlmask
  134.     defb    '#char'        ;; If not restricted, leave high bit clear
  135.      endif    ;;whlmask
  136.  
  137.      endif    ;;lower case
  138.  
  139.      endif    ;;[ count lt cmdsize ]
  140.  
  141. whlmask    defl    false        ;; Turn off high-bit setting after first char
  142.  
  143.     endm    ;irpc
  144.  
  145.         ;; Pad command name with blanks
  146.  
  147.      if    [ count gt cmdsize ]    ;; If we underflowed
  148.     *** Command name "#cmdname" is too long / truncated ***
  149.      else
  150.     rept    count
  151.     defb    ' '
  152.     endm
  153.      endif    ;[ count gt cmdsize ]
  154.  
  155.     dw    #address    ;; Dispatch address for command
  156.  
  157.      endif    ;enable
  158.  
  159.     endm    ;command
  160.  
  161. ;---------------------------------------------------------------------------
  162.  
  163. ;One macro to resolve ZASM's trouble with pseudo-op "page"
  164.  
  165. page    macro
  166.     eject
  167.     endm
  168.  
  169.  
  170. ; End Z33MAC.LIB
  171.  
  172.