home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
extra
/
promlb.mac
< prev
next >
Wrap
Text File
|
1988-08-16
|
15KB
|
563 lines
.TITLE KERMLB - Kermit Macro library
.SBTTL Robert C. McQueen/S Hecht
;++
; This file contains the various macros and symbol definitions for
; PRO/Kermit. All of the symbol definitions are defined in the KERDEF
; macro
; Create using: LIBRARY/RSX/CREATE/MACRO KERMLB KERMLB
;--
; Version:
.IDENT /1.0.03/
.SBTTL Revision History
;++
;
; 1.0.00 By: Robert C. Mcqueen
; Create this module
;
; 1.0.01 By: Stuart Hecht On: 24-Feb-1984
; Change MSG macro so that the length does not include the
; null byte at the end.
;
; 1.0.02 By: Robert C. McQueen On: 5-March-1984
; Add SPAWN EFN (SPNEFN).
;
; 1.0.03 By: Robert C. McQueen On: 8-March-1984
; Clean the module some and add the InterTask Communication
; EFN (ITCEFN).
;
; 1.0.04 By: Robert C. McQueen On: 12-March-1984
; Change the intertask communications to use send/receive data.
;--
.MACRO KERDEF
keyerr= -16 ; Code returned in status when a
; function key was pressed on a menu
badcod= -7 ; Code returned in status
lefone= 1*400 ; A one in the left byte
putdat= 1 ; Put data in flag.
;
; Logical Unit Numbers
;
TERLUN= 7. ; Terminal LUN number
XKLUN= 8. ; Communications port LUN
DFLLUN= 10. ; Defaults file LUN
;
; Event falgs used by KERMIT
;
TTAEFN= 0 ; Terminal attach/detach EFN
TTREFN= 1 ; Terminal read event flag number
TTWEFN= 2 ; Terminal write EFN
XKAEFN= 3 ; Communication attach/detach EFN
XKREFN= 4 ; Communication read EFN
XKWEFN= 5 ; Communication write EFN
GENEFN= 6 ; General EFN
CONEFN= 7 ; Connect processing EFN
SPNEFN=10 ; Spawn EFN
ITCEFN=11 ; Intertask communication EFN
RESEFN=12 ; Resume EFN
;
; File modes that are possible
;
MODBLK =0
MODASC =1
MODBIN =2
MODFIX =3
;
; Random items
;
ON= 1 ; Value for on (bit set)
off= 0 ; Value for off (bit clear)
true= 1 ; Value for true
false= 0 ; Value for false
msb = 100000 ; Most significant bit for BIC/BIS
knormal == ^b000000001 ; 001 = information
internalerr == ^b000001010 ; 010 = error
cmderr == ^b000010010
illeol == ^b000011010
illpktlen == ^b000100010
illpadchr == ^b000101010
illnpad == ^b000110010
lintoolng == ^b000111010
eof == ^b001000001
rms11 == ^b001001010
nomorfiles == ^b001010001
illfiltyp == ^b001011010
rec.too.big == ^b001100010
errmsg == ^b001101010
chksumerr == ^b001110010
snderr == ^b001111010
retries == ^b010000010
iexit == ^b010001001
unimplgen == ^b010010010
unisrv == ^b010011010
protoerr == ^b010100010
timeout == ^b010110100 ; 100 = warning
aborted == ^b010111010
recerr == ^b011000010
.ENDM
.SBTTL Symbols for the control characters
.MACRO CHRDEF
.CHCAT= 000 ; Control atsign (@) (Null)
.CHCNA= 001 ; Control A
.CHCNB= 002 ; Control B
.CHCNC= 003 ; Control C
.CHCND= 004 ; Control D
.CHCNE= 005 ; Control E
.CHCNF= 006 ; Control F
.CHCNG= 007 ; Control G (Bell)
.CHCNH= 010 ; Control H (Backspace)
.CHCNI= 011 ; Control I (Tab)
.CHCNJ= 012 ; Control J (Line feed)
.CHCNK= 013 ; Control K (Vertical tab)
.CHCNL= 014 ; Control L (Form feed)
.CHCNM= 015 ; Control M (Carriage return)
.CHCNN= 016 ; Control N
.CHCNO= 017 ; Control O
.CHCNP= 020 ; Control P
.CHCNQ= 021 ; Control Q
.CHCNR= 022 ; Control R
.CHCNS= 023 ; Control S
.CHCNT= 024 ; Control T
.CHCNU= 025 ; Control U
.CHCNV= 026 ; Control V
.CHCNW= 027 ; Control W
.CHCNX= 030 ; Control X
.CHCNY= 031 ; Control Y
.CHCNZ= 032 ; Control Z
.CHCLB= 033 ; Control left bracket
.CHCBS= 034 ; Control back slash
.CHCRB= 035 ; Control right bracket
.CHCCF= 036 ; Control circonflex
.CHCUN= 037 ; Control underline
; Symbols with ASCII names for control characters
.CHNUL= 000 ; Null (tape feed character, fill character)
.CHSOH= 001 ; Start of header
.CHSTX= 002 ; Start of text
.CHETX= 003 ; End of text
.CHEOT= 004 ; End of transmission
.CHENQ= 005 ; Enquiry (WRU "Who are you?")
.CHACK= 006 ; Acknowledge
.CHBEL= 007 ; Bell
.CHBS= 010 ; Backspace
.CHHT= 011 ; Horizontal tab
.CHLF= 012 ; Line feed
.CHVT= 013 ; Vertical tab
.CHFF= 014 ; Form feed
.CHCR= 015 ; Carriage return
.CHSO= 016 ; Shift out
.CHSI= 017 ; Shift in
.CHDLE= 020 ; Data link escape
.CHDC1= 021 ; Device control 1 (also XON)
.CHDC2= 022 ; Device control 2 (also TAPE or AUX ON)
.CHDC3= 023 ; Device control 3 (also XOFF)
.CHDC4= 024 ; Device control 4 (also AUX OFF)
.CHNAK= 025 ; Negative acknowledge
.CHSYN= 026 ; Synchronous idle (SYNC)
.CHETB= 027 ; End of transmission block
.CHCAN= 030 ; Cancel
.CHEM= 031 ; End of medium
.CHSUB= 032 ; Substitute
.CHESC= 033 ; Escape
.CHFS= 034 ; File separator
.CHGS= 035 ; Group separator
.CHRS= 036 ; Record separator
.CHUS= 037 ; Unit separator
.CHSPC= 040 ; Space
.CHSEM= '; ; Semicolon
.CHCMA= ', ; Comma
.CHALT= 175 ; Old altmode
.CHAL2= 176 ; Other type of old altmode
.CHDEL= 177 ; Delete
.CHCSI= 233 ; CSI
; Alternate names for motion characters
.CHTAB= .CHHT ; Tab
.CHLFD= .CHLF ; Line feed
.CHVTB= .CHVT ; Vertical tab
.CHFFD= .CHFF ; Form feed
.CHCRT= .CHCR ; Carriage return
.ENDM
.SBTTL Macros -- Bit definitions
;++
; The following gives names to the various bits that are found in
; this small machine. It really needs 20 more bits
;--
.MACRO BITS
B0=001 ;; Bit 0
B1=002 ;; Bit 1
B2=004 ;; Bit 2
B3=010 ;; Bit 3
B4=020 ;; Bit 4
B5=040 ;; Bit 5
B6=100 ;; Bit 6
B7=200 ;; Bit 7
.ENDM
.SBTTL Macro definitions -- IOSBDF - IOSB definitions
;++
; The following symbols define the format of an IOSB
;--
.MACRO IOSBDF
IB.STS= 0 ; Status byte
IB.XXX= 1 ; Other half (I forget what this is)
IB.CNT= 2 ; Count of characters read/written
IB.FLG= 4 ; Flag byte
IB.XXX= 5 ; Filler
IB.SIZ= 6 ; Max size
IB.MSZ= 4 ; Minimum size
.ENDM ; End of IOSBDF macro definition
.SBTTL Macro definitions -- PJMP
;++
; This macro is used similarly to the PJRST opdef that is used in MACRO-10/20.
; That is to jump to a routine that will RTS PC back to a higher level.
;--
.MACRO PJMP ADDR
JMP ADDR
.ENDM
.SBTTL Bliss interface definition macro -- BLSRTN
; The following macros are used to generate the proper entry for
;a routine which is to be callable from BLISS, and to generate the
;proper call to a BLISS routine.
;
; Usage:
; BLSRTN Routine.name,Registers,<Argument.names>,<Temp.names>
;
; Where:
; Routine.name is the name of the routine to be defined.
; Register is the number of the highest register to save (2-5)
; Argument.names is the list of the names to be defined for the arguments
; These are in the same order as supplied in the BLISS call.
; Temp.names is a list of names to be defined as stack locals
;
.MACRO BLSRTN RTNNAM,REG,ARGS,TEMPS,?LBL
RTNNAM:: ;; Define the routine entry point
.IF NB <REG>
..REG=REG ;; If have a register to save, remember it
.IFF ;; Else
..REG=0 ;; Don't save anything
.ENDC ;; .IF NB <REG>
.IF GE ..REG-2
JSR R1,$SAVE'REG ;; Save needed registers
..AOFS= 2+2+<2*REG> ;; Define offset to last argument
;; 2 for SAVEn return,
;; 2 for our return address
;; Plus 2 for each register saved
.IFF ;; if not saving registers
..AOFS= 2 ;; Just have our return address
.ENDC ;; .IF GE REG-2
..TCNT= 0 ;; Assume no temps
.IF NB <TEMPS> ;; Any temps to define?
..TOFS= 2 ;; First temp is +2 (we add a return address)
.IRP TEMP,<TEMPS> ;; Yes, loop for each one
TEMP= ..TOFS ;; Define the offset
..TOFS= ..TOFS+2 ;; One more temp
.ENDR
;; Now generate the code to allocate the space and remove it
.IF EQ ..TOFS-4 ;; Only one temp?
TST -(SP) ;; Yes, just use a test
.IFF
.IF EQ ..TOFS-6 ;; Just two temps?
CMP -(SP),-(SP) ;; Yes, allocate two items
.IFF
ADD #..TOFS-2,SP ;; Otherwise allocate the desired space
.ENDC
.ENDC
JSR PC,LBL ;; Call routine
;; Now generate the code to remove the arguments
.IF EQ ..TOFS-4 ;; Only one temp?
TST (SP)+ ;; Yes, just use a test
.IFF
.IF EQ ..TOFS-6 ;; Just two temps?
CMP (SP)+,(SP)+ ;; Yes, remove two items
.IFF
SUB #..TOFS-2,SP ;; Otherwise remove what we allocated
.ENDC
.ENDC
RTS PC ;; And continue returning
LBL: ;; Define label for where routine really starts
..AOFS= ..AOFS+..TOFS ;; Argument offset is now greater
.ENDC
..ACNT= 0 ;; Assume no arguments
.IF NB <ARGS>
.IRP ARG,<ARGS> ;; Once for each argument
..ACNT=..ACNT+1 ;; Count the arguments
.ENDR ;; .IRP ARGS ARG
.IRP ARG,<ARGS> ;; Once for each arg
..ACNT=..ACNT-1 ;; Decrement counter
ARG=..AOFS+<2*..ACNT> ;; Define offset for argument
.ENDR ;; .IRP ARGS ARG
.ENDC
.ENDM BLSRTN
.SBTTL Bliss interface definition macro -- BLSCAL
;
; Macro to call a BLISS routine.
;
; Usage:
;
; BLSCAL Routine.name,<Arguments>,Flag
;
; Where:
; Routine.name is the name of the routine to call
; Arguments is the list of arguments to pass to the routine
; Where flag is:
; blank to cause stack space for the arguments to be allocated
; before calling and removed afterwords
; + to cause stack space to be allocated (if additional space is
; necessary) but not removed
; - to cause stack space to be allocated if additional space is
; needed, and all argument stack space removed after the
; call.
;
; Flag is typically used for a series of BLSCAL's, so that stack space being
; allocated for arguments does not have to be removed each time.
;
; Example:
; BLSCAL FIRST,<ARG1,ARG2>,+
; BLSCAL SECOND,<ARG1,ARG2,ARG3>,+
; BLSCAL THIRD,<ARG1,ARG2>,+
; BLSCAL LAST,<ARG1,ARG2>,-
;
; BLSCAL keeps a variable which is the current stack offset. It needs it to
; determine if more stack space must be allocated, or how much needs to be
; removed. This variable can also be used by the calling program to correctly
; access its own arguments or stack locals. The variable is called ..STKO
;
.MACRO BLSCAL RTNNAM,ARGS,FLAG
.IIF NDF,..STKO ..STKO=0 ;; Nothing on the stack to start
..ACNT= 0 ;; Assume no arguments
.IRP ARG,<ARGS> ;; First count the arguments
..ACNT=..ACNT+1 ;; Count the argument
.ENDR ;; End of .IRP
;; Now determine how to allocate the stack space and store the arguments
.IF NB <FLAG> ;; If flag is not blank, we can use what we already have on the stack
.IF GE ..STKO-<2*..ACNT> ;; Have enough space for all the arguments?
..STKB= 2*<..ACNT-1> ;; Offset to position on stack for first argument
.IFF ;; If we need more space
..STKB= ..STKO-2 ;; Offset to first argument
.ENDC
.IRP ARG,<ARGS> ;; Repeat for all arguments
.IF LT ..STKB ;; If we have used up all previous space
MOV ARG,-(SP) ;; Just stack the argument
..STKO= ..STKO+2 ;; More info on the stack
.IFF ;; Otherwise
.IF NE ..STKB
MOV ARG,..STKB(SP) ;; Store on previously allocated space
.IFF
MOV ARG,@SP ;; Store last argument
.ENDC
.ENDC ;; End of .IF LE....
..STKB= ..STKB-2 ;; And account for the space
.ENDR ;; End of .IRP ARG,<ARGS>
.IFF ;; If we want to allocate new space always
.IRP ARG,<ARGS> ;; Repeat for all arguments
MOV ARG,-(SP) ;; Stack the argument
.ENDR ;; End of .IRP
.ENDC
JSR PC,RTNNAM ;; Call the routine
.IF IDN <FLAG>,<->
..ACNT=..STKO/2 ;; Yes, get the amount we need to remove
..STKO=0 ;; Nothing on the stack now
.ENDC
.IIF IDN <FLAG>,<+>..ACNT=0 ;; If we should leave things on, remember that
.IF NE ..ACNT ;; Any arguments at all?
.IIF EQ ..ACNT-1,TST (SP)+ ;; Remove argument if only one
.IIF EQ ..ACNT-2,CMP (SP)+,(SP)+ ;; Remove if exactly two args
.IIF GT ..ACNT-2,ADD #<2*..ACNT>,SP ;; Remove if many arguments
.ENDC
.ENDM BLSCAL
.SBTTL Text processing definition macro
;++
; The MSG macro will generate a length symbol for the message and the]
; text associated with the message. It is called with a four character
; name of the text and then will generate M$xxxx for the address of the
; message and xxxx$L for the length in bytes
;
; Usage:
;
; MSG xxxx,<This is the text for the xxxx message>
;
;--
.MACRO MSG NAME,TEXT
M$'NAME:
;; Generate the ASCIZ string
.ASCIZ ^TEXT^
;;[01] Length of the text (without null)
NAME'$L= .-M$'NAME-1
.EVEN
.ENDM
.SBTTL Macro definitions -- TABLE
;++
; This macro is used to build the text tables for KERMNU.
;--
.MACRO TABLE NAME,MCRNAM
.SAVE ;; Save the current program section
.ENABL LSB ;; Start local symbol block
;;
;; First go to the table PSECT
;;
.PSECT $TABL$, RO, D
;;
;; Define the start of the table
;;
T$'NAME:
.MACRO $TAB VALUE,TEXT,?TXTADR,?TXTEND
.WORD VALUE
.ENDM
.MACRO $TABA VALUE,ADDR
.WORD VALUE
.ENDM
MCRNAM ;; Build the table
NAME'$L=.-T$'NAME
;;
;; Now redefine to point to the associated text.
;;
.MACRO $TAB VALUE,TEXT,?TXTADR,?TXTEND
;;
;; First go to the text PSECT
;;
.PSECT $TEXT$, RO, D
;;
;; Expand the text
;;
.EVEN ;; Must be on word boundary
TXTADR: .BYTE TXTEND-.-1
.ASCII ^TEXT^
TXTEND:
;;
;; Now to the table PSECT
;;
.PSECT $TABL$, RO, D
;;
;; Generate the entry
;;
.WORD TXTADR
.ENDM
;;
;; Macro for defining a table of values and addresses
;;
.MACRO $TABA VALUE,ADDR
.WORD ADDR
.ENDM
;;
;; Expand the macro a second time
;;
MCRNAM ;; Expand the macro for a second time
.DSABL LSB ;; End of local symbol block
.RESTORE ;; Restore the program section
.ENDM
.SBTTL BIT. - Define bit mask for a bit number
; This macro is used to define a mask for a given bit number
.MACRO BIT. MASK,BIT
.IF NDF, BIT..
.MACRO BIT.. ARG1,ARG2
ARG1=B'ARG2 ; Define the mask
.ENDM
.ENDC
.IF NDF B0
.MCALL BITS
BITS ; Define the bits
.ENDC
BIT.. MASK,\BIT
.ENDM
.MACRO ND ARG1,ARG2
.IIF NDF ARG1,ARG1=ARG2
.ENDM
;MACRO FOR BUILDING VARIOUS BLOCK STRUCTURES
.MACRO BLOCK TYPE
...OFF=0 ;START WITH ZERO OFFSET
.MACRO ITIS A,B
.LIST
A=B
.NLIST
.ENDM ITIS
.MACRO .X Q,QQ
.IF NB <Q>
ITIS .'TYPE''Q,\...OFF
.ENDC
.IF NB <QQ>
...OFF=...OFF+<2*<QQ>>
.IFF
...OFF=...OFF+2
.ENDC
.ENDM
.MACRO .XX Q,QQ
.IF NB <Q>
ITIS .'TYPE''Q,\...OFF
.ENDC
.IF NB <QQ>
...OFF=...OFF+<QQ>
.IFF
...OFF=...OFF+1
.ENDC
.ENDM
.ENDM BLOCK
; Macro to ensure that values are placed into correct position in
;block
.MACRO SETBLK TYPE
...ORG=. ; Remember origin
.MACRO .X NAME,VALUE
.IFGT ...ORG+.'TYPE''NAME-.
.REPT ...ORG+.'TYPE''NAME-.
.BYTE 0
.ENDR
.ENDC
.IIF NE ...ORG+.'TYPE''NAME-.,.ERROR 0; With val=VALUE
VALUE ; Generate the value
.ENDM .X
.ENDM SETBLK
.END