home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Oakland CPM Archive
/
oakcpm.iso
/
cpm
/
turbodos
/
td-zcpr3.lbr
/
Z33MAC.LZB
/
Z33MAC.LIB
Wrap
Text File
|
1988-12-16
|
4KB
|
160 lines
; Z33MAC.LIB : Macros for use with ZCPR33
; General purpose macros
putreg macro
push hl ; Save registers in order
push de
push bc
endm
getreg macro
pop bc ; Restore registers in order
pop de
pop hl
endm
swap macro
rrca ; Exchange nibbles
rrca
rrca
rrca
endm
;----------------------------------------
; Macro for forming option bytes
; This macro generates a byte with bits corresponding to up to 8 option
; flags. The bits are filled in the order of the parameters and are right
; justified in the byte.
optflag macro f1,f2,f3,f4,f5,f6,f7,f8
flag defl 0 ;; initial value
irp temp,<f1,f2,f3,f4,f5,f6,f7,f8>
if not nul temp
flag defl flag shl 1
if temp
flag defl flag or 1
endif ;;temp
endif ;;not nul temp
endm ;; irp
defb low flag
endm ;; optflag
;----------------------------------------
; Macro for directory scanning
; This macro resolves the command token for possible directory references.
; FORM1 and FORM2 can each be either "DU" or "DIR". FORM2 can also be null.
; The two forms are scanned for in the indicated order.
; This macro preserves the pointer to the FCB in DE and to the next
; character in the line in HL. On return, the FCB pointer has been restored,
; and the command string pointer is still on the stack. The routines DUSCAN
; and DIRSCAN are called as needed.
resolve macro form1,form2
local resolved
push hl ; Save pointer to command string
push de ; Save pointer to FCB
call form1&scan ; Scan for the first directory form
if not nul form2
jr z,gotit ; Resolved successfully, so jump ahead
pop de ; Restore pointers for use by second call
pop hl
push hl ; Save them again
push de
call form2&scan ; Scan for the second directory form
endif ;not nul form2
gotit:
pop de ; Restore pointer to FCB
endm ;resolve
;-----------------------------------------------------------------------------
; Command table entry definition macro
; Macro to form an entry for one command in the table. The first parameter is
; the name to be used for the command (no quotes); the second parameter is the
; flag that indicates whether or not the command is to be enabled; the third
; parameter is the wheel control flag; and the last parameter is the jump
; address to the code that carries out the command. The command names are
; automatically padded out to the correct length (they will be truncated and
; an error message will result if a command name is too long). The characters
; in the command name are automatically converted to upper case.
command macro cmdname,enableflag,wheelflag,address
if enableflag ;; Generate command only if enabled
whlmask defl wheelflag ;; Initialize variables
count defl cmdsize ;; Initialize to size of each command name
irpc char,cmdname ;; Repeat over letters in command name
count defl count - 1 ;; Count down characters in name
if [ count lt cmdsize ]
;; If character is lower case, convert to upper case
if [ '&char' ge 'a' ] and [ '&char' le 'z' ]
if whlmask
defb [ '&char' and 5fh ] + 80h
else ;;not whlmask
defb [ '&char' and 5fh ]
endif ;;whlmask
else ;;not lower case
if whlmask
defb '&char' + 80h ;; If controlled by wheel, set high bit
else ;;not whlmask
defb '&char' ;; If not restricted, leave high bit clear
endif ;;whlmask
endif ;;lower case
endif ;;[ count lt cmdsize ]
whlmask defl false ;; Turn off high-bit setting after first char
endm ;irpc
;; Pad command name with blanks
if [ count gt cmdsize ] ;; If we underflowed
*** Command name "&cmdname" is too long / truncated ***
else
rept count
defb ' '
endm
endif ;[ count gt cmdsize ]
dw address ;; Dispatch address for command
endif ;enable
endm ;command
; End Z33MAC.LIB