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 / CPM / ZCPR33 / S-Z / ZCPR33.LBR / Z33MAC.LZB / Z33MAC.LIB
Text File  |  2000-06-30  |  4KB  |  160 lines

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