home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
fortran
/
compiler
/
sbm
/
sbm.mac
< prev
next >
Wrap
Text File
|
1991-01-09
|
8KB
|
337 lines
list-
CR equ 0dh
LF equ 0ah
ESC equ 1Bh
FF equ 0Ch
TAB equ 09h
BS equ 08h
COMMA equ 2Ch
QUOTE equ 27h
QUOTES equ '"'
TILDE equ '~'
MARKER equ '|'
False equ 0
True equ 1
; M A C R O S
; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;------------------------------------------------------------
^HANDLE macro {IOCB}
mov bx,offset {iocb}
mov bp,[bx-2]
endm
;-----------------------------------
^OPEN_INPUT macro {filename}
mov bx,offset {filename}
call v06
endm
;-----------------------------------
^OPEN_OUTPUT macro {filename}
mov bx,offset {filename}
call v30
endm
;-----------------------------------
^READ macro {iocb},{alternate}
mov bx,offset {iocb}
ifn type({alternate})=type()
mov di,offset {alternate}
call v05 ; buffin_alt
else
call v04 ; buffin
endif
endm
;--------------------------------
^WRITE macro {iocb}, {buffer}, {tail}
if value({iocb})=1
mov bp,1
elseif value({iocb})='*'
mov bp,1
else
mov bx,offset {iocb}
mov bp,[bx-2]
endif
ifn type({buffer})=type()
mov bx,offset {buffer}
endif
call v33
if value({tail})=cr
^crlf {iocb}
endif
Endm
;--------------------------------
;$P
^OUTBLK macro {iocb},{string},{tail}
if value({iocb})=1
mov bp,1
else
mov bx,offset {iocb}
mov bp,[bx-2]
endif
call v31
db {string}
if value({tail})=cr
db cr,lf,0
else
db {tail}
endif
Endm
;--------------------------------
^SHOW_CHAR macro {char}
mov ah,2
ifn type({char})=type()
mov dl,{char}
else
mov dl,al
endif
int 21h
Endm
;--------------------------------
^CRLF macro {IOCB}
if value({iocb})=1
mov bp,1
else
mov bp,offset {iocb}
mov bp,[bp-2]
endif
call v31 ; outblk
db cr,lf,0
Endm
;-----------------------------------
^CONOUT macro {string},{tail}
call v07
db {string}
if value({tail})=cr
db cr,lf,0
else
db {tail}
endif
Endm
;------------------------------------
^REWIND macro {filename}
mov bx,offset {filename}
mov bx,[bx-2]
mov ax,4200h
mov cx,00
mov dx,00
int 21h
Endm
;----------------------------------------
;$P
^GET_FILE_POINTER macro {filename}, {locn}
mov bx,offset {filename}
mov bx,[bx-2]
if value({locn}) = 'S'
mov ax,4200h
endif
if value({locn}) = 'C'
mov ax,4201h
endif
if value({locn}) = 'E'
mov ax,4202h
endif
mov cx,00
mov dx,00
int 21h
mov cx,ax
Endm
;----------------------------------------
^LOAD_FILE macro {filename}, {address}
mov bx,offset {filename}
mov bx,[bx-2]
mov dx,offset {address}
mov ah,3Fh
int 21h
Endm
;----------------------------------------
^WRITE_FILE macro {filename}, {address}
mov bx,offset {filename}
mov bx,[bx-2]
mov dx,offset {address}
mov ah,40h
int 21h
Endm
;----------------------------------------
^COMMAND_TAIL_TO macro {array}
mov di,offset {array}
call v10
Endm
;--------------------------
^FIND_CHAR macro {char},{array}
if type({array}) = type(bx)
mov bx, {array}
else
mov bx, offset {array}
endif
mov ah,{char}
call v19
Endm
;------------------------
;$P
^FNB_THEN_COPY macro {source},{destination}
mov bx,offset {source}
mov di,offset {destination}
call v21
Endm
;----------------------------
^DATA macro {array}, {string}
if type({array}) = type(bx)
mov di,{array}
else
mov di,offset {array}
endif
call v42
db {string},0
Endm
; ----------------------------
^SETDATA macro {destin}, {source}
mov si,offset {source}
mov di,offset {destin}
mov cx,[si-2]
rep
movsb
Endm
; ----------------------------
^COPY macro {from},{to}
if type({from}) = type(bx)
mov bx,{from}
else
mov bx,offset {from}
endif
if type({to}) = type(bx)
mov di,{to}
else
mov di,offset {to}
endif
call v08 ; copy
Endm
; ----------------------------
^COPY_TIL macro {char}, {from}, {to}
if type({from}) = type(bx)
mov bx,{from}
else
mov bx,offset {from}
endif
if type({to}) = type(bx)
mov di,{to}
else
mov di,offset {to}
endif
mov ah,{char}
call v11
Endm
; -----------------------------------------
^FILL macro {buffer},{spaces},{char}
mov di,offset {buffer}
mov al,{char}
mov cx,{spaces}
rep
stosb
Endm
; -----------------------------------------
; create a new file, deleting any existing.
^DOS_CREATE macro {filename}
jmp b
a db {filename},0
b mov dx,offset a
mov cx,00
mov ah,3Ch
int 21h
Endm
; ---------------------------------------------------------------
;$P
; COMPARE: macro to compare an unknown string (given) with a known (model)
; string. The model must be an ASCIIZ string and may be defined as
; an array name or immediate data.
; compare known,'model' compare known, other-known
^compare macro {given}, {model}
mov si,offset {given}
if type({model}) and type ([0])=0
call v17
db {model},0
Else
mov bx,offset {model}
call v41
Endif
Endm
; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
; PARSE: macro to parse the leading keword from a given string. The keword
; is removed from the string and the string then left-justified.
; delims optional if you want more than blank, comma, equals.
^PARSE macro {String_address}, {Keword_address}, {delims}
call v36
Dw offset {String_address}, offset {keword_address}
Db {delims},0
Endm
;-- the following version loads the registers before the call and is needed
;-- for RTL operations.
^PARCE macro {String_address}, {Keword_address}, {delims}
mov si,offset {string_address}
mov dx,si
mov di,offset {keword_address}
mov bp,offset {delims}
call v34
Endm
; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
^PARSE_ONLY macro {String_address}, {Keword_address}, char
mov ah,char
mov si,offset {string_address}
mov dx,si
mov di,offset {keword_address}
call v35
Endm
; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
^TABLE_LOOKUP macro {model},{table}
mov bp,offset {model}
mov si,offset {table}
call v44
endm
; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
^TABLE_ADD macro {token}
mov di,si
mov si,offset {token}
call v09
mov byte[di],'$'
endm
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
^UPCASE macro {string}
mov di,offset {string}
mov si,offset {string}
call v09
endm
; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
^CTOI macro {variable} ; converts variable to binry. CY if not numeric.
mov al,{variable}
call v12
endm
; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
^DECBIN macro {string} ; converts string to binry, DX,AX
mov bx,offset {string}
call v14
Endm
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
^BINDEC macro {string},{nchar} ; converts DX,AX to string
mov di,offset {string}
mov cx,{nchar}
call v03
Endm
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
^APPEND macro {string1}, {string2}
^find_char 0,{string1}
mov di,bx
mov bx,offset {string2}
call v08
Endm
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
^ASCNTR macro {array}
mov bx,offset {array}
call v01
Endm
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
; END MACROS