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 / BEEHIVE / ZSUS / ZSUS009.LBR / NZFCP13.LBR / Z34MAC.LZB / Z34MAC.LIÂ
Text File  |  1990-07-14  |  3KB  |  122 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. ; Command table entry definition macro
  55.  
  56. ; Macro to form an entry for one command in the table.  The first parameter is
  57. ; the name to be used for the command (no quotes); the second parameter is the
  58. ; flag that indicates whether or not the command is to be enabled; the third
  59. ; parameter is the wheel control flag; and the last parameter is the jump
  60. ; address to the code that carries out the command.  The command names are
  61. ; automatically padded out to the correct length (they will be truncated and
  62. ; an error message will result if a command name is too long).  The characters
  63. ; in the command name are automatically converted to upper case.
  64.  
  65. command    macro cmdname,enableflag,wheelflag,address
  66.  
  67.      if    enableflag    ;; Generate command only if enabled
  68.  
  69. whlmask    defl    wheelflag    ;; Initialize variables
  70. count    defl    cmdsize        ;; Initialize to size of each command name
  71.  
  72.     irpc    char,cmdname    ;; Repeat over letters in command name
  73.  
  74. count    defl    count - 1    ;; Count down characters in name
  75.  
  76.      if    [ count lt cmdsize ]
  77.  
  78.         ;; If character is lower case, convert to upper case
  79.  
  80.      if    [ '&char' ge 'a' ] and [ '&char' le 'z' ]
  81.  
  82.      if    whlmask
  83.     defb    [ '&char' and 5fh ] + 80h
  84.      else    ;;not whlmask
  85.     defb    [ '&char' and 5fh ]
  86.      endif    ;;whlmask
  87.  
  88.      else    ;;not lower case
  89.  
  90.      if    whlmask
  91.     defb    '&char' + 80h    ;; If controlled by wheel, set high bit
  92.      else    ;;not whlmask
  93.     defb    '&char'        ;; If not restricted, leave high bit clear
  94.      endif    ;;whlmask
  95.  
  96.      endif    ;;lower case
  97.  
  98.      endif    ;;[ count lt cmdsize ]
  99.  
  100. whlmask    defl    false        ;; Turn off high-bit setting after first char
  101.  
  102.     endm    ;irpc
  103.  
  104.         ;; Pad command name with blanks
  105.  
  106.      if    [ count gt cmdsize ]    ;; If we underflowed
  107.     *** Command name "&cmdname" is too long / truncated ***
  108.      else
  109.     rept    count
  110.     defb    ' '
  111.     endm
  112.      endif    ;[ count gt cmdsize ]
  113.  
  114.     dw    address        ;; Dispatch address for command
  115.  
  116.      endif    ;enable
  117.  
  118.     endm    ;command
  119.  
  120. ; End Z33MAC.LIB
  121.  
  122.