home *** CD-ROM | disk | FTP | other *** search
- ; File......: MINTER.MAC (MASM 5.1)
- ; Author....: David Minter
- ; Date......: $Date: 14 Jun 1991 19:55:24 $
- ; Revision..: $Revision: 1.1 $
- ; Log file..: $Logfile: E:/nanfor/src/minter.mav $
- ;
- ; This is an original work by David Minter and is placed in the
- ; public domain.
- ;
- ; Modification history:
- ; ---------------------
- ;
- ; $Log: E:/nanfor/src/minter.mav $
- ;
- ; Rev 1.1 14 Jun 1991 19:55:24 GLENN
- ; Minor edit to file header
- ;
- ; Rev 1.0 01 Apr 1991 01:04:00 GLENN
- ; Nanforum Toolkit
- ;
-
-
- ; Some Equates
-
- ; DOS interrupts for file management
-
- OPENFILE equ 03dh
- CLOSEFILE equ 03eh
- READFILE equ 03fh
- WRITEFILE equ 040h
- DELETEFILE equ 041h
- SEEKFILE equ 042h
-
-
- ;----------------------------------------------------------------------------
- ; @SAVE - save registers on the stack
- ;----------------------------------------------------------------------------
- @SAVE macro r1,r2,r3,r4,r5,r6,r7,r8,r9
-
- IRP Reg,<r1,r2,r3,r4,r5,r6,r7,r8,r9>
- IFNB <Reg>
- push Reg
- ENDIF
- endm
- endm
-
- ;----------------------------------------------------------------------------
- ; @RESTORE - restore registers from stack
- ;----------------------------------------------------------------------------
- @RESTORE macro r1,r2,r3,r4,r5,r6,r7,r8,r9
-
- IRP Reg,<r9,r8,r7,r6,r5,r4,r3,r2,r1>
- IFNB <Reg>
- pop Reg
- ENDIF
- endm
- endm
-
- ;----------------------------------------------------------------------------
- ; @DOSREQ - DOS function request using INT 21h
- ;----------------------------------------------------------------------------
- @DOSREQ macro function
-
- mov ah,function
- int 21h
-
- endm
-
-
- ;----------------------------------------------------------------------------
- ; @CALL - call a procedure
- ;----------------------------------------------------------------------------
- @CALL macro procedure,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14
-
- _COUNT_ = 0
-
- EXTRN procedure:far
-
- IRP REG,<r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14>
- IFNB <REG>
- _COUNT_ = _COUNT_ + 1
- push REG
- ENDIF
- endm
-
- call procedure
- if _COUNT_
- add sp,_COUNT
- endif
-
- endm
-
- ;----------------------------------------------------------------------------
- ; @BEGIN - Initialize a procedure macro
- ;----------------------------------------------------------------------------
- @BEGIN macro procedure
-
- .code
-
- public procedure
- procedure proc far
-
- endm
-
- ;----------------------------------------------------------------------------
- ; @END - end a procedure
- ;----------------------------------------------------------------------------
- @END macro procedure
- procedure endp
- end
-
- endm
-
- ;----------------------------------------------------------------------------
- ; @PARINFO - get information about type of parameter passed,
- ; or the number of paramters passed. An integer is
- ; returned in the AX register that denotes the type
- ; of paramter passed
- ;----------------------------------------------------------------------------
- @PARINFO macro _param
-
- EXTRN __parinfo
-
- mov ax,_param
- push ax
- call __parinfo
- add sp,2
-
- endm
-
- ;----------------------------------------------------------------------------
- ; @PARINFA - get information about type of an array element, or
- ; the number of elements in the array passed. An
- ; integer is returned in the AX register that denotes
- ; the type of an array element, or the number of
- ; elements in the array
- ;----------------------------------------------------------------------------
- @PARINFA macro _element,_param
-
- EXTRN __parinfa
-
- mov ax,_element
- push ax
- mov ax,_param
- push ax
- call __parinfa
- add sp,4
-
- endm
-
- ;----------------------------------------------------------------------------
- ; @PARC - get a string from Clipper into dx:ax
- ;----------------------------------------------------------------------------
- @PARC macro _param
-
- EXTRN __parc:far
-
- mov ax,_param ;get paramter we want
- push ax ;send to __parc
- call __parc ;call it
- add sp,2 ;clear the stack
- ;dx:ax now contains the address
-
- endm
-
- ;----------------------------------------------------------------------------
- ; @PARCLEN - gets length of a string from Clipper in AX
- ;----------------------------------------------------------------------------
- @PARCLEN macro _param
-
- EXTRN __parclen:far
-
- mov ax,_param
- push ax
- call __parclen
- add sp,2
-
- endm
-
- ;----------------------------------------------------------------------------
- ; @PARCSIZ - get allocated size of a string from Clipper. It
- ; returns an integer in the AX register
- ;----------------------------------------------------------------------------
- @PARCSIZ macro _param
-
- EXTRN __parcsiz:far
-
- mov ax,_param
- push ax
- call __parcsiz
- add sp,2
-
- endm
-
- ;----------------------------------------------------------------------------
- ; @PARDS - get a date string from clipper. It returns a pointer
- ; to a string in the DX:AX regiters. The string is in
- ; the format YYYYMMDD
- ;----------------------------------------------------------------------------
- @PARDS macro _param
-
- EXTRN __pards:far
-
- mov ax,_param
- push ax
- call __pards
- add sp,2
-
- endm
-
- ;----------------------------------------------------------------------------
- ;@PARNI - gets an integer from clipper in the AX register
- ;----------------------------------------------------------------------------
- @PARNI macro _param
-
- EXTRN __parni:far
-
- mov ax,_param
- push ax
- call __parni
- add sp,2
-
- endm
-
- ;----------------------------------------------------------------------------
- ;@PARL - gets a logical from Clipper in the AX Register. Logical .T.
- ; will equal 1, logical .F. will equal 0
- ;----------------------------------------------------------------------------
- @PARL macro _param
-
- EXTRN __parl:far
-
- mov ax,_param
- push ax
- call __parl
- add sp,2
-
- endm
-
- ;----------------------------------------------------------------------------
- ;@PARNL - gets a long value from Clipper in the DX:AX register
- ;----------------------------------------------------------------------------
- @PARNL macro _param
-
- EXTRN __parnl:far
-
- mov ax,_param
- push ax
- call __parnl
- add sp,2
-
- endm
-
- ;----------------------------------------------------------------------------
- ; @RETC - return a string to Clipper
- ;----------------------------------------------------------------------------
- @RETC macro _param
-
- EXTRN __retc:FAR
-
- mov dx, seg _param
- mov ax, offset _param
- push dx
- push ax
- call __retc
- add sp, 4
-
- endm
-
- ;----------------------------------------------------------------------------
- ; @RETL - return a logical to Clipper
- ;----------------------------------------------------------------------------
- @RETL macro _param
-
- EXTRN __retl:FAR
-
- mov ax,_param
- push ax
- call __retl
- add sp, 2
-
- endm
-
- ;----------------------------------------------------------------------------
- ; @RET - return a Nil to clipper
- ;----------------------------------------------------------------------------
- @RET macro
-
- EXTRN __ret:FAR
- call __ret
-
- endm
-
- ;----------------------------------------------------------------------------
- ; @FOPEN - Open a file, requires pointer to name, open mode
- ; returns a handle in AX, or -1 for error. Open mode
- ; defaults to 0 if not passed
- ;----------------------------------------------------------------------------
- @FOPEN macro _segment,_offset,_openmode
- local _SkipError ;local label used in macro only
-
- @SAVE ds,dx ;save DS and DX
-
- mov ax,_segment ;get the segment of the file name
- mov ds,ax ;into DS as required by DOS
-
- mov dx,_offset ;get offset of filename as required
-
- IFNB _openmode ;if openmode passed
- mov al,_openmode ;use it
- ELSE ;else
- xor al,al ;use 0 as the default mode
- ENDIF
-
- @DOSREQ OPENFILE ;handle now in AX, or error code
-
- @RESTORE ds,dx ;restore DS and DX
-
- jnc _SkipError ;if no carry flag, don't change AX
- mov ax,-1 ;else return -1 for error
- _SkipError:
-
- endm
-