;;; DSYMS1 -- Definitions and stuff for DSYMS language. ;;; Copyright (c) 1987 Massachusetts Institute of Technology. ;;; ;;; Note that there is absolutely NO WARRANTY on this software. ;;; See the file COPYRIGHT.NOTICE for details and restrictions. ;;; DSYMS format is a limited set of macros used to define symbols, ;;; structures, and tokens in a single file that can be used as source ;;; code for both C compilers (in particular the KCC compiler) and ;;; assemblers (in particular MACRO and MIDAS). This makes it much ;;; easier to keep things consistant when two sides of a message ;;; protocol have to be implemented in different lanugages. ;;; ;;; This version is for DEC's MACRO assembler. It would probably work ;;; with FAIL as well if anybody cares. The command to assemble a ;;; symbol file using DSYMS format would be ;;; ;;; @COMPILE unvfil.MAC + DSYMS1.MAC + foo.D + DSYMS2.MAC ;;; ;;; "unvfil" should be a file with a UNIVERSAL statement in it. There ;;; may be more than one file as "foo.D" (which is why the UNIVERSAL ;;; statement is not handled by DSYMS. Any special .DIRECT statements ;;; or whatever should also be in "unvfil". DSYMS2 flushes some ;;; internal symbols and provides an END statement, so it should be ;;; the last file in the sequence. ; We need structure defining stuff from MACSYM SEARCH MACSYM ; Ignore extraneous tabs and spaces in macro calls .DIRECT .XTABM ;; Worker macros ; Convert C names to SQUOZE ("_" becomes ".") DEFINE $$$CVT(FOO) < XLIST $$$NAM==0 $$$DUN==0 IRPC FOO,< IFIDN < >,,<$$$DUN==1>> IFN <$$$NAM&>,<$$$DUN==1> IFE <$$$DUN>,< IFIDN <_>,<$$$CHR==> IFDIF <_>,<$$$CHR==> $$$NAM==<$$$NAM_6>!<$$$CHR_-36> > IFN <$$$DUN>, > PURGE $$$CHR,$$$DUN LIST > ; Set up an equivalence. Needed because name conversion has to be ; done via a macro call. DEFINE $$$EQV(FOO,BAR) ;; Language elements ; COMMENT is already present in MACRO ; Define a constant. Radix is decimal unless first digit is zero (like C). DEFINE CONST(FOO,BAR) < $$$RX1==5+5 IRPC BAR,,< IFIDN <0>,<$$$RX1==4+4> STOPI >> $$$RX2==10 RADIX $$$RX1 $$$BAR==BAR RADIX $$$RX2 $$$CVT(FOO) $$$EQV(\'$$$NAM,\$$$BAR) PURGE $$$NAM,$$$BAR,$$$RX1,$$$RX2 > ; Begin a structure definition DEFINE BSTRUCT(FOO) < $$$FLD==0 $$$WRD==0 > ; Define a structure bitfield DEFINE DFIELD(FOO,BAR) < $$$CVT(FOO) $$$SIZ==^D $$$POS==$$$FLD+$$$SIZ-1 DEFSTR(\'$$$NAM,\$$$WRD,$$$POS,$$$SIZ) PURGE $$$SIZ,$$$POS,$$$NAM DFILL(BAR) > ; Define a "halfword". This should be at least 16 bits of precision. DEFINE DHALF(FOO) < DFIELD(FOO,18) > ; Fill a bitfield. Filling by zero just aligns to next word boundry, per C. DEFINE DFILL(FOO) < IFE <^D>,< IFN <$$$FLD>,< $$$FLD==0 $$$WRD==$$$WRD+1 > > IFN <^D>,< $$$FLD==$$$FLD+^D IFGE <$$$FLD-44>,< $$$WRD==$$$WRD+1 $$$FLD==$$$FLD-44 > > > ; Define a "word". This is a 32 bit (at least) aligned value. DEFINE DWORD(FOO) < DWORDS(FOO,1) > ; Define an array of "words". DEFINE DWORDS(FOO,BAR) < DFILL(0) $$$CVT(FOO) $$$POS==^D35 $$$SIZ==^D36 DEFSTR(\'$$$NAM,\$$$WRD,$$$POS,$$$SIZ) $$$WRD==$$$WRD+^D PURGE $$$NAM,$$$POS,$$$SIZ > ; End of a structure definition. DEFINE ESTRUCT(FOO,BAR) < IFN <$$$FLD>,< $$$WRD==$$$WRD+1 > $$$CVT(BAR) $$$EQV(\'$$$NAM,$$$WRD) PURGE $$$NAM > ;; Tuple stuff ; Begining of a tuple list DEFINE BTUPLE(FOO) <> ; A tuple entry DEFINE TUPLE(FOO,BAR,BAZ) < $$$CVT(FOO) $$$EQV(\'$$$NAM,<^D>) PURGE $$$NAM > ; A tuple alias DEFINE ATUPLE(FOO,BAR) <> ; End of a tuple list DEFINE ETUPLE <> ;; RDATA stuff ; Begin an RDATA definition DEFINE BRDATA(FOO,BAR) < $$$IDX==0 > ; An RDATA entry DEFINE RDATA(FOO,BAR) < $$$CVT(FOO) $$$EQV(\'$$$NAM,\$$$IDX) $$$IDX==$$$IDX+1 PURGE $$$NAM > ; Alias (to work around 6 char limit screw) to an RDATA entry DEFINE ARDATA(FOO,BAR) < $$$CVT(FOO) $$$NM1==$$$NAM $$$CVT(BAR) $$$NM2==$$$NAM $$$EQV(\'$$$NM2,\'$$$NM1) PURGE $$$NAM,$$$NM1,$$$NM2 > ; End of an RDATA definition DEFINE ERDATA(FOO) < PURGE $$$IDX > ;; End of DSYMS1.MAC.