diff --git a/DistrAction b/DistrAction new file mode 100755 index 00000000..90295286 --- /dev/null +++ b/DistrAction @@ -0,0 +1,3 @@ +p=/proj/em/Work +sh TakeAction 'make distr' $p/distr/Action +sh TakeAction 'make distr' $p/distr/Action1 diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..bf4572b2 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +cmp: # compile everything and compare + (cd etc ; make cmp ) + (cd util ; make cmp ) + (cd lang ; make cmp ) + (cd mach ; make cmp ) + +install: # compile everything to machine code + (cd etc ; make install ) + (cd util ; make install ) + (cd lang/cem ; make install ) + (cd mach ; make install ) + (cd lang/pc ; make install ) + +clean: # remove all non-sources, except boot-files + (cd doc ; make clean ) + (cd man ; make clean ) + (cd h ; make clean ) + (cd etc ; make clean ) + (cd util ; make clean ) + (cd lang ; make clean ) + (cd mach ; make clean ) + +opr: # print all sources + make pr | opr + +pr: # print all sources + @( pr Makefile ; \ + (cd doc ; make pr ) ; \ + (cd man ; make pr ) ; \ + (cd h ; make pr ) ; \ + (cd etc ; make pr ) ; \ + (cd lang ; make pr ) ; \ + (cd util ; make pr ) ; \ + (cd mach ; make pr ) \ + ) diff --git a/bin/em.pascal b/bin/em.pascal new file mode 100755 index 00000000..2e03475b --- /dev/null +++ b/bin/em.pascal @@ -0,0 +1 @@ +exec /usr/em/doc/em/int/em /usr/em/doc/em/int/tables ${1-e.out} core diff --git a/distr/Action b/distr/Action new file mode 100644 index 00000000..1cbc5442 --- /dev/null +++ b/distr/Action @@ -0,0 +1,3 @@ +name "EM tables" +dir etc +end diff --git a/distr/Action1 b/distr/Action1 new file mode 100644 index 00000000..dc1e371f --- /dev/null +++ b/distr/Action1 @@ -0,0 +1,16 @@ +name "m68k2/cg bootstrap files" +dir mach/m68k2/cg +action "make EMHOME=/proj/em/Work distr" +end +name "vax4/cg bootstrap files" +dir mach/vax4/cg +action "make EMHOME=/proj/em/Work distr" +end +name "m68020/ncg bootstrap files" +dir mach/m68020/ncg +action "make EMHOME=/proj/em/Work distr" +end +name "m68k4/cg bootstrap files" +dir mach/m68k4/cg +action "make EMHOME=/proj/em/Work distr" +end diff --git a/distr/f.attf b/distr/f.attf new file mode 100644 index 00000000..a95572a5 --- /dev/null +++ b/distr/f.attf @@ -0,0 +1,26 @@ +-- ./doc/install.pr no RCS file +-- ./h/em_mnem.h no RCS file +-- ./h/em_pseu.h no RCS file +-- ./h/em_spec.h no RCS file +-- ./lang/basic/src/y.tab.c no RCS file +-- ./lang/basic/src/y.tab.h no RCS file +-- ./lang/pc/pem/pem22.m no RCS file +-- ./lang/pc/pem/pem24.m no RCS file +-- ./lang/pc/pem/pem44.m no RCS file +-- ./lib/LLgen/incl no RCS file +-- ./lib/LLgen/rec no RCS file +-- ./mach/m68k2/cg/tables1.c no RCS file +-- ./mach/m68k2/cg/tables1.h no RCS file +-- ./mach/m68020/ncg/tables1.c no RCS file +-- ./mach/m68020/ncg/tables1.h no RCS file +-- ./mach/vax4/cg/tables1.c no RCS file +-- ./mach/vax4/cg/tables1.h no RCS file +-- ./util/LLgen/src/parser no RCS file +-- ./util/LLgen/src/LLgen.c no RCS file +-- ./util/LLgen/src/Lpars.c no RCS file +-- ./util/LLgen/src/Lpars.h no RCS file +-- ./util/LLgen/src/tokens.c no RCS file +-- ./util/data/em_flag.c no RCS file +-- ./util/data/em_mnem.c no RCS file +-- ./util/data/em_pseu.c no RCS file +-- ./util/ego/share/pop_push.h no RCS file diff --git a/distr/mks b/distr/mks new file mode 100755 index 00000000..be169fb6 --- /dev/null +++ b/distr/mks @@ -0,0 +1 @@ +cp .distr $DESTDIR/$1 diff --git a/doc/ceg/Makefile b/doc/ceg/Makefile new file mode 100644 index 00000000..de1e6080 --- /dev/null +++ b/doc/ceg/Makefile @@ -0,0 +1,6 @@ +PIC=pic +TBL=tbl +REFER=refer + +../ceg.doc: ceg.tr ceg.ref + $(PIC) ceg.tr | $(REFER) -e -p ceg.ref | $(TBL) > $@ diff --git a/doc/ceg/proposal.tr b/doc/ceg/proposal.tr new file mode 100644 index 00000000..0063bb62 --- /dev/null +++ b/doc/ceg/proposal.tr @@ -0,0 +1,284 @@ +.TL + +Code Expander +.br +(proposal) + +.SH +Introduction +.LP +The \fBcode expander\fR, \fBce\fR, is a program that translates EM-code to +objectcode. The main goal is to translate very fast. \fBce\fR is an instance +of the EM_CODE(3L)-interface. During execution of \fBce\fR, \fBce\fR will build +in core a machine independent objectfile ( NEW A.OUT(5L)). With \fBcv\fR or +with routines supplied by the user the machine independent objectcode will +be converted to a machine dependent object code. \fBce\fR needs +information about the targetmachine (e.g. the opcode's). We divide the +information into two parts: +.IP +- The description in assembly instructions of EM-code instructions. +.IP +- The description in objectcode of assembly instructions. +.LP +With these two tables we can make a \fBcode expander generator\fR which +generates a \fBce\fR. It is possible to put the information in one table +but that will probably introduce (propable) more bugs in the table. So we +divide and conquer. With this approach it is also possible to generate +assembly code ( rather yhan objectcode), wich is useful for debugging. +There is of course a link between the two tables, the link +consist of a restriction on the assembly format. Every assembly +instruction must have the following format: +.sp + INSTR ::= LABEL : MNEMONIC [ OPERAND ( "," OPERAND)* ] +.sp +.LP +\fBCeg\fR uses the following algorithm: +.IP \0\0a) +The assembly table will be converted to a (C-)routine assemble(). +assemble() gets as argument a string, the assembler instruction, +and can use the MNEMONIC to execute the corresponding action in the +assembly table. +.IP \0\0b) +The routine assemble() can now be used to convert the EM-code table to +a set of C-routines, wich together form an instance of the +EM_CODE(3L). +.SH +The EM-instruction table +.LP +We use the following grammar: +.sp +.TS +center box ; +l. +TABLE ::= (ROW)* +ROW ::= C_instr ( SPECIAL | SIMPLE) +SPECIAL ::= ( CONDITION SIMPLE)+ 'default' SIMPLE +SIMPLE ::= '==>' ACTIONLIST | '::=' ACTIONLIST +ACTIONLIST ::= [ ACTION ( ';' ACTION)* ] '.' +ACTION ::= function-call | assembly-instruction +.TE +.LP +An example for the 8086: +.LP +.DS +C_lxl + $arg1 == 0 ==> "push bp". + $arg1 == 1 ==> "push EM_BSIZE(bp)". + default ==> "mov cx, $arg1"; + "mov si, bp"; + "1: mov si, EM_BSIZE(si); + "loop 1b" + "push si". +.DE +.sp +Some remarks: +.sp +* The C_instr is a function indentifier in the EM_CODE(3L)-interface. +.LP +* CONDITION is a "boolean" C-expression. +.LP +* The arguments of an EM-instruction can be used in CONDITION and in assembly +instructions. They are referred by $arg\fIi\fR. \fBceg\fR modifies the +arguments as follows: +.IP \0\0- +For local variables at positive offsets it increases this offset by EM_BSIZE +.IP \0\0- +It makes names en labels unique. The user must supply the formats (see mach.h). +.LP +* function-call is allowed to implement e.g. push/pop optimization. +For example: +.LP +.DS +C_adi + $arg1 == 2 ==> combine( "pop ax"); + combine( "pop bx"); + "add ax, bx"; + save( "push ax"). + default ==> arg_error( "C_adi", $arg1). +.DE +.LP +* The C-functions called in the EM-instructions table have to use the routine +assemble()/gen?(). "assembler-instr" is in fact assemble( "assembler-instr"). +.LP +* \fBceg\fR takes care not only about the conversions of arguments but also +about +changes between segments. There are situation when one doesn't want +conversion of arguments. This can be done by using ::= in stead of ==>. +This is usefull when two C_instr are equivalent. For example: +.IP +C_slu ::= C_sli( $arg1) +.LP +* There are EM-CODE instructions wich are machine independent (e.g. C_open()). +For these EM_CODE instructions \fBceg\fR will generate \fIdefault\fR- +instructions. There is one exception: in the case of C_pro() the tablewriter +has to supply a function prolog(). +.LP +* Also the EM-pseudoinstructions C_bss_\fIcstp\fR(), C_hol_\fIcstp\fR(), +C_con_\fIcstp\fR() and C_rom_\fIcstp\fR can be translated automaticly. +\fBceg\fR only has to know how to interpretate string-constants: +.DS +\&..icon $arg2 == 1 ==> gen1( (char) atoi( $arg1)) + $arg2 == 2 ==> gen2( atoi( $arg1)) + $arg2 == 4 ==> gen4( atol( $arg1)) +\&..ucon $arg2 == 1 ==> gen1( (char) atoi( $arg1)) + $arg2 == 2 ==> gen2( atoi( $arg1)) + $arg2 == 4 ==> gen4( atol( $arg1)) +\&..fcon ::= not_implemented( "..fcon") +.DE +.LP +* Still, life can be made easier for the tablewriter; For the routines wich +he/she didn't implement \fBceg\fR will generate a default instruction wich +generates an error-message. \fBceg\fR seems to generate : +.IP +C_xxx ::= not_implemented( "C_xxx") +.SH +The assembly table +.LP +How to map assembly on objectcode. +.LP +Each row in the table consists of two fields, one field for the assembly +instruction, the other field for the corresponding objectcode. The tablewriter +can use the following primitives to generate code for the machine +instructions : +.IP "\0\0gen1( b)\0\0:" 17 +generates one byte in de machine independent objectfile. +.IP "\0\0gen2( w)\0\0:" 17 +generates one word ( = two bytes), the table writer can change the byte +order by setting the flag BYTES_REVERSED. +.IP "\0\0gen4( l)\0\0:" 17 +generates two words ( = four bytes), the table writer can change the word +order by setting the flag WORDS_REVERSED. +.IP "\0\0reloc( n, o, r)\0\0:" 17 +generates relocation information for a label ( = name + offset + +relocationtype). +.LP +Besides these primitives the table writer may use his self written +C-functions. This allows the table writer e.g. to write functions to set +bitfields within a byte. +.LP +There are more or less two methods to encode the assembly instructions: +.IP \0\0a) +MNEMONIC and OPERAND('s) are encoded independently of each other. This can be +done when the target machine has an orthogonal instruction set (e.g. pdp-11). +.IP \0\0b) +MNEMONIC and OPERAND('s) together determine the opcode. In this case the +assembler often uses overloading: one MNEMONIC is used for several +different machine-instructions. For example : (8086) +.br + mov ax, bx +.br + mov ax, variable +.br +These instructions have different opcodes. +.LP +As the transformation MNEMONIC-OPCODE is not one to +one the table writer must be allowed to put restrictions on the operands. +This can be done with type declarations. For example: +.LP +.DS + mov dst:REG, src:MEM ==> + gen1( 0x8b); + modRM( op2.reg, op1); +.DE +.DS + mov dst:REG, src:REG ==> + gen1( 0x89); + modRM( op2.reg, op1); +.DE +.LP +modRM() is a function written by the tablewriter and is used to encode +the operands. This frees the table writer of endless typing. +.LP +The table writer has to do the "typechecking" by himself. But typechecking +is almost the same as operand decoding. So it's more efficient to do this +in one function. We now have all the tools to describe the function +assemble(). +.IP +assemble() first calls the function +decode_operand() ( by the table writer written), with two arguments: a +string ( the operand) and a +pointer to a struct. The struct is declared by the table writer and must +consist of at least a field called type. ( the other fields in the struct can +be used to remember information about the decoded operand.) Now assemble() +fires a row wich is selected by mapping the MNEMONIC and the type of the +operands. +.br +In the second field of a row there may be references to other +fields in the struct (e.g. op2.reg in the example above). +.LP +We ignored one problem. It's possible when the operands are encoded, that +not everything is known. For example $arg\fIi\fR arguments in the +EM-instruction table get their value at runtime. This problem is solved by +introducing a function eval(). eval() has a string as argument and returns +an arith. The string consists of constants and/or $arg\fIi\fR's and the value +returned by eval() is the value of the string. To encode the $arg\fIi\fR's +in as few bytes as possible the table writer can use the statements %if, +%else and %endif. They can be used in the same manner as #if, #else and +#endif in C and result in a runtime test. An example : +.LP +.DS + -- Some rows of the assembly table + + mov dst:REG, src:DATA ==> + %if sfit( eval( src), 8) /* does the immediate-data fit in 1 byte? */ + R53( 0x16 , op1.reg); + gen1( eval( src)); + %else + R53( 0x17 , op1.reg); + gen2( eval( src)); + %endif +.LD + + mov dst:REG, src:REG ==> + gen1( 0x8b); + modRM( op1.reg, op2); + +.DE +.DS + -- The corresponding part in the function assemble() : + + case MNEM_mov : + decode_operand( arg1, &op1); + decode_operand( arg2, &op2); + if ( REG( op1.type) && DATA( op2.type)) { + printf( "if ( sfit( %s, 8)) {\\\\n", eval( src)); + R53( 0x16 , op1.reg); + printf( "gen1( %s)\\\\n", eval( arg2)); + printf( "}\\\\nelse {\\\\n"); + R53( 0x17 , op1.reg); + printf( "gen2( %s)\\\\n", eval( arg2)); + printf( "}\\\\n"); + } + else if ( REG( op1.type) && REG( op2.type)) { + gen1( 0x8b); + modRM( op1.reg, op2); + } + + +.DE +.DS + -- Some rows of the right part of the EM-instruction table are translated + -- in the following C-functions. + + "mov ax, $arg1" ==> + if ( sfit( w, 8)) { /* w is the actual argument of C_xxx( w) */ + gen1( 176); /* R53() */ + gen1( w); + } + else { + gen1( 184); + gen2( w); + } +.LD + + "mov ax, bx" ==> + gen1( 138); + gen1( 99); /* modRM() */ +.DE +.SH +Restrictions +.LP +.IP \0\01) +The EM-instructions C_exc() is not implemented. +.IP \0\03) +All messages are ignored. diff --git a/doc/ceg/prototype.tr b/doc/ceg/prototype.tr new file mode 100644 index 00000000..c5c5d91b --- /dev/null +++ b/doc/ceg/prototype.tr @@ -0,0 +1,276 @@ +.TL +A prototype Code expander +.NH +Introduction +.PP +A program to be compiled with ACK is first fed into the preprocessor. +The output of the preprocessor goes into the appropiate front end, +whose job it is to produce EM. The EM code generated is +fed into the peephole optimizer, wich scans it with a window of few +instructions, replacing certain inefficient code sequences by better +ones. Following the peephole optimizer follows a backend wich produces +good assembly code. The assembly code goes into the assembler and the objectcode +then goes into the loader/linker, the final component in the pipeline. +.PP +For various applications this scheme is too slow. For example for testing +programs; In this case the program has to be translated fast and the +runtime of the objectcode may be slower. A solution is to build a code +expander ( \fBce\fR) wich translates EM code to objectcode. Of course this +has to +be done automaticly by a code expander generator, but to get some feeling +for the problem we started out to build prototypes. +We built two types of ce's. One wich tranlated EM to assembly, one +wich translated EM to objectcode. +.NH +EM to assembly +.PP +We made one for the 8086 and one for the vax4. These ce's are instances of the +EM_CODE(3L)-interface and produce for a single EM instruction a set +of assembly instruction wich are semantic equivalent. +We implemented in the 8086-ce push/pop-optimalization. +.NH +EM to objectcode +.PP +Instead of producing assembly code we tried to produce vax4-objectcode. +During execution of ce, ce builds in core a machine independent +objectfile ( NEW A.OUT(5L)) and just before dumping the tables this +objectfile is converted to a Berkly 4.2BSD a.out-file. We build two versions; +One with static memory allocation and one with dynamic memory allocation. +If the first one runs out of memory it will give an error message and stop, +the second one will allocate more memory and proceed with producing +objectcode. +.PP +The C-frontend calls the EM_CODE-interface. So after linking the frontend +and the ce we have a pipeline in a program saving a lot of i/o. +It is interesting to compare this C-compiler ( called fcemcom) with "cc -c". +fcemcom1 (the dynamic variant of fcemcom) is tuned in such a way, that +alloc() won't be called. +.NH 2 +Compile time +.PP +fac.c is a small program that produces n! ( see below). foo.c is small program +that loops a lot. +.TS +center, box, tab(:); +c | c | c | c | c | c +c | c | n | n | n | n. +compiler : program : real : user : sys : object size += +fcemcom : sort.c : 31.0 : 17.5 : 1.8 : 23824 +fcemcom1 : : 59.0 : 21.2 : 3.3 : +cc -c : : 50.0 : 38.0 : 3.5 : 6788 +_ +fcemcom : ed.c : 37.0 : 23.6 : 2.3 : 41744 +fcemcom1 : : 1.16.0 : 28.3 : 4.6 : +cc -c : : 1.19.0 : 54.8 : 4.3 : 11108 +_ +fcemcom : cp.c : 4.0 : 2.4 : 0.8 : 4652 +fcemcom1 : : 9.0 : 3.0 : 1.0 : +cc -c : : 8.0 : 5.2 : 1.6 : 1048 +_ +fcemcom : uniq.c : 5.0 : 2.5 : 0.8 : 5568 +fcemcom1 : : 9.0 : 2.9 : 0.8 : +cc -c : : 13.0 : 5.4 : 2.0 : 3008 +_ +fcemcom : btlgrep.c : 24.0 : 7.2 : 1.4 : 12968 +fcemcom1 : : 23.0 : 8.1 : 1.2 : +cc -c : : 1.20.0 : 15.3 : 3.8 : 2392 +_ +fcemcom : fac.c : 1.0 : 0.1 : 0.5 : 216 +fecmcom1 : : 2.0 : 0.2 : 0.5 : +cc -c : : 3.0 : 0.7 : 1.3 : 92 +_ +fcemcom : foo.c : 4.0 : 0.2 : 0.5 : 272 +fcemcom1 : : 11.0 : 0.3 : 0.5 : +cc -c : : 7.0 : 0.8 : 1.6 : 108 +.TE +.NH 2 +Run time +.LP +Is the runtime very bad? +.TS +tab(:), box, center; +c | c | c | c | c +c | c | n | n | n. +compiler : program : real : user : system += +fcem : sort.c : 22.0 : 17.5 : 1.5 +cc : : 5.0 : 2.4 : 1.1 +_ +fcem : btlgrep.c : 1.58.0 : 27.2 : 4.2 +cc : : 12.0 : 3.6 : 1.1 +_ +fcem : foo.c : 1.0 : 0.7 : 0.1 +cc : : 1.0 : 0.4 : 0.1 +_ +fcem : uniq.c : 2.0 : 0.5 : 0.3 +cc : : 1.0 : 0.1 : 0.2 +.TE +.NH 2 +quality object code +.LP +The runtime is very bad so its interesting to have look at the code which is +produced by fcemcom and by cc -c. I took a program which computes recursively +n!. +.DS +long fac(); + +main() +{ + int n; + + scanf( "%D", &n); + printf( "fac is %D\\\\n", fac( n)); +} + +long fac( n) +int n; +{ + if ( n == 0) + return( 1); + else + return( n * fac( n-1)); +} +.DE +.br +.br +.br +.br +.LP +"cc -c fac.c" produces : +.DS +fac: tstl 4(ap) + bnequ 7f + movl $1, r0 + ret +7f: subl3 $1, 4(ap), r0 + pushl r0 + call $1, fac + movl r0, -4(fp) + mull3 -4(fp), 4(ap), r0 + ret +.DE +.br +.br +.LP +"fcem fac.c fac.o" produces : +.DS +_fac: 0 +42: jmp be +48: pushl 4(ap) +4e: pushl $0 +54: subl2 (sp)+,(sp) +57: tstl (sp)+ +59: bnequ 61 +5b: jmp 67 +61: jmp 79 +67: pushl $1 +6d: jmp ba +73: jmp b9 +79: pushl 4(ap) +7f: pushl $1 +85: subl2 (sp)+,(sp) +88: calls $0,_fac +8f: addl2 $4,sp +96: pushl r0 +98: pushl 4(ap) +9e: pushl $4 +a4: pushl $4 +aa: jsb .cii +b0: mull2 (sp)+,(sp) +b3: jmp ba +b9: ret +ba: movl (sp)+,r0 +bd: ret +be: jmp 48 +.DE +.NH 1 +Conclusions +.PP +comparing "cc -c" with "fcemcom" +.LP +.TS +center, box, tab(:); +c | c s | c | c s +^ | c s | ^ | c s +^ | c | c | ^ | c | c +l | n | n | n | n | n. +program : compile time : object size : runtime +:_::_ +: user : sys :: user : sys += +sort.c : 0.47 : 0.5 : 3.5 : 7.3 : 1.4 +_ +ed.c : 0.46 : 0.5 : 3.8 : : : +_ +cp.c : 0.46 : 0.5 : 4.4 : : : +_ +uniq.c : 0.46 : 0.4 : 1.8 : : : +_ +btlgrep.c : 0.47 : 0.3 : 5.4 : 7.5 : 3.8 +_ +fac.c : 0.14 : 0.4 : 2.3 : 1.8 : 1.0 +_ +foo.c : 0.25 : 0.3 : 2.5 : 5.0 : 1.5 +.TE +.PP +The results for fcemcom1 are almost identical; The only thing that changes +is that fcemcom1 is 1.2 slower than fcemcom. ( compile time) This is due to +to an another datastructure . In the static version we use huge array's for +the text- and +data-segment, the relocation information, the symboltable and stringarea. +In the dynamic version we use linked lists, wich makes it expensive to get +and to put a byte on a abritrary memory location. So it is probably better +to use realloc(), because in the most cases there will be enough memory. +.PP +The quality of the objectcode is very bad. The reason is that the frontend +generates bad code and expects the peephole-optimizer to improve the code. +This is also one of the main reasons that the runtime is very bad. +(e.g. the expensive "cii" with arguments 4 and 4 could be deleted.) +So its seems a good +idea to put a new peephole-optimizer between the frontend and the ce. +.PP +Using the peephole optimizer the ce would produce : +.DS +_fac: 0 + pushl 4(ap) + tstl (sp)+ + beqlu 1f + jmp 3f + 1 : pushl $1 + jmp 2f + 3 : pushl 4(ap) + decl (sp) + calls $0,_fac + addl2 $4,sp + pushl r0 + pushl 4(ap) + mull2 (sp)+,(sp) + movl (sp)+,r0 + 2 : ret +.DE +.PP +Bruce McKenzy already implemented it and made some improvements in the +source code of the ce. The compile-time is two to two and a half times better +and the +size of the objectcode is two to three times bigger.(comparing with "cc -c") +Still we could do better. +.PP +Using peephole- and push/pop-optimization ce could produce : +.DS +_fac: 0 + tstl 4(ap) + beqlu 1f + jmp 2f + 1 : pushl $1 + jmp 3f + 2 : decl 4(ap) + calls $0,_fac + addl2 $4,sp + mull3 4(ap), r0, -(sp) + movl (sp)+, r0 + 3 : ret +.DE +.PP +prof doesn't cooperate, so no profile information. +.PP diff --git a/doc/cref.doc b/doc/cref.doc new file mode 100644 index 00000000..76c4f84d --- /dev/null +++ b/doc/cref.doc @@ -0,0 +1,323 @@ +.\" $Header$ +.nr ID 4 +.de hd +'sp 2 +'tl ''-%-'' +'sp 3 +.. +.de fo +'bp +.. +.tr ~ +. TITLE +.de TL +.sp 15 +.ce +\\fB\\$1\\fR +.. +. AUTHOR +.de AU +.sp 15 +.ce +by +.sp 2 +.ce +\\$1 +.. +. DATE +.de DA +.sp 3 +.ce +( Dated \\$1 ) +.. +. INSTITUTE +.de VU +.sp 3 +.ce 4 +Wiskundig Seminarium +Vrije Universteit +De Boelelaan 1081 +Amsterdam +.. +. PARAGRAPH +.de PP +.sp +.ti +\n(ID +.. +.nr CH 0 1 +. CHAPTER +.de CH +.nr SH 0 1 +.bp +.in 0 +\\fB\\n+(CH.~\\$1\\fR +.PP +.. +. SUBCHAPTER +.de SH +.sp 3 +.in 0 +\\fB\\n(CH.\\n+(SH.~\\$1\\fR +.PP +.. +. INDENT START +.de IS +.sp +.in +\n(ID +.. +. INDENT END +.de IE +.in -\n(ID +.sp +.. +.de PT +.ti -\n(ID +.ta \n(ID +.fc " @ +"\\$1@"\c +.fc +.. +. DOUBLE INDENT START +.de DS +.sp +.in +\n(ID +.ll -\n(ID +.. +. DOUBLE INDENT END +.de DE +.ll +\n(ID +.in -\n(ID +.sp +.. +. EQUATION START +.de EQ +.sp +.nf +.. +. EQUATION END +.de EN +.fi +.sp +.. +. ITEM +.de IT +.sp +.in 0 +\\fB~\\$1\\fR +.ti +5 +.. +.de CS +.br +~-~\\ +.. +.br +.fi +.TL "Ack-C reference manual" +.AU "Ed Keizer" +.DA "September 12, 1983" +.VU +.wh 0 hd +.wh 60 fo +.CH "Introduction" +The C frontend included in the Amsterdam Compiler Kit +translates UNIX-V7 C into compact EM code [1]. +The language accepted is described in [2] and [3]. +This document describes which implementation dependent choices were +made in the Ack-C frontend and +some restrictions and additions. +.CH "The language" +.PP +Under the same heading as used in [2] we describe the +properties of the Ack-C frontend. +.IT "2.2 Identifiers" +External identifiers are unique up to 7 characters and allow +both upper and lower case. +.IT "2.3 Keywords" +The word \fBvoid\fP is also reserved as a keyword. +.IT "2.4.3 Character constants" +The ASCII-mapping is used when a character is converted to an +integer. +.IT "2.4.4 Floating constants" +To prevent loss of precision the compiler does not perform +floating point constant folding. +.IT "2.6 Hardware characteristics" +The size of objects of the several arithmetic types and +pointers depend on the EM-implementation used. +The ranges of the arithmetic types depend on the size used, +the C-frontend assumes two's complement representation for the +integral types. +All sizes are multiples of bytes. +The calling program \fIack\fP[4] passes information about the +size of the types to the compiler proper. +.br +However, a few general remarks must be made: +.sp 1 +.IS +.PT (a) +The size of pointers is a multiple of +(or equal to) the size of an \fIint\fP. +.PT (b) +The following relations exist for the sizes of the types +mentioned: +.br +.ti +5 +\fIchar<=short<=int<=long\fP +.PT (c) +Objects of type \fIchar\fP use one 8-bit byte of storage, +although several bytes are allocated sometimes. +.PT (d) +All sizes are in multiples of bytes. +.PT (e) +Most EM implementations use 4 bytes for floats and 8 bytes +for doubles, but exceptions to this rule occur. +.IE +.IT "4 What's in a name" +The type \fIvoid\fP is added. +Objects of type void do not exist. +Functions declared as returning void, do not return a value at all. +.IT "6.1 Characters and integers" +Objects of type \fIchar\fP are unsigned and do not cause +sign-extension when converted to \fIint\fP. +The range of characters values is from 0 to 255. +.IT "6.3 Floating and integral" +Floating point numbers are truncated towards zero when +converted to the integral types. +.IT "6.4 Pointers and integers" +When a \fIlong\fP is added to or subtracted from a pointer and +longs are larger then pointers the \fIlong\fP is converted to an +\fIint\fP before the operation is performed. +.IT "7.2 Unary operators" +It is allowed to cast any expression to the type \fIvoid\fP. +.IT "8.2 Type specifiers" +One type is added to the type-specifiers: +.br +.IS +void +.IE +.IT "8.5 Structure and union declarations" +The only type allowed for fields is \fIint\fP. +Fields with exactly the size of \fIint\fP are signed, +all other fields are unsigned. +.br +The size of any single structure must be less then 4096 bytes. +.IT "8.6 Initialization" +Initialization of structures containing bit fields is not +allowed. +There is one restriction when using an 'address expression' to initialize +an integral variable. +The integral variable must have the same size as a pointer. +Conversions altering the size of the address expression are not allowed. +.IT "9.10 Return statement" +Return statements of the form: +.IS + return ; +.IE +are the only form of return statement allowed in a function of type +function returning void. +.IT "10.1 External function definitions" +The total amount for storage used for parameters +in any function must be less then 4096 bytes. +The same holds for the total amount of storage occupied by the +automatic variables declared inside any function. +.sp +Using formal parameters whose size is smaller the the size of an int +is less efficient on several machines. +At procedure entry these parameters are converted from integer to the +declared type, because the compiler doesn't know where the least +significant bytes are stored in the int. +.IT "11.2 Scope of externals" +Most C compilers are rather lax in enforcing the restriction +that only one external definition without the keyword +\fIextern\fP is allowed in a program. +The Ack-C frontend is very strict in this. +The only exception is that declarations of arrays with a +missing first array bounds expression are regarded to have an +explicit keyword \fIextern\fP. +.IT "14.4 Explicit pointer conversions" +Pointers may be larger the ints, thus assigning a pointer to an +int and back will not always result in the same pointer. +The process mentioned above works with integrals +of the same size or larger as pointers in all EM implementations +having such integrals. +When converting pointers to an integral type or vice-versa, +the pointers is seen as an unsigned int. +.br +EM guarantees that any object can be placed at a word boundary, +this allows the C-programs to use \fIint\fP pointers +as pointers to objects of any type not smaller than an \fIint\fP. +.CH "Frontend options" +The C-frontend has a few options, these are controlled +by flags: +.IS +.PT -V +This flag is followed by a sequence of letters each followed by +positive integers. Each letter indicates a +certain type, the integer following it specifies the size of +objects of that type. One letter indicates the wordsize used. +.IS +.sp 1 +.TS +center tab(:); +l l16 l l. +letter:type:letter:type + +w:wordsize:i:int +s:short:l:long +f:float:d:double +p:pointer:: +.TE +.sp 1 +All existing implementations use an integer size equal to the +wordsize. +.IE +The calling program \fIack\fP[4] provides the frontend with +this flag, with values depending on the machine used. +.sp 1 +.PT -l +The frontend normally generates code to keep track of the line +number and source file name at runtime for debugging purposes. +Currently a pointer to a +string containing the filename is stored at a fixed place in +memory at each function +entry and the line number at the start of every expression. +At the return from a function these memory locations are not reset to +the values they had before the call. +Most library routines do not use this feature and thus do not +ruin the current line number and filename when called. +However, you are really unlucky when your program crashes due +to a bug in such a library function, because the line number +and filename do not indicate that something went wrong inside +the library function. +.br +Providing the flag -l to the frontend tells it not to generate +the code updating line number and file name. +This is, for example, used when translating the stdio library. +.br +When the \fIack\fP[4] is called with the -L flag it provides +the frontend with this flag. +.sp 1 +.PT -Xp +When this flag is present the frontend generates a call to +the function \fBprocentry\fP at each function entry and a +call to \fBprocexit\fP at each function exit. +Both functions are provided with one parameter, +a pointer to a string containing the function name. +.br +When \fIack\fP is called with the -p flag it provides the +frontend with this flag. +.IE +.CH References +.IS +.PT [1] +A.S. Tanenbaum, Hans van Staveren, Ed Keizer and Johan +Stevenson \fIDescription of a machine architecture for use with +block structured languages\fP Informatica report IR-81. +.sp 1 +.PT [2] +B.W. Kernighan and D.M. Ritchie, \fIThe C Programming +language\fP, Prentice-Hall, 1978 +.PT [3] +D.M. Ritchie, \fIC Reference Manual\fP +.sp +.PT [4] +UNIX manual ack(I). diff --git a/doc/ego/Makefile b/doc/ego/Makefile new file mode 100644 index 00000000..f6aefa1c --- /dev/null +++ b/doc/ego/Makefile @@ -0,0 +1,55 @@ +REFS=-p refs.opt -p refs.stat -p refs.gen +INTRO=intro/intro? +OV=ov/ov? +IC=ic/ic? +CF=cf/cf? +IL=il/il? +SR=sr/sr? +CS=cs/cs? +SP=sp/sp? +UD=ud/ud? +LV=lv/lv? +CJ=cj/cj? +BO=bo/bo? +RA=ra/ra? +CA=ca/ca? +EGO=$(INTRO) $(OV) $(IC) $(CF) $(IL) $(SR) $(CS) $(SP) $(CJ) $(BO) \ + $(UD) $(LV) $(RA) $(CA) +REFER=refer +TROFF=troff +TBL=tbl +TARGET=-Tlp + +../ego.doc: refs.opt refs.stat refs.gen intro/head intro/tail $(EGO) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(EGO) intro/tail | $(TBL) > ../ego.doc + +ego.f: refs.opt refs.stat refs.gen intro/head intro/tail $(EGO) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(EGO) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > ego.f +intro.f: refs.opt refs.stat refs.gen intro/head intro/tail $(INTRO) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(INTRO) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > intro.f +ov.f: refs.opt refs.stat refs.gen intro/head intro/tail $(OV) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(OV) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > ov.f +ic.f: refs.opt refs.stat refs.gen intro/head intro/tail $(IC) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(IC) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > ic.f +cf.f: refs.opt refs.stat refs.gen intro/head intro/tail $(CF) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(CF) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > cf.f +il.f: refs.opt refs.stat refs.gen intro/head intro/tail $(IL) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(IL) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > il.f +sr.f: refs.opt refs.stat refs.gen intro/head intro/tail $(SR) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(SR) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > sr.f +cs.f: refs.opt refs.stat refs.gen intro/head intro/tail $(CS) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(CS) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > cs.f +sp.f: refs.opt refs.stat refs.gen intro/head intro/tail $(SP) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(SP) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > sp.f +cj.f: refs.opt refs.stat refs.gen intro/head intro/tail $(CJ) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(CJ) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > cj.f +bo.f: refs.opt refs.stat refs.gen intro/head intro/tail $(BO) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(BO) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > bo.f +ud.f: refs.opt refs.stat refs.gen intro/head intro/tail $(UD) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(UD) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > ud.f +lv.f: refs.opt refs.stat refs.gen intro/head intro/tail $(LV) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(LV) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > lv.f +ra.f: refs.opt refs.stat refs.gen intro/head intro/tail $(RA) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(RA) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > ra.f +ca.f: refs.opt refs.stat refs.gen intro/head intro/tail $(CA) + $(REFER) -sA+T -l4,2 $(REFS) intro/head $(CA) intro/tail | $(TBL) | $(TROFF) $(TARGET) -ms > ca.f diff --git a/doc/em/Makefile b/doc/em/Makefile new file mode 100644 index 00000000..e8bc072d --- /dev/null +++ b/doc/em/Makefile @@ -0,0 +1,37 @@ +HOME=../.. + +TBL=tbl +NROFF=nroff +SUF=pr +TARGET=-Tlp + +head: ../em.$(SUF) + +FILES = macr.nr title.nr intro.nr mem.nr ispace.nr dspace.nr mapping.nr \ + types.nr descr.nr env.nr traps.nr mach.nr assem.nr \ + app.int.nr app.codes.nr app.exam.nr cont.nr + +IOP=$(HOME)/etc/ip_spec.t# # to construct itables from + +../em.$(SUF): $(FILES) itables dispatdummy em.i Makefile + $(TBL) $(FILES) | $(NROFF) -mkun $(TARGET) > ../em.$(SUF) + +app.codes.pr: app.codes.nr itables dispatdummy + +itables: $(IOP) ip.awk + awk -f ip.awk $(IOP) | sed 's/-/\\-/g' | $(TBL) >itables + +dispatdummy: $(IOP) mkdispatch + mkdispatch < $(IOP) > dispatdummy + sed -f dispat1.sed < dispatdummy | $(TBL) > dispat1 + sed -f dispat2.sed < dispatdummy | $(TBL) > dispat2 + sed -f dispat3.sed < dispatdummy | $(TBL) > dispat3 + +mkdispatch: mkdispatch.c + $(CC) -I$(HOME)/h -o mkdispatch mkdispatch.c $(HOME)/lib.bin/em_data.a + +.SUFFIXES : .pr .nr +.nr.pr: ; $(TBL) macr.nr $*.nr | $(NROFF) -mkun >$@ + +clean: + rm -f *.pr itables *.out dispatdummy dispat? *.o mkdispatch diff --git a/doc/em/addend.n b/doc/em/addend.n new file mode 100644 index 00000000..368ca2d1 --- /dev/null +++ b/doc/em/addend.n @@ -0,0 +1,1122 @@ +.lg 0 +.ta 8 16 24 32 40 48 56 64 72 80 +.hw iden-ti-fi-er +.nr a 0 1 +.nr f 1 1 +.de x1 +'sp 2 +'tl '''%' +'sp 2 +.ns +.. +.wh 0 x1 +.de fo +'bp +.. +.wh 60 fo +.ll 79 +.lt 79 +.de HT +.ti -4 +.. +.de PP +.sp +.ne 2 +.ti +5 +.. +.de SE +.bp +\fB\\n+a. \\$1\fR +.nr b 0 1 +.. +.de SB +.br +.ne 10 +.sp 5 +\fB\\na.\\n+b. \\$1\fR +.. +.de DC +.ti -14 +DECISION~\\$1: +.. +.de IN +.in +6 +.. +.de OU +.in -6 +.. +.tr ~ +.sp 5 +.rs +.sp 10 +.ce 3 +Changes in EM-1 + +Addendum to Informatica Rapport IR-54 +.sp 5 +.PP +This document describes a revision of EM-1. +A list of differences is presented roughly in the order IR-54 +describes the original architecture. +A complete list of EM-1 pseudo's and instructions is also included. +.SE Introduction +.PP +EM is a family of intermediate languages, resembling assembly +language for a stack machine. +EM defines the layout of data memory and a partitioning +of instruction memory. +EM has can do operations on five basic types: +pointers, signed integers, unsigned integers, floating point numbers +and sets of bits. +The size of pointers is fixed in each member, +in contrast to the sizes of the other types. +Each member has one more fixed size: the word size. +This is the mimimum size of any object on the stack. +The sizes of all objects on the stack are assumed to +multiples of the word size. +We assume that pointer and word-sizes are both powers of two. +.PP +It is possible to load objects smaller then the word size from memory. +These objects are converted to objects of the word size by +clearing the most significant bytes. +(A separate conversion instruction can do sign extension). +While storing objects smaller then the word size are stored in memory, +the most significant bytes are ignored. +The size of such objects has to be a divisor of the word size. +.PP +Put in other terms, instructions such as LOC, LOL, LOE, STF, etc. +manipulate WORDS. Up until now, a word was defined as 16 bits. +It is now possible to define a word size other than 16 bits. For +example, MES 2,1,2 defines a word to be 8 bits and a pointer to be +16 bits. As another example, MES 2,4,4 defines a word to be 32 bits +and a pointer to be 32 bits. +.PP +If a compiler receives flags telling it to use 32 bit integers, it now +has a choice of setting the word length to 16 bits and using LDL etc +for dealing with integers, or setting the word length to 32 bits and using +LOL etc for integers. +For example, x:=a+b for 32-bit integers would become: + + MES 2,2,4 MES 2,4,4 + LDL a LOL a + LDL b LOL b + ADI 4 ADI 4 + SDL x STL x + +In many cases, the target machine code that is finally produced from either +of the above sequences will not show any traces of the stack machine, however +for some instructions actual pushes and pops at run time will be necessary. +Choosing a wider EM word will usually produce fewer stack operations than +a narrower word, but it eliminates the possibility of doing arithmetic on +quantities smaller than a word. If, for example, a compiler chooses a 32-bit +EM word, it will be difficult to add two 16 bit integers with ADI, since +the argument must be multiple of the word size. +(The operation can be done by converting the operands to 32 bits using CII, +adding the 32-bit numbers, and reconverting the result.) +On the other hand, choosing a 16-bit EM word makes it possible to do both +16-bit adds (ADI 2) and 32-bit adds (ADI 4), +but the price paid is that 32-bit operations will be viewed as double +precision, and may be slightly less efficient on target machines with a +32-bit word, i.e. the EM to target translator may not take full advantage +of the 32 bit facilities. +.PP +Note that since LOC pushes a WORD on the stack, the argument of LOC +must fit ina word. LOC 256 on an EM machine with a 1-byte word length +is not allowed. LDC 256 is allowed, however. +.PP +A general rule of thumb is that the compiler should choose an EM word +length equal to the width of a single precision integer. +Obviously, compilers should be well parameterized to allow the integer +size(s) and word size(s) to be changed by just changing a few constants. +.PP +The size of a instruction space pointer in is the same +as the size of a data space pointer. +.PP +EM assumes two's complement arithmetic on signed integers, +but does not define an ordering of the bytes in a integer. +The lowest numbered byte of a two-byte object can contain +either the most or the least significant part. +.SE Memory +.PP +EM has two separate addressing spaces, instruction and data. +The sizes of these spaces are not specified. +The layout of instruction space in not defined. +Any interpreter or translator may assume a layout fitting his/her needs. +The layout of data memory is specified by EM. +EM data memory consists of a sequence of 8-bit bytes each separately +addressable. +Certain alignment restrictions exist for object consisting of multiple bytes. +Objects smaller then the word size can only be addressed +at multiples of the object size. +For example: in a member with a four-byte word size, two-byte integers +can only be accessed from even addresses. +Objects larger then the word size can only be placed at multiples +of the word size. +For example: in a member with a four-byte word size, +eight-byte floating point numbers can be fetched at addresses +0, 4, 8, 12, etc. +.SB "Procedure identifiers" +.PP +Procedure identifiers in EM have the same size +as pointers. +Any implementation of EM is free to use any method of identifying procedures. +Common methods are indices into tables containing further information +and addresses of the first instructions of procedures. +.SB "Heap and Stack in global data" +.PP +The stack grows downward, the heap grows upward. +The stack pointer points to the lowest occupied word on the stack. +The heap pointer marks the first free word in the heap area. +.br +.ne 39 +.sp 1 +.nf + 65534 -> |-------------------------------| + |///////////////////////////////| + |//// unimplemented memory /////| + |///////////////////////////////| + SB -> |-------------------------------| + | | + | stack and local area | <- LB + | | + | | + |-------------------------------| <- SP + |///////////////////////////////| + |// implementation dependent //| + |///////////////////////////////| + |-------------------------------| <- HP + | | + | heap area | + | | + | | + |-------------------------------| + | | + | global area | + | | + EB -> |-------------------------------| + | | + | | + | program text | <- PC + | | + | | + PB -> |-------------------------------| + |///////////////////////////////| + |////////// undefined //////////| + |///////////////////////////////| + 0 -> |-------------------------------| + + Fig. \nf. Example of memory layout showing typical register + positions during execution of an EM program. +.fi +.SB "Data addresses as arguments" +.PP +Anywhere previous versions of the EM assembly language +allowed identifiers of objects in +data space, +it is also possible to use 'identifier+constant' or 'identifier-constant'. +For example, both "CON LABEL+4" and "LAE SAVED+3" are allowed. +More complicated expressions are illegal. +.SB "Local data area" +.PP +The mark block has been banished. +When calling a procedure, +the calling routine first has to push the actual parameters. +All language implementations currently push their arguments +in reverse order, to be compatible with C. +Then the procedure is called using a CAL or CAI instruction. +Either the call or the procedure prolog somehow has to save +the return address and dynamic link. +The prolog allocates the space needed for locals and is free to +surround this space with saved registers and other information it +deems necessary. +.PP +The locals are now accessed using negative offsets in LOL, LDL, SDL, LAL, +LIL, SIL and STL instructions. +The parameters are accessed using positive offsets in LOL, LDL, SDL, LAL, +LIL, STL and +STL instructions. +The prolog might have stored information in the area between parameters and +locals. +As a consequence there are two bases, AB(virtual) and LB. +AB stands for Argument Base and LB stands for Local Base. +Positive arguments to LOL etc ... are interpreted as offsets from AB, +negative arguments as offsets from LB. +.PP +The BEG instruction is not needed to allocate the locals because +storage for locals is set aside in the prolog. +The instruction still exists under the name ASP (Adjust Stack Pointer). +.PP +Procedures return using the RET instruction. +The RET pops the function result from the stack and +brings the stack pointer and other relevant registers to the state +they had just before the procedure was called. +The RET instruction expects that - aside from possible function results - +the stack pointer has the value it had after execution of the prolog. +RET finally returns control to the calling routine. +The actual parameters have to be removed from the stack by the calling routine, +and not by the called procedure. +.sp 1 +.ne 38 +.nf + + + + |===============================| + | actual argument n | + |-------------------------------| + | . | + | . | + | . | + |-------------------------------| + | actual argument 1 | ( <- AB ) + |===============================| + |///////////////////////////////| + |// implementation dependent //| + |///////////////////////////////| <- LB + |===============================| + | | + | local variables | + | | + |-------------------------------| + | | + | compiler temporaries | + | | + |===============================| + |///////////////////////////////| + |// implementation dependent //| + |///////////////////////////////| + |===============================| + | | + | dynamic local generators | + | | + |===============================| + | operand | + |-------------------------------| + | operand | <- SP + |===============================| + + A sample procedure frame. + +.fi +.sp 1 +This scheme allows procedures to be called with a variable number +of parameters. +The parameters have to be pushed in reverse order, +because the called procedure has to be able to locate the first one. +.PP +.PP +Since the mark block has disappeared, a new mechanism for static +links had to be created. +All compilers use the convention that EM procedures needing +a static link will find a link in their zero'th parameter, +i.e. the last one pushed on the stack. +This parameter should be invisible to users of the compiler. +The link needs to be in a fixed place because the lexical instructions +have to locate it. +The LEX instruction is replaced by two instructions: LXL and LXA. +\&"LXL~n" finds the LB of a procedure n static levels removed. +\&"LXA~n" finds the (virtual) AB. +The value used for static link is LB. +.PP +When a procedure needing a static link is called, first the actual +parameters are pushed, then the static link is pushed using LXL +and finally the procedure is called with a CAL with the procedure's +name as argument. +.br +.ne 40 +.nf + + + + |===============================| + | actual argument n | + |-------------------------------| + | . | + | . | + | . | + |-------------------------------| + | actual argument 1 | + |-------------------------------| + | static link | ( <- AB ) + |===============================| + |///////////////////////////////| + |// implementation dependent //| + |///////////////////////////////| <- LB + |===============================| + | | + | local variables | + | | + |-------------------------------| + | | + | compiler temporaries | + | | + |===============================| + |///////////////////////////////| + |// implementation dependent //| + |///////////////////////////////| + |===============================| + | | + | dynamic local generators | + | | + |===============================| + | operand | + |-------------------------------| + | operand | <- SP + |===============================| + + A procedure frame with static link. + +.fi +.sp 1 +.sp 1 +.PP +Pascal and other languages have to use procedure +instance identifiers containing +the procedure identifier +'ul +and +the static link the procedure has to be called with. +A static link having a value of zero signals +that the called procedure does not need a static link. +C uses the same convention for pointers to C-routines. +In pointers to C-routines the static link is set to zero. +.PP +Note: The distance from LB to AB must be known for each procedure, otherwise +LXA can not be implemented. +Most implementations will have a fixed size area between +the parameter and local storage. +The zone between the compiler temporaries and the dynamic +local generators can be used +to save a variable number of registers. +.PP +.ne 11 +Prolog examples: +.sp 2 +.nf + + proc1 proc2 + + mov lb,-(sp) mov lb,-(sp) + mov sp,lb mov sp,lb + sub $loc_size,sp sub $loc_size,sp + mov r2,-(sp) ; save r2 mov r2,-(sp) + mov r4,-(sp) ; save r4 + +.fi +.SB "Return values" +.PP +The return value popped by RET is stored in an unnamed 'function return area'. +This area can be different for different sized objects returned, +e.g. one register for two byte objects, +two registers for four byte objects, +memory for larger objects. +The area is available for 'READ-ONCE' access using the LFR instruction. +The result of a LFR is only defined if the sizes used to store and +fetch are identical. +The only instructions guaranteed not to destroy the contents of +any 'function return area' are ASP and BRA. +Thus parameters can be popped before fetching the function result. +The maximum size of all function return areas is +implementation dependant, +but allows procedure instance identifiers and all +implemented objects of type integer, unsigned, float +and pointer to be returned. + +.SE "EM Assembly Language" +.nr b 0 1 +.SB "Object types and instructions" +.PP +EM knows five basic object types: +pointers, +signed integers, +unsigned integers, +floating point numbers and +sets of bits. +Operations on objects of the last four types do not assume +a specific size. +Pointers (including procedure identifiers) have a fixed size in each +implementation. +Instructions acting on one or more objects of the last four types need +explicit size information. +This information can be given either as the argument of the +instruction or on top of the stack. +.sp 1 +For example: +.nf +addition of integers LOL a, LOL b, ADI 2 +subtraction of two floats LDL a, LDL b, SBF 4 +integer to float LOL a, LOC 2, LOC 4, CIF, SDL b +.fi +.sp +Note that conversion instructions always expect size +before and size after conversion on the stack. +.sp +No obligation exists to implement all operations on all possible sizes. +.PP +The EM assembly language +allows constants as instruction arguments up to a size of four bytes. +In all EM's it is possible to initialize any type and size object. +BSS, HOL, CON and ROM allow type and size indication in initializers. +.SB "Conversion instructions" +.PP +The conversion operators can convert from any type and size to any +type and size. +The types are specified by the instruction, +the sizes should be in words on top of the stack. +Normally the sizes are multiples of the word size, +There is one exception: the CII instructions sign-extends if the +size of the source is a divisor of the word size. +.SB "CSA and CSB" +.PP +The tables used by these instructions do not contain the procedure +identifier any more. +See also "Descriptors". +.SB EXG +.PP +The EXG instruction is deleted from the EM instruction set. +If future applications show any need for this instruction, +it will be added again. +.SB "FIL" +.PP +A FIL instruction has been introduced. +When using separate compilation, +the LIN feature of EM was insufficient. +FIL expects as argument an address in global data. +This address is stored in a fixed place in memory, +where it can be used by any implementation for diagnostics etc. +Like LIN, it provides access to the ABS fragment at the start +of external data. +.SB "LAI and SAI" +.PP +LAI and SAI have been dropped, they thwarted register optimization. +.SB LNC +.PP +The LNC instruction is deleted from the instruction set. +LOC -n wil do what it is supposed to. +.SB "Branch instructions" +.PP +The branch instructions are allowed to branch both forward and backward. +Consequently BRF and BRB are deleted and a BRA instruction is added. +BRA branches unconditionally in any direction. +.SB LDC +.PP +Loads a double word constant on the stack. +.SB LEX +.PP +LXA and LXL replace LEX. +.SB LFR +.PP +LFR loads the function result stored by RET. +.SB "LIL and SIL" +.PP +They replace LOP and STP. (Name change only) +.SB "Traps and Interrupts" +.PP +The numbers used for distinguishing the various types +of traps and interrupts have been reassigned. +The new instructions LIM and SIM +allow setting and clearing of bits in a mask. +The bits in the mask control the action taken upon encountering certain +errors at runtime. +A 1 bit causes the corresponding error to be ignored, +a 0 bit causes the run-time system to trap. +.SB LPI +.PP +Loads a procedure identifier on the stack. +LOC cannot be used to do this anymore. +.SB "ZER and ZRF" +.PP +ZER loads S zero bytes on the stack. +ZRF loads a floating point zero of size S. +.SB "Descriptors" +.PP +All instructions using descriptors have the size of the integer used +in the descriptor as argument. +The descriptors are: case descriptors (CSA and CSB), +range check descriptors (RCK) and +array descriptors ( LAR, SAR, AAR). +.SB "Case descriptors" +.PP +The value used in a case descriptor to indicate the absence of a label +is zero instead of -1. +.SE "EM assembly language" +.SB "Instruction arguments" +.PP +The previous EM had different instructions for distinguishing +between operand on the stack and explicit argument in the instruction. +For example, LOI and LOS. +This distinction has been removed. +Several instructions have two possible forms: +with explicit argument and with implicit argument on top of the stack. +The size of the implicit argument is the word size. +The implicit argument is always popped before all other operands. +Appendix 1 shows what is allowed for each instruction. +.SB Notation +.PP +First the notation used for the arguments of +instructions and pseudo instructions. +.in +12 +.ti -11 +~~=~~an integer number in the range -32768..32767 +.ti -11 +~~=~~an offset -2**31..2**31~-~1 +.ti -11 +~~=~~an identifier +.ti -11 +~~=~~ or or + or - +.ti -11 +~~=~~integer constant, +unsigned constant, +floating point constant +.ti -11 +~~=~~string constant (surrounded by double quotes), +.ti -11 +~~=~~instruction label ('*' followed by an integer in the range +0..32767). +.ti -11 +~~=~~procedure number ('$' followed by a procedure name) +.ti -11 +~~=~~, +, + or +. +.ti -11 +<...>*~=~~zero or more of <...> +.ti -11 +<...>+~=~~one or more of <...> +.ti -11 +[...]~~=~~optional ... +.in -12 +.SB Labels +.PP +No label, instruction or data, can have a (pseudo) instruction +on the same line. +.SB Constants +.PP +All constants in EM are interpreted in the decimal base. +.PP +In BSS, HOL, CON and ROM pseudo-instructions +numbers must be followed by I, U or F +indicating Integer, Unsigned or Float. +If no character is present I is assumed. +This character can be followed by an even positive number or a 1. +The number indicates the size in bytes of the object to be initialized, +up to 32766. +Double precision integers can no longer be indicated by a trailing L. +As said before CON and ROM also allow expressions of the form: +\&"LABEL+offset" and "LABEL-offset". +The offset must be an unsigned decimal number. +The 'IUF' indicators cannot be used with the offsets. +.PP +Areas reserved in the global data area by HOL or BSS can be +initialized. +BSS and HOL have a third parameter indicating whether the initialization +is mandatory or optional. +.PP +Since EM needs aligment of objects, this alignment is enforced by the +pseudo instructions. +All objects are aligned on a multiple of their size or the word size +whichever is smaller. +Switching to another type of fragment or placing a label forces word-alignment. +There are three types of fragments in global data space: CON, ROM and BSS-HOL. +.sp +.SB "Pseudo instructions" +.PP +The LET, IMC and FWC pseudo's have disappeared. +The only application of these pseudo's was in postponing the +specification of the size of the local storage to just before +the END of the procedure. +A new mechanism has been introduced to handle this problem. +.ti +5 +The pseudos involved in separate compilation and linking have +been reorganized. +.ti +5 +PRO and END are altered and reflect the new calling sequence. +EOF has disappeared. +.ti +5 +BSS and HOL allow initialization of the requested data areas. +.sp 2 +Four pseudo instructions request global data: +.sp 2 + BSS ,, +.IN +Reserve bytes. + is the value used to initialize the area. + must be a multiple of the size of . + is 0 if the initialization is not strictly necessary, +1 otherwise. +.OU +.sp + HOL ,, +.IN +Idem, but all following absolute global data references will +refer to this block. +Only one HOL is allowed per procedure, +it has to be placed before the first instruction. +.OU +.sp + CON + +.IN +Assemble global data words initialized with the constants. +.OU +.sp + ROM + +.IN +Idem, but the initialized data will never be changed by the program. +.OU +.sp 2 +Two pseudo instructions partition the input into procedures: +.sp 2 + PRO [,] +.IN +Start of procedure. + is the procedure name. + is the number of bytes for locals. +The number of bytes for locals must be specified in the PRO or +END pseudo-instruction. +When specified in both, they must be identical. +.OU +.sp + END [] +.IN +End of Procedure. + is the number of bytes for locals. +The number of bytes for locals must be specified in either the PRO or +END pseudo-instruction or both. +.OU +.PP +Names of data and procedures in a EM module can either be +internal or external. +External names are known outside the module and are used to link +several pieces of a program. +Internal names are not known outside the modules they are used in. +Other modules will not 'see' an internal name. +.ti +5 +In order to reduce the number of passes needed, +it must be known at the first occurrence whether +a name is internal or external. +If the first occurrence of a name is in a definition, +the name is considered to be internal. +If the first occurrence of a name is a reference, +the name is considered to be external. +If the first occurrence is in one of the following pseudo instructions, +the effect of the pseudo has precedence. +.sp 2 + EXA +.IN +External name. + is external to this module. +Note that may be defined in the same module. +.OU +.sp + EXP +.IN +External procedure identifier. +Note that may be defined in the same module. +.OU +.sp + INA +.IN +Internal name. + is internal to this module and must be defined in this module. +.OU +.sp + INP +.IN +Internal procedure. + is internal to this module and must be defined in this module. +.OU +.sp 2 +Two other pseudo instructions provide miscellaneous features: +.sp 2 + EXC , +.IN +Two blocks of instructions preceding this one are +interchanged before being processed. + gives the number of lines of the first block. + gives the number of lines of the second one. +Blank and pure comment lines do not count. +This instruction is obsolete. Its use is strongly discouraged. +.OU +.sp + MES ,* +.IN +A special type of comment. Used by compilers to communicate with the +optimizer, assembler, etc. as follows: +.br + MES 0 - +.IN +An error has occurred, stop further processing. +.OU +.br + MES 1 - +.IN +Suppress optimization +.OU +.br + MES 2,, +.IN +Use word-size and pointer size . +.OU +.br + MES 3,,, - +.IN +Indicates that a local variable is never referenced indirectly. + is offset in bytes from LB if positive +and offset from AB if negative. + gives the size of the variable. + indicates the class of the variable. +.OU +.br + MES 4,, +.IN +Number of source lines in file (for profiler). +.OU +.br + MES 5 - +.IN +Floating point used. +.OU +.br + MES 6,* - +.IN +Comment. Used to provide comments in compact assembly language (see below). +.OU +.sp 1 +Each back end is free to skip irrelevant MES pseudos. +.OU +.SB "The Compact Assembly Language" +.PP +The assembler accepts input in a highly encoded form. This +form is intended to reduce the amount of file transport between the compiler +and assembler, and also reduce the amount of storage required for storing +libraries. +Libraries are stored as archived compact assembly language, not machine language. +.PP +When beginning to read the input, the assembler is in neutral state, and +expects either a label or an instruction (including the pseudoinstructions). +The meaning of the next byte(s) when in neutral state is as follows, where b1, b2 +etc. represent the succeeding bytes. +.sp + 0 Reserved for future use + 1-129 Machine instructions, see Appendix 2, alphabetical list + 130-149 Reserved for future use + 150-161 BSS,CON,END,EXC,EXA,EXP,HOL,INA,INP,MES,PRO,ROM + 162-179 Reserved for future pseudoinstructions + 180-239 Instruction labels 0 - 59 (180 is local label 0 etc.) + 240-244 See the Common Table below + 245-255 Not used + +After a label, the assembler is back in neutral state; it can immediately +accept another label or an instruction in the very next byte. There are +no linefeeds used to separate lines. +.PP +If an opcode expects no arguments, +the assembler is back in neutral state after +reading the one byte containing the instruction number. If it has one or +more arguments (only pseudos have more than 1), the arguments follow directly, +encoded as follows: +.sp + 0-239 Offsets from -120 to 119 +.br + 240-255 See the Common Table below +.sp 2 +If an opcode has one optional argument, +a special byte is used to announce that the argument is not present. +.ce 1 +Common Table for Neutral State and Arguments +.sp +.nf + 240 b1 Instruction label b1 (Not used for branches) + 241 b1 b2 16 bit instruction label (256*b2 + b1) + 242 b1 Global label .0-.255, with b1 being the label + 243 b1 b2 Global label .0-.32767 + with 256*b2+b1 being the label + 244 Global symbol not of the form .nnn +. \" Only the previous can occur in neutral state. + 245 b1 b2 (16 bit constant) 256*b2+b1 + 246 b1 b2 b3 b4 (32 bit constant) (256*(256*(256*b4)+b3)+b2)+b1 + 247 Global label + (possibly negative) constant + 248 Procedure name (not including $) + 249 String used in CON or ROM (no quotes) + 250 Integer constant, size bytes + 251 Unsigned constant, size bytes + 252 Floating constant, size bytes + 255 Delimiter for argument lists or + indicates absence of optional argument + +.fi +.PP +The notation consists first of a length field, and then an +arbitrary string of bytes. +The length is specified by a . +.PP +.ne 8 +The pseudoinstructions fall into several categories, depending on their +arguments: +.sp + Group 1 -- EXC, BSS, HOL have a known number of arguments + Group 2 -- EXA, EXP, INA, INP start with a string + Group 3 -- CON, MES, ROM have a variable number of various things + Group 4 -- END, PRO have a trailing optional argument. + +Groups 1 and 2 +use the encoding described above. +Group 3 also uses the encoding listed above, with a byte after the +last argument to indicate the end of the list. +Group 4 uses +a byte if the trailing argument is not present. + +.ad +.fi +.sp 2 +.ne 12 +.nf +Example ASCII Example compact +(LOC = 66, BRA = 18 here): + + 2 182 + 1 181 + LOC 10 66 130 + LOC -10 66 110 + LOC 300 66 245 44 1 + BRA 19 18 139 + 300 241 44 1 + .3 242 3 + CON 4,9,*2,$foo 151 124 130 240 2 248 3 102 111 111 255 + LOC .35 66 242 35 +.fi +.nr a 0 1 +.SE "ASSEMBLY LANGUAGE INSTRUCTION LIST" +.PP +For each instruction in the list the range of operand values +in the assembly language is given. +All constants, offsets and sizes are in the range -2**31~..~2**31-1. +The column headed \fIassem\fP contains the mnemonics defined +in 4.1. +The following column indicates restrictions in the range of the operand. +Addresses have to obey the restrictions mentioned in chapter 2 - Memory -. +The size parameter of most instructions has to be a multiple +of the word size. +The classes of operands +are indicated by letters: +.ds b \fBb\fP +.ds c \fBc\fP +.ds d \fBd\fP +.ds g \fBg\fP +.ds f \fBf\fP +.ds l \fBl\fP +.ds n \fBn\fP +.ds i \fBi\fP +.ds p \fBp\fP +.ds r \fBr\fP +.ds s \fBs\fP +.ds z \fBz\fP +.ds - \fB-\fP +.nf + + \fIassem\fP constraints rationale + +\&\*c off 1-word constant +\&\*d off 2-word constant +\&\*l off local offset +\&\*g arg >= 0 global offset +\&\*f off fragment offset +\&\*n num >= 0 counter +\&\*s off > 0 object size +\&\*z off >= 0 object size +\&\*i off > 0 object size * +\&\*p pro pro identifier +\&\*b lab >= 0 label number +\&\*r num 0,1,2 register number +\&\*- no operand + +.fi +.PP +The * at the rationale for \*i indicates that the operand +can either be given as argument or on top of the stack. +If the operand has to be fetched from the stack, +it is assumed to be a word-sized unsigned integer. +.PP +Instructions that check for undefined operands and underflow or overflow +are indicated by (*). +.nf + +GROUP 1 - LOAD + + LOC \*c : Load constant (i.e. push one word onto the stack) + LDC \*d : Load double constant ( push two words ) + LOL \*l : Load word at \*l-th local (l<0) or parameter (l>=0) + LOE \*g : Load external word \*g + LIL \*l : Load word pointed to by \*l-th local or parameter + LOF \*f : Load offsetted. (top of stack + \*f yield address) + LAL \*l : Load address of local or parameter + LAE \*g : Load address of external + LXL \*n : Load lexical. (address of LB \*n static levels back) + LXA \*n : Load lexical. (address of AB \*n static levels back) + LOI \*s : Load indirect \*s bytes (address is popped from the stack) + LOS \*i : Load indirect. \*i-byte integer on top of stack gives object size + LDL \*l : Load double local or parameter (two consecutive words are stacked) + LDE \*g : Load double external (two consecutive externals are stacked) + LDF \*f : Load double offsetted (top of stack + \*f yield address) + LPI \*p : Load procedure identifier + +GROUP 2 - STORE + + STL \*l : Store local or parameter + STE \*g : Store external + SIL \*l : Store into word pointed to by \*l-th local or parameter + STF \*f : Store offsetted + STI \*s : Store indirect \*s bytes (pop address, then data) + STS \*i : Store indirect. \*i-byte integer on top of stack gives object size + SDL \*l : Store double local or parameter + SDE \*g : Store double external + SDF \*f : Store double offsetted + +GROUP 3 - INTEGER ARITHMETIC + + ADI \*i : Addition (*) + SBI \*i : Subtraction (*) + MLI \*i : Multiplication (*) + DVI \*i : Division (*) + RMI \*i : Remainder (*) + NGI \*i : Negate (two's complement) (*) + SLI \*i : Shift left (*) + SRI \*i : Shift right (*) + +GROUP 4 - UNSIGNED ARITHMETIC + + ADU \*i : Addition + SBU \*i : Subtraction + MLU \*i : Multiplication + DVU \*i : Division + RMU \*i : Remainder + SLU \*i : Shift left + SRU \*i : Shift right + +GROUP 5 - FLOATING POINT ARITHMETIC (Format not defined) + + ADF \*i : Floating add (*) + SBF \*i : Floating subtract (*) + MLF \*i : Floating multiply (*) + DVF \*i : Floating divide (*) + NGF \*i : Floating negate (*) + FIF \*i : Floating multiply and split integer and fraction part (*) + FEF \*i : Split floating number in exponent and fraction part (*) + +GROUP 6 - POINTER ARITHMETIC + + ADP \*f : Add \*c to pointer on top of stack + ADS \*i : Add \*i-byte value and pointer + SBS \*i : Subtract pointers in same fragment and push diff as size \*i integer + +GROUP 7 - INCREMENT/DECREMENT/ZERO + + INC \*- : Increment top of stack by 1 (*) + INL \*l : Increment local or parameter (*) + INE \*g : Increment external (*) + DEC \*- : Decrement top of stack by 1 (*) + DEL \*l : Decrement local or parameter (*) + DEE \*g : Decrement external (*) + ZRL \*l : Zero local or parameter + ZRE \*g : Zero external + ZRF \*i : Load a floating zero of size \*i + ZER \*i : Load \*i zero bytes + +GROUP 8 - CONVERT ( stack: source, source size, dest. size (top) ) + + CII \*- : Convert integer to integer (*) + CUI \*- : Convert unsigned to integer (*) + CFI \*- : Convert floating to integer (*) + CIF \*- : Convert integer to floating (*) + CUF \*- : Convert unsigned to floating (*) + CFF \*- : Convert floating to floating (*) + CIU \*- : Convert integer to unsigned + CUU \*- : Convert unsigned to unsigned + CFU \*- : Convert floating to unsigned + +GROUP 9 - LOGICAL + + AND \*i : Boolean and on two groups of \*i bytes + IOR \*i : Boolean inclusive or on two groups of \*i bytes + XOR \*i : Boolean exclusive or on two groups of \*i bytes + COM \*i : Complement (one's complement of top \*i bytes) + ROL \*i : Rotate left a group of \*i bytes + ROR \*i : Rotate right a group of \*i bytes + +GROUP 10 - SETS + + INN \*i : Bit test on \*i byte set (bit number on top of stack) + SET \*i : Create singleton \*i byte set with bit n on (n is top of stack) + +GROUP 11 - ARRAY + + LAR \*i : Load array element, descriptor contains integers of size \*i + SAR \*i : Store array element + AAR \*i : Load address of array element + +GROUP 12 - COMPARE + + CMI \*i : Compare \*i byte integers. Push negative, zero, positive for <, = or > + CMF \*i : Compare \*i byte reals + CMU \*i : Compare \*i byte unsigneds + CMS \*i : Compare \*i byte sets. can only be used for equality test. + CMP \*- : Compare pointers + + TLT \*- : True if less, i.e. iff top of stack < 0 + TLE \*- : True if less or equal, i.e. iff top of stack <= 0 + TEQ \*- : True if equal, i.e. iff top of stack = 0 + TNE \*- : True if not equal, i.e. iff top of stack non zero + TGE \*- : True if greater or equal, i.e. iff top of stack >= 0 + TGT \*- : True if greater, i.e. iff top of stack > 0 + +GROUP 13 - BRANCH + + BRA \*b : Branch unconditionally to label \*b + + BLT \*b : Branch less (pop 2 words, branch if top > second) + BLE \*b : Branch less or equal + BEQ \*b : Branch equal + BNE \*b : Branch not equal + BGE \*b : Branch greater or equal + BGT \*b : Branch greater + + ZLT \*b : Branch less than zero (pop 1 word, branch negative) + ZLE \*b : Branch less or equal to zero + ZEQ \*b : Branch equal zero + ZNE \*b : Branch not zero + ZGE \*b : Branch greater or equal zero + ZGT \*b : Branch greater than zero + +GROUP 14 - PROCEDURE CALL + + CAI \*- : Call procedure (procedure instance identifier on stack) + CAL \*p : Call procedure (with name \*p) + LFR \*s : Load function result + RET \*z : Return (function result consists of top \*z bytes) + +GROUP 15 - MISCELLANEOUS + + ASP \*f : Adjust the stack pointer by \*f + ASS \*i : Adjust the stack pointer by \*i-byte integer + BLM \*z : Block move \*z bytes; first pop destination addr, then source addr + BLS \*i : Block move, size is in \*i-byte integer on top of stack + CSA \*i : Case jump; address of jump table at top of stack + CSB \*i : Table lookup jump; address of jump table at top of stack + DUP \*s : Duplicate top \*s bytes + DUS \*i : Duplicate top \*i bytes + FIL \*g : File name (external 4 := \*g) + LIM \*- : Load 16 bit ignore mask + LIN \*n : Line number (external 0 := \*n) + LNI \*- : Line number increment + LOR \*r : Load register (0=LB, 1=SP, 2=HP) + MON \*- : Monitor call + NOP \*- : No operation + RCK \*i : Range check; trap on error + RTT \*- : Return from trap + SIG \*- : Trap errors to proc nr on top of stack (-2 resets default). Static + link of procedure is below procedure number. Old values returned + SIM \*- : Store 16 bit ignore mask + STR \*r : Store register (0=LB, 1=SP, 2=HP) + TRP \*- : Cause trap to occur (Error number on stack) +.fi diff --git a/doc/em/app.int.nr b/doc/em/app.int.nr new file mode 100644 index 00000000..26dd3a7c --- /dev/null +++ b/doc/em/app.int.nr @@ -0,0 +1,11 @@ +.BP +.AP "EM INTERPRETER" +.nf +.ft CW +.lg 0 +.nr x \w' ' +.ta \nxu +\nxu +\nxu +\nxu +\nxu +\nxu +\nxu +\nxu +\nxu +\nxu +.so em.i +.ft P +.lg 1 +.fi diff --git a/doc/em/app.nr b/doc/em/app.nr new file mode 100644 index 00000000..78e082fc --- /dev/null +++ b/doc/em/app.nr @@ -0,0 +1,488 @@ +.BP +.AP "EM INTERPRETER" +.nf +.ta 8 16 24 32 40 48 56 64 72 80 +.so em.i +.fi +.BP +.AP "EM CODE TABLES" +The following table is used by the assembler for EM machine +language. +It specifies the opcodes used for each instruction and +how arguments are mapped to machine language arguments. +The table is presented in three columns, +each line in each column contains three or four fields. +Each line describes a range of interpreter opcodes by +specifying for which instruction the range is used, the type of the +opcodes (mini, shortie, etc..) and range for the instruction +argument. +.A +The first field on each line gives the EM instruction mnemonic, +the second field gives some flags. +If the opcodes are minis or shorties the third field specifies +how many minis/shorties are used. +The last field gives the number of the (first) interpreter +opcode. +.N 1 +Flags : +.IS 3 +.N 1 +Opcode type, only one of the following may be specified. +.PS - 5 " " +.PT - +opcode without argument +.PT m +mini +.PT s +shortie +.PT 2 +opcode with 2-byte signed argument +.PT 4 +opcode with 4-byte signed argument +.PT 8 +opcode with 8-byte signed argument +.PE +Secondary (escaped) opcodes. +.PS - 5 " " +.PT e +The opcode thus marked is in the secondary opcode group instead +of the primary +.PE +restrictions on arguments +.PS - 5 " " +.PT N +Negative arguments only +.PT P +Positive and zero arguments only +.PE +mapping of arguments +.PS - 5 " " +.PT w +argument must be divisible by the wordsize and is divided by the +wordsize before use as opcode argument. +.PT o +argument ( possibly after division ) must be >= 1 and is +decremented before use as opcode argument +.PE +.IE +If the opcode type is 2,4 or 8 the resulting argument is used as +opcode argument (least significant byte first). +.N +If the opcode type is mini, the argument is added +to the first opcode - if in range - . +If the argument is negative, the absolute value minus one is +used in the algorithm above. +.N +For shorties with positive arguments the first opcode is used +for arguments in the range 0..255, the second for the range +256..511, etc.. +For shorties with negative arguments the first opcode is used +for arguments in the range -1..-256, the second for the range +-257..-512, etc.. +The byte following the opcode contains the least significant +byte of the argument. +First some examples of these specifications. +.PS - 5 +.PT "aar mwPo 1 34" +Indicates that opcode 34 is used as a mini for Positive +instruction arguments only. +The w and o indicate division and decrementing of the +instruction argument. +Because the resulting argument must be zero ( only opcode 34 may be used +), this mini can only be used for instruction argument 2. +Conclusion: opcode 34 is for "AAR 2". +.PT "adp sP 1 41" +Opcode 41 is used as shortie for ADP with arguments in the range +0..255. +.PT "bra sN 2 60" +Opcode 60 is used as shortie for BRA with arguments -1..-256, +61 is used for arguments -257..-512. +.PT "zer e- 145" +Escaped opcode 145 is used for ZER. +.PE +The interpreter opcode table: +.N 1 +.IS 3 +.DS B +.so itables +.DE 0 +.IE +.P +The table above results in the following dispatch tables. +Dispatch tables are used by interpreters to jump to the +routines implementing the EM instructions, indexed by the next opcode. +Each line of the dispatch tables gives the routine names +of eight consecutive opcodes, preceded by the first opcode number +on that line. +Routine names consist of an EM mnemonic followed by a suffix. +The suffices show the encoding used for each opcode. +.N +The following suffices exist: +.N 1 +.VS 1 0 +.IS 4 +.PS - 11 +.PT .z +no arguments +.PT .l +16-bit argument +.PT .lw +16-bit argument divided by the wordsize +.PT .p +positive 16-bit argument +.PT .pw +positive 16-bit argument divided by the wordsize +.PT .n +negative 16-bit argument +.PT .nw +negative 16-bit argument divided by the wordsize +.PT .s +shortie with as high order argument byte +.PT .sw +shortie with argument divided by the wordsize +.PT . +mini with as argument +.PT .W +mini with *wordsize as argument +.PE 3 + is a possibly negative integer. +.VS 1 1 +.IE +The dispatch table for the 256 primary opcodes: +.DS B + 0 loc.0 loc.1 loc.2 loc.3 loc.4 loc.5 loc.6 loc.7 + 8 loc.8 loc.9 loc.10 loc.11 loc.12 loc.13 loc.14 loc.15 + 16 loc.16 loc.17 loc.18 loc.19 loc.20 loc.21 loc.22 loc.23 + 24 loc.24 loc.25 loc.26 loc.27 loc.28 loc.29 loc.30 loc.31 + 32 loc.32 loc.33 aar.1W adf.s0 adi.1W adi.2W adp.l adp.1 + 40 adp.2 adp.s0 adp.s-1 ads.1W and.1W asp.1W asp.2W asp.3W + 48 asp.4W asp.5W asp.w0 beq.l beq.s0 bge.s0 bgt.s0 ble.s0 + 56 blm.s0 blt.s0 bne.s0 bra.l bra.s-1 bra.s-2 bra.s0 bra.s1 + 64 cal.1 cal.2 cal.3 cal.4 cal.5 cal.6 cal.7 cal.8 + 72 cal.9 cal.10 cal.11 cal.12 cal.13 cal.14 cal.15 cal.16 + 80 cal.17 cal.18 cal.19 cal.20 cal.21 cal.22 cal.23 cal.24 + 88 cal.25 cal.26 cal.27 cal.28 cal.s0 cff.z cif.z cii.z + 96 cmf.s0 cmi.1W cmi.2W cmp.z cms.s0 csa.1W csb.1W dec.z + 104 dee.w0 del.w-1 dup.1W dvf.s0 dvi.1W fil.l inc.z ine.lw + 112 ine.w0 inl.-1W inl.-2W inl.-3W inl.w-1 inn.s0 ior.1W ior.s0 + 120 lae.l lae.w0 lae.w1 lae.w2 lae.w3 lae.w4 lae.w5 lae.w6 + 128 lal.p lal.n lal.0 lal.-1 lal.w0 lal.w-1 lal.w-2 lar.W + 136 ldc.0 lde.lw lde.w0 ldl.0 ldl.w-1 lfr.1W lfr.2W lfr.s0 + 144 lil.w-1 lil.w0 lil.0 lil.1W lin.l lin.s0 lni.z loc.l + 152 loc.-1 loc.s0 loc.s-1 loe.lw loe.w0 loe.w1 loe.w2 loe.w3 + 160 loe.w4 lof.l lof.1W lof.2W lof.3W lof.4W lof.s0 loi.l + 168 loi.1 loi.1W loi.2W loi.3W loi.4W loi.s0 lol.pw lol.nw + 176 lol.0 lol.1W lol.2W lol.3W lol.-1W lol.-2W lol.-3W lol.-4W + 184 lol.-5W lol.-6W lol.-7W lol.-8W lol.w0 lol.w-1 lxa.1 lxl.1 + 192 lxl.2 mlf.s0 mli.1W mli.2W rck.1W ret.0 ret.1W ret.s0 + 200 rmi.1W sar.1W sbf.s0 sbi.1W sbi.2W sdl.w-1 set.s0 sil.w-1 + 208 sil.w0 sli.1W ste.lw ste.w0 ste.w1 ste.w2 stf.l stf.W + 216 stf.2W stf.s0 sti.1 sti.1W sti.2W sti.3W sti.4W sti.s0 + 224 stl.pw stl.nw stl.0 stl.1W stl.-1W stl.-2W stl.-3W stl.-4W + 232 stl.-5W stl.w-1 teq.z tgt.z tlt.z tne.z zeq.l zeq.s0 + 240 zeq.s1 zer.s0 zge.s0 zgt.s0 zle.s0 zlt.s0 zne.s0 zne.s-1 + 248 zre.lw zre.w0 zrl.-1W zrl.-2W zrl.w-1 zrl.nw escape1 escape2 +.DE 2 +The list of secondary opcodes (escape1): +.N 1 +.DS B + 0 aar.l aar.z adf.l adf.z adi.l adi.z ads.l ads.z + 8 adu.l adu.z and.l and.z asp.lw ass.l ass.z bge.l + 16 bgt.l ble.l blm.l bls.l bls.z blt.l bne.l cai.z + 24 cal.l cfi.z cfu.z ciu.z cmf.l cmf.z cmi.l cmi.z + 32 cms.l cms.z cmu.l cmu.z com.l com.z csa.l csa.z + 40 csb.l csb.z cuf.z cui.z cuu.z dee.lw del.pw del.nw + 48 dup.l dus.l dus.z dvf.l dvf.z dvi.l dvi.z dvu.l + 56 dvu.z fef.l fef.z fif.l fif.z inl.pw inl.nw inn.l + 64 inn.z ior.l ior.z lar.l lar.z ldc.l ldf.l ldl.pw + 72 ldl.nw lfr.l lil.pw lil.nw lim.z los.l los.z lor.s0 + 80 lpi.l lxa.l lxl.l mlf.l mlf.z mli.l mli.z mlu.l + 88 mlu.z mon.z ngf.l ngf.z ngi.l ngi.z nop.z rck.l + 96 rck.z ret.l rmi.l rmi.z rmu.l rmu.z rol.l rol.z + 104 ror.l ror.z rtt.z sar.l sar.z sbf.l sbf.z sbi.l + 112 sbi.z sbs.l sbs.z sbu.l sbu.z sde.l sdf.l sdl.pw + 120 sdl.nw set.l set.z sig.z sil.pw sil.nw sim.z sli.l + 128 sli.z slu.l slu.z sri.l sri.z sru.l sru.z sti.l + 136 sts.l sts.z str.s0 tge.z tle.z trp.z xor.l xor.z + 144 zer.l zer.z zge.l zgt.l zle.l zlt.l zne.l zrf.l + 152 zrf.z zrl.pw dch.z exg.s0 exg.l exg.z lpb.z gto.l +.DE 2 +Finally, the list of opcodes with four byte arguments (escape2). +.DS + + 0 loc +.DE 0 +.BP +.AP "AN EXAMPLE PROGRAM" +.DS B + 1 program example(output); + 2 {This program just demonstrates typical EM code.} + 3 type rec = record r1: integer; r2:real; r3: boolean end; + 4 var mi: integer; mx:real; r:rec; + 5 + 6 function sum(a,b:integer):integer; + 7 begin + 8 sum := a + b + 9 end; +10 +11 procedure test(var r: rec); +12 label 1; +13 var i,j: integer; +14 x,y: real; +15 b: boolean; +16 c: char; +17 a: array[1..100] of integer; +18 +19 begin +20 j := 1; +21 i := 3 * j + 6; +22 x := 4.8; +23 y := x/0.5; +24 b := true; +25 c := 'z'; +26 for i:= 1 to 100 do a[i] := i * i; +27 r.r1 := j+27; +28 r.r3 := b; +29 r.r2 := x+y; +30 i := sum(r.r1, a[j]); +31 while i > 0 do begin j := j + r.r1; i := i - 1 end; +32 with r do begin r3 := b; r2 := x+y; r1 := 0 end; +33 goto 1; +34 1: writeln(j, i:6, x:9:3, b) +35 end; {test} +36 begin {main program} +37 mx := 15.96; +38 mi := 99; +39 test(r) +40 end. +.DE 0 +.BP +The EM code as produced by the Pascal-VU compiler is given below. Comments +have been added manually. Note that this code has already been optimized. +.DS B + mes 2,2,2 ; wordsize 2, pointersize 2 + .1 + rom 't.p\e000' ; the name of the source file + hol 552,-32768,0 ; externals and buf occupy 552 bytes + exp $sum ; sum can be called from other modules + pro $sum,2 ; procedure sum; 2 bytes local storage + lin 8 ; code from source line 8 + ldl 0 ; load two locals ( a and b ) + adi 2 ; add them + ret 2 ; return the result + end 2 ; end of procedure ( still two bytes local storage ) + .2 + rom 1,99,2 ; descriptor of array a[] + exp $test ; the compiler exports all level 0 procedures + pro $test,226 ; procedure test, 226 bytes local storage + .3 + rom 4.8F8 ; assemble Floating point 4.8 (8 bytes) in + .4 ; global storage + rom 0.5F8 ; same for 0.5 + mes 3,-226,2,2 ; compiler temporary not referenced by address + mes 3,-24,2,0 ; the same is true for i, j, b and c in test + mes 3,-22,2,0 + mes 3,-4,2,0 + mes 3,-2,2,0 + mes 3,-20,8,0 ; and for x and y + mes 3,-12,8,0 + lin 20 ; maintain source line number + loc 1 + stl -4 ; j := 1 + lni ; lin 21 prior to optimization + lol -4 + loc 3 + mli 2 + loc 6 + adi 2 + stl -2 ; i := 3 * j + 6 + lni ; lin 22 prior to optimization + lae .3 + loi 8 + lal -12 + sti 8 ; x := 4.8 + lni ; lin 23 prior to optimization + lal -12 + loi 8 + lae .4 + loi 8 + dvf 8 + lal -20 + sti 8 ; y := x / 0.5 + lni ; lin 24 prior to optimization + loc 1 + stl -22 ; b := true + lni ; lin 25 prior to optimization + loc 122 + stl -24 ; c := 'z' + lni ; lin 26 prior to optimization + loc 1 + stl -2 ; for i:= 1 + 2 + lol -2 + dup 2 + mli 2 ; i*i + lal -224 + lol -2 + lae .2 + sar 2 ; a[i] := + lol -2 + loc 100 + beq *3 ; to 100 do + inl -2 ; increment i and loop + bra *2 + 3 + lin 27 + lol -4 + loc 27 + adi 2 ; j + 27 + sil 0 ; r.r1 := + lni ; lin 28 prior to optimization + lol -22 ; b + lol 0 + stf 10 ; r.r3 := + lni ; lin 29 prior to optimization + lal -20 + loi 16 + adf 8 ; x + y + lol 0 + adp 2 + sti 8 ; r.r2 := + lni ; lin 23 prior to optimization + lal -224 + lol -4 + lae .2 + lar 2 ; a[j] + lil 0 ; r.r1 + cal $sum ; call now + asp 4 ; remove parameters from stack + lfr 2 ; get function result + stl -2 ; i := + 4 + lin 31 + lol -2 + zle *5 ; while i > 0 do + lol -4 + lil 0 + adi 2 + stl -4 ; j := j + r.r1 + del -2 ; i := i - 1 + bra *4 ; loop + 5 + lin 32 + lol 0 + stl -226 ; make copy of address of r + lol -22 + lol -226 + stf 10 ; r3 := b + lal -20 + loi 16 + adf 8 + lol -226 + adp 2 + sti 8 ; r2 := x + y + loc 0 + sil -226 ; r1 := 0 + lin 34 ; note the abscence of the unnecesary jump + lae 22 ; address of output structure + lol -4 + cal $_wri ; write integer with default width + asp 4 ; pop parameters + lae 22 + lol -2 + loc 6 + cal $_wsi ; write integer width 6 + asp 6 + lae 22 + lal -12 + loi 8 + loc 9 + loc 3 + cal $_wrf ; write fixed format real, width 9, precision 3 + asp 14 + lae 22 + lol -22 + cal $_wrb ; write boolean, default width + asp 4 + lae 22 + cal $_wln ; writeln + asp 2 + ret 0 ; return, no result + end 226 + exp $_main + pro $_main,0 ; main program + .6 + con 2,-1,22 ; description of external files + .5 + rom 15.96F8 + fil .1 ; maintain source file name + lae .6 ; description of external files + lae 0 ; base of hol area to relocate buffer addresses + cal $_ini ; initialize files, etc... + asp 4 + lin 37 + lae .5 + loi 8 + lae 2 + sti 8 ; mx := 15.96 + lni ; lin 38 prior to optimization + loc 99 + ste 0 ; mi := 99 + lni ; lin 39 prior to optimization + lae 10 ; address of r + cal $test + asp 2 + loc 0 ; normal exit + cal $_hlt ; cleanup and finish + asp 2 + end 0 + mes 5 ; reals were used +.DE 0 +The compact code corresponding to the above program is listed below. +Read it horizontally, line by line, not column by column. +Each number represents a byte of compact code, printed in decimal. +The first two bytes form the magic word. +.N 1 +.IS 3 +.DS B +173 0 159 122 122 122 255 242 1 161 250 124 116 46 112 0 +255 156 245 40 2 245 0 128 120 155 249 123 115 117 109 160 +249 123 115 117 109 122 67 128 63 120 3 122 88 122 152 122 +242 2 161 121 219 122 255 155 249 124 116 101 115 116 160 249 +124 116 101 115 116 245 226 0 242 3 161 253 128 123 52 46 + 56 255 242 4 161 253 128 123 48 46 53 255 159 123 245 30 +255 122 122 255 159 123 96 122 120 255 159 123 98 122 120 255 +159 123 116 122 120 255 159 123 118 122 120 255 159 123 100 128 +120 255 159 123 108 128 120 255 67 140 69 121 113 116 68 73 +116 69 123 81 122 69 126 3 122 113 118 68 57 242 3 72 +128 58 108 112 128 68 58 108 72 128 57 242 4 72 128 44 +128 58 100 112 128 68 69 121 113 98 68 69 245 122 0 113 + 96 68 69 121 113 118 182 73 118 42 122 81 122 58 245 32 +255 73 118 57 242 2 94 122 73 118 69 220 10 123 54 118 + 18 122 183 67 147 73 116 69 147 3 122 104 120 68 73 98 + 73 120 111 130 68 58 100 72 136 2 128 73 120 4 122 112 +128 68 58 245 32 255 73 116 57 242 2 59 122 65 120 20 +249 123 115 117 109 8 124 64 122 113 118 184 67 151 73 118 +128 125 73 116 65 120 3 122 113 116 41 118 18 124 185 67 +152 73 120 113 245 30 255 73 98 73 245 30 255 111 130 58 +100 72 136 2 128 73 245 30 255 4 122 112 128 69 120 104 +245 30 255 67 154 57 142 73 116 20 249 124 95 119 114 105 + 8 124 57 142 73 118 69 126 20 249 124 95 119 115 105 8 +126 57 142 58 108 72 128 69 129 69 123 20 249 124 95 119 +114 102 8 134 57 142 73 98 20 249 124 95 119 114 98 8 +124 57 142 20 249 124 95 119 108 110 8 122 88 120 152 245 +226 0 155 249 125 95 109 97 105 110 160 249 125 95 109 97 +105 110 120 242 6 151 122 119 142 255 242 5 161 253 128 125 + 49 53 46 57 54 255 50 242 1 57 242 6 57 120 20 249 +124 95 105 110 105 8 124 67 157 57 242 5 72 128 57 122 +112 128 68 69 219 110 120 68 57 130 20 249 124 116 101 115 +116 8 122 69 120 20 249 124 95 104 108 116 8 122 152 120 +159 124 160 255 159 125 255 +.DE 0 +.IE +.MS T A 0 +.ME +.BP +.MS B A 0 +.ME +.CT diff --git a/doc/em/int/Makefile b/doc/em/int/Makefile new file mode 100644 index 00000000..7895cb20 --- /dev/null +++ b/doc/em/int/Makefile @@ -0,0 +1,32 @@ +CFLAGS=-O +HOME=../../.. + +install \ +all: em emdmp tables + +tables: mktables $(HOME)/etc/ip_spec.t + mktables $(HOME)/etc/ip_spec.t tables + +mktables: mktables.c $(HOME)/h/em_spec.h $(HOME)/h/em_flag.h \ + $(HOME)/lib.bin/em_data.a $(HOME)/h/ip_spec.h + $(CC) -I$(HOME)/h -O -o mktables mktables.c $(HOME)/lib.bin/em_data.a + +em.out: em.p + apc -mint -O em.p >emerrs ; mv e.out em.out + +em: em.p + apc -O -i em.p >emerrs ; mv a.out em + +nem.p: em.p + sed -e '/maxadr = t16/s//maxadr =t15/' -e '/maxdata = 8191; /s//maxdata = 14335;/' -e '/ adr=.*long/s// adr= 0..maxadr/' nem.p + +nem: nem.p + apc -O -i nem.p >emerrs ; mv a.out nem + +emdmp: emdmp.c + $(CC) -I$(HOME)/h -I$(HOME)/config -o emdmp -O emdmp.c + +cmp: + +pr: + @pr em.p mktables.c emdmp.c diff --git a/doc/em/iotrap.nr b/doc/em/iotrap.nr new file mode 100644 index 00000000..716f363b --- /dev/null +++ b/doc/em/iotrap.nr @@ -0,0 +1,376 @@ +.SN 8 +.VS 1 0 +.BP +.S1 "ENVIRONMENT INTERACTIONS" +EM programs can interact with their environment in three ways. +Two, starting/stopping and monitor calls, are dealt with in this chapter. +The remaining way to interact, interrupts, will be treated +together with traps in chapter 9. +.S2 "Program starting and stopping" +EM user programs start with a call to a procedure called +m_a_i_n. +The assembler and backends look for the definition of a procedure +with this name in their input. +The call passes three parameters to the procedure. +The parameters are similar to the parameters supplied by the +UNIX +.FS +UNIX is a Trademark of Bell Laboratories. +.FE +operating system to C programs. +These parameters are often called +.BW argc , +.B argv +and +.BW envp . +Argc is the parameter nearest to LB and is a wordsized integer. +The other two are pointers to the first element of an array of +string pointers. +.N +The +.B argv +array contains +.B argc +strings, the first of which contains the program call name. +The other strings in the +.B argv +array are the program parameters. +.P +The +.B envp +array contains strings in the form "name=string", where 'name' +is the name of an environment variable and string its value. +The +.B envp +is terminated by a zero pointer. +.P +An EM user program stops if the program returns from the first +invocation of m_a_i_n. +The contents of the function return area are used to procure a +wordsized program return code. +EM programs also stop when traps and interrupts occur that are +not caught and when the exit monitor call is executed. +.S2 "Input/Output and other monitor calls" +EM differs from most conventional machines in that it has high level i/o +instructions. +Typical instructions are OPEN FILE and READ FROM FILE instead +of low level instructions such as setting and clearing +bits in device registers. +By providing such high level i/o primitives, the task of implementing +EM on various non EM machines is made considerably easier. +.P +I/O is initiated by the MON instruction, which expects an iocode on top +of the stack. +Often there are also parameters which are pushed on the +stack in reverse order, that is: last +parameter first. +Some i/o functions also provide results, which are returned on the stack. +In the list of monitor calls we use several types of parameters and results, +these types consist of integers and unsigneds of varying sizes, but never +smaller than the wordsize, and the two pointer types. +.N 1 +The names of the types used are: +.IS 4 +.PS - 10 +.PT int +an integer of wordsize +.PT int2 +an integer whose size is the maximum of the wordsize and 2 +bytes +.PT int4 +an integer whose size is the maximum of the wordsize and 4 +bytes +.PT intp +an integer with the size of a pointer +.PT uns2 +an unsigned integer whose size is the maximum of the wordsize and 2 +.PT unsp +an unsigned integer with the size of a pointer +.PT ptr +a pointer into data space +.PE 1 +.IE 0 +The table below lists the i/o codes with their results and +parameters. +This list is similar to the system calls of the UNIX Version 7 +operating system. +.BP +.A +To execute a monitor call, proceed as follows: +.IS 2 +.N 1 +.PS a 4 "" ) +.PT +Stack the parameters, in reverse order, last parameter first. +.PT +Push the monitor call number (iocode) onto the stack. +.PT +Execute the MON instruction. +.PE 1 +.IE +An error code is present on the top of the stack after +execution of most monitor calls. +If this error code is zero, the call performed the action +requested and the results are available on top of the stack. +Non-zero error codes indicate a failure, in this case no +results are available and the error code has been pushed twice. +This construction enables programs to test for failure with a +single instruction (~TEQ or TNE~) and still find out the cause of +the failure. +The result name 'e' is reserved for the error code. +.N 1 +List of monitor calls. +.DS B +number name parameters results function + + 1 Exit status:int Terminate this process + 2 Fork e,flag,pid:int Spawn new process + 3 Read fildes:int;buf:ptr;nbytes:unsp + e:int;rbytes:unsp Read from file + 4 Write fildes:int;buf:ptr;nbytes:unsp + e:int;wbytes:unsp Write on a file + 5 Open string:ptr;flag:int + e,fildes:int Open file for read and/or write + 6 Close fildes:int e:int Close a file + 7 Wait e:int;status,pid:int2 + Wait for child + 8 Creat string:ptr;mode:int + e,fildes:int Create a new file + 9 Link string1,string2:ptr + e:int Link to a file + 10 Unlink string:ptr e:int Remove directory entry + 12 Chdir string:ptr e:int Change default directory + 14 Mknod string:ptr;mode,addr:int2 + e:int Make a special file + 15 Chmod string:ptr;mode:int2 + e:int Change mode of file + 16 Chown string:ptr;owner,group:int2 + e:int Change owner/group of a file + 18 Stat string,statbuf:ptr + e:int Get file status + 19 Lseek fildes:int;off:int4;whence:int + e:int;oldoff:int4 Move read/write pointer + 20 Getpid pid:int2 Get process identification + 21 Mount special,string:ptr;rwflag:int + e:int Mount file system + 22 Umount special:ptr e:int Unmount file system + 23 Setuid userid:int2 e:int Set user ID + 24 Getuid e_uid,r_uid:int2 Get user ID + 25 Stime time:int4 e:int Set time and date + 26 Ptrace request:int;pid:int2;addr:ptr;data:int + e,value:int Process trace + 27 Alarm seconds:uns2 previous:uns2 Schedule signal + 28 Fstat fildes:int;statbuf:ptr + e:int Get file status + 29 Pause Stop until signal + 30 Utime string,timep:ptr + e:int Set file times + 33 Access string,mode:int e:int Determine file accessibility + 34 Nice incr:int Set program priority + 35 Ftime bufp:ptr e:int Get date and time + 36 Sync Update filesystem + 37 Kill pid:int2;sig:int + e:int Send signal to a process + 41 Dup fildes,newfildes:int + e,fildes:int Duplicate a file descriptor + 42 Pipe e,w_des,r_des:int Create a pipe + 43 Times buffer:ptr Get process times + 44 Profil buff:ptr;bufsiz,offset,scale:intp Execution time profile + 46 Setgid gid:int2 e:int Set group ID + 47 Getgid e_gid,r_gid:int Get group ID + 48 Sigtrp trapno,signo:int + e,prevtrap:int See below + 51 Acct file:ptr e:int Turn accounting on or off + 53 Lock flag:int e:int Lock a process + 54 Ioctl fildes,request:int;argp:ptr + e:int Control device + 56 Mpxcall cmd:int;vec:ptr e:int Multiplexed file handling + 59 Exece name,argv,envp:ptr + e:int Execute a file + 60 Umask complmode:int2 oldmask:int2 Set file creation mode mask + 61 Chroot string:ptr e:int Change root directory +.DE 1 +Codes 0, 11, 13, 17, 31, 32, 38, 39, 40, 45, 49, 50, 52, +55, 57, 58, 62, and 63 are +not used. +.P +All monitor calls, except fork and sigtrp +are the same as the UNIX version 7 system calls. +.P +The sigtrp entry maps UNIX signals onto EM interrupts. +Normally, trapno is in the range 0 to 252. +In that case it requests that signal signo +will cause trap trapno to occur. +When given trap number -2, default signal handling is reset, and when given +trap number -3, the signal is ignored. +.P +The flag returned by fork is 1 in the child process and 0 in +the parent. +The pid returned is the process-id of the other process. +.BP +.S1 "TRAPS AND INTERRUPTS" +EM provides a means for the user program to catch all traps +generated by the program itself, the hardware, or external conditions. +This mechanism uses five instructions: LIM, SIM, SIG, TRP and RTT. +This section of the manual may be omitted on the first reading since it +presupposes knowledge of the EM instruction set. +.P +The action taken when a trap occures is determined by the value +of an internal EM trap register. +This register contains a pointer to a procedure. +Initially the pointer used is zero and all traps halt the +program with, hopefully, a useful message to the outside world. +The SIG instruction can be used to alter the trap register, +it pops a procedure pointer from the +stack into the trap register. +When a trap occurs after storing a nonzero value in the trap +register, the procedure pointed to by the trap register +is called with the trap number +as the only parameter (see below). +SIG returns the previous value of the trap register on the +stack. +Two consecutive SIGs are a no-op. +When a trap occurs, the trap register is reset to its initial +condition, to prevent recursive traps from hanging the machine up, +e.g. stack overflow in the stack overflow handling procedure. +.P +The runtime systems for some languages need to ignore some EM +traps. +EM offers a feature called the ignore mask. +It contains one bit for each of the lowest 16 trap numbers. +The bits are numbered 0 to 15, with the least significant bit +having number 0. +If a certain bit is 1 the corresponding trap never +occurs and processing simply continues. +The actions performed by the offending instruction are +described by the Pascal program in appendix A. +.N +If the bit is 0, traps are not ignored. +The instructions LIM and SIM allow copying and replacement of +the ignore mask.~ +.P +The TRP instruction generates a trap, the trap number being found on the +stack. +This is, among other things, +useful for library procedures and runtime systems. +It can also be used by a low level trap procedure to pass the trap to a +higher level one (see example below). +.P +The RTT instruction returns from the trap procedure and continues after the +trap. +In the list below all traps marked with an asterisk ('*') are +considered to be fatal and it is explicitly undefined what happens if +you try to restart after the trap. +.P +The way a trap procedure is called is completely compatible +with normal calling conventions. The only way a trap procedure +differs from normal procedures is the return. It has to use RTT instead +of RET. This is necessary because the complete runtime status is saved on the +stack before calling the procedure and all this status has to be reloaded. +Error numbers are in the range 0 to 252. +The trap numbers are divided into three categories: +.IS 4 +.N 1 +.PS - 10 +.PT ~~0-~63 +EM machine errors, e.g. illegal instruction. +.PS - 8 +.PT ~0-15 +maskable +.PT 16-63 +not maskable +.PE +.PT ~64-127 +Reserved for use by compilers, run time systems, etc. +.PT 128-252 +Available for user programs. +.PE 1 +.IE +EM machine errors are numbered as follows: +.DS I 5 +.TS +tab(@); +n l l. +0@EARRAY@Array bound error +1@ERANGE@Range bound error +2@ESET@Set bound error +3@EIOVFL@Integer overflow +4@EFOVFL@Floating overflow +5@EFUNFL@Floating underflow +6@EIDIVZ@Divide by 0 +7@EFDIVZ@Divide by 0.0 +8@EIUND@Undefined integer +9@EFUND@Undefined float +10@ECONV@Conversion error +16*@ESTACK@Stack overflow +17*@EHEAP@Heap overflow +18*@EILLINS@Illegal instruction +19*@EODDZ@Illegal size argument +20*@ECASE@Case error +21*@EMEMFLT@Addressing non existent memory +22*@EBADPTR@Bad pointer used +23*@EBADPC@Program counter out of range +24@EBADLAE@Bad argument of LAE +25@EBADMON@Bad monitor call +26@EBADLIN@Argument of LIN too high +27@EBADGTO@GTO descriptor error +.TE +.DE 0 +.P +As an example, +suppose a subprocedure has to be written to do a numeric +calculation. +When an overflow occurs the computation has to be stopped and +the higher level procedure must be resumed. +This can be programmed as follows using the mechanism described above: +.DS B + mes 2,2,2 ; set sizes +ersave + bss 2,0,0 ; Room to save previous value of trap procedure +msave + bss 2,0,0 ; Room to save previous value of trap mask + + pro calcule,0 ; entry point + lxl 0 ; fill in non-local goto descriptor with LB + ste jmpbuf+4 + lor 1 ; and SP + ste jmpbuf+2 + lim ; get current ignore mask + ste msave ; save it + lim + loc 16 ; bit for EFOVFL + ior 2 ; set in mask + sim ; ignore EFOVFL from now on + lpi $catch ; load procedure identifier + sig ; catch wil get all traps now + ste ersave ; save previous trap procedure identifier +; perform calculation now, possibly generating overflow +1 ; label jumped to by catch procedure + loe ersave ; get old trap procedure + sig ; refer all following trap to old procedure + asp 2 ; remove result of sig + loe msave ; restore previous mask + sim ; done now +; load result of calculation + ret 2 ; return result +jmpbuf + con *1,0,0 + end +.DE 0 +.VS 1 1 +.DS +Example of catch procedure + pro catch,0 ; Local procedure that must catch the overflow trap + lol 2 ; Load trap number + loc 4 ; check for overflow + bne *1 ; if other trap, call higher trap procedure + gto jmpbuf ; return to procedure calcule +1 ; other trap has occurred + loe ersave ; previous trap procedure + sig ; other procedure will get the traps now + asp 2 ; remove the result of sig + lol 2 ; stack trap number + trp ; call other trap procedure + rtt ; if other procedure returns, do the same + end +.DE diff --git a/doc/em/itables b/doc/em/itables new file mode 100644 index 00000000..a4825dc9 --- /dev/null +++ b/doc/em/itables @@ -0,0 +1,2922 @@ +.TS +.if \n+(b.=1 .nr d. \n(.c-\n(c.-1 +.de 35 +.ps \n(.s +.vs \n(.vu +.in \n(.iu +.if \n(.u .fi +.if \n(.j .ad +.if \n(.j=0 .na +.. +.nf +.nr #~ 0 +.if \n(.T .if n .nr #~ 0.6n +.ds #d .d +.if \(ts\n(.z\(ts\(ts .ds #d nl +.fc +.nr 33 \n(.s +.rm 66 67 68 69 70 71 72 73 74 75 76 77 +.nr 66 0 +.nr 38 \waar +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wadp +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wadp +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wasp +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wbeq +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wble +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wbne +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wbra +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wcff +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wcmf +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wcms +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wdec +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wdup +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wfil +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wine +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \winn +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlae +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlal +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlal +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wldc +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wldl +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlfr +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlil +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlni +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wloc +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wloe +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlof +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wloi +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlol +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlol +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlxa +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wmli +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wret +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wsbf +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wset +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wsli +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wstf +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wsti +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wstl +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wstl +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wtgt +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wzeq +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wzge +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wzlt +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wzre +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wzrl +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \waar +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wadi +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wads +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wand +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wass +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wbgt +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wbls +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wbne +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wcfi +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wcmf +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wcmi +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wcmu +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wcom +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wcsb +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wcui +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wdel +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wdus +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wdvf +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wdvu +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wfef +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \winl +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \winn +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlar +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wldf +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlfr +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlim +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlor +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlxl +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wmli +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wmlu +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wngf +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wnop +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wret +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wrmu +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wrol +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wrtt +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wsbf +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wsbi +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wsbu +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wsdf +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wset +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wsil +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wsli +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wslu +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wsru +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wsts +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wtge +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wxor +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wzer +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wzle +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wzrf +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wdch +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wexg +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wldc +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlal +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wldl +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlil +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlof +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wlpi +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wbeq +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wble +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wbne +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wdee +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wfil +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \winl +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wsde +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wsdl +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wste +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wstl +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wzgt +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wzne +.if \n(66<\n(38 .nr 66 \n(38 +.nr 38 \wzrl +.if \n(66<\n(38 .nr 66 \n(38 +.66 +.rm 66 +.nr 38 4n +.if \n(66<\n(38 .nr 66 \n(38 +.nr 67 0 +.nr 38 \wmwPo +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsN +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wmwPo +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wmwPo +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsw +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wN2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wswP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wmP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wmP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wmwP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wmN +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \ww2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wmwPo +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wmPo +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wwP2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wmwN +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wmPo +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wmwPo +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wmwPo +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wmPo +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wwP2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wmwN +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wsP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \ww2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wswN +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wewP2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wewP2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wesP +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wewP2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we2 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \we- +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wN4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wwP4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wwN4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \ww4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wwP4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wwN4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \ww4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wwN4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \w4 +.if \n(67<\n(38 .nr 67 \n(38 +.nr 38 \wwN4 +.if \n(67<\n(38 .nr 67 \n(38 +.67 +.rm 67 +.nr 38 6n +.if \n(67<\n(38 .nr 67 \n(38 +.nr 68 0 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w5 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w2 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w2 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w4 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w8 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w2 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w5 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.nr 38 \w1 +.if \n(68<\n(38 .nr 68 \n(38 +.68 +.rm 68 +.nr 38 2n +.if \n(68<\n(38 .nr 68 \n(38 +.nr 69 0 +.nr 38 \w34 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w38 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w42 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w45 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w52 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w55 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w58 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w62 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w93 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w96 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w100 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w103 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w106 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w109 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w112 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w117 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w120 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w129 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w132 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w136 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w139 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w143 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w146 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w150 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w152 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w155 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w162 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w168 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w174 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w180 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w190 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w194 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w199 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w202 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w206 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w209 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w214 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w218 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w224 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w228 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w235 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w238 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w242 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w245 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w248 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w252 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w1 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w4 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w7 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w10 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w13 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w16 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w19 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w22 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w25 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w28 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w31 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w34 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w37 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w40 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w43 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w46 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w49 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w52 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w55 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w58 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w61 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w64 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w67 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w70 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w73 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w76 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w79 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w82 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w85 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w88 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w91 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w94 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w97 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w100 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w103 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w106 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w109 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w112 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w115 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w118 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w121 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w124 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w127 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w130 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w133 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w136 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w139 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w142 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w145 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w148 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w151 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w154 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w157 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w0 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w3 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w6 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w9 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w12 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w15 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w18 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w21 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w24 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w27 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w30 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w33 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w36 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w39 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w42 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w45 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w48 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w51 +.if \n(69<\n(38 .nr 69 \n(38 +.nr 38 \w54 +.if \n(69<\n(38 .nr 69 \n(38 +.69 +.rm 69 +.nr 38 5n +.if \n(69<\n(38 .nr 69 \n(38 +.nr 70 0 +.nr 38 \wadf +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wadp +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wads +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wasp +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wbge +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wblm +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wbra +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wcal +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wcif +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wcmi +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wcsa +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wdee +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wdvf +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \winc +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \winl +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wior +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlae +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlal +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlal +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlde +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wldl +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlil +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlin +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wloc +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wloc +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wloe +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlof +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wloi +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlol +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlol +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlxl +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wrck +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wrmi +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsbi +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsil +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wste +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wstf +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsti +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wstl +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wstl +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wtlt +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wzeq +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wzgt +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wzne +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wzre +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wzrl +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wadf +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wadi +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wadu +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wand +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wass +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wble +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wbls +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wcai +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wcfu +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wcmf +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wcms +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wcmu +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wcsa +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wcsb +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wcuu +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wdel +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wdus +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wdvi +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wdvu +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wfif +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \winl +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wior +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlar +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wldl +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlil +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlos +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlpi +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wmlf +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wmli +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wmon +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wngi +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wrck +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wrmi +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wrmu +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wror +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsar +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsbf +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsbs +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsbu +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsdl +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wset +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsil +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsli +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsri +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsru +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsts +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wtle +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wxor +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wzge +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wzlt +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wzrf +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wexg +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlpb +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlae +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlde +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wldl +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wloc +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wlol +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wadp +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wbge +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wblm +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wbra +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wdel +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wgto +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \winl +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsdf +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wsil +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wstf +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wzeq +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wzle +.if \n(70<\n(38 .nr 70 \n(38 +.nr 38 \wzre +.if \n(70<\n(38 .nr 70 \n(38 +.70 +.rm 70 +.nr 38 4n +.if \n(70<\n(38 .nr 70 \n(38 +.nr 71 0 +.nr 38 \wsP +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmPo +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmwPo +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wswP +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wsP +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wsP +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmPo +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmwPo +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmwPo +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wsw +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wsP +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmwN +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmwPo +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wsw +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmP +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wswN +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \ww2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wswN +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wswN +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wsP +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wsw +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wsP +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmwPo +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wwN2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wswP +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmPo +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmwPo +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmwPo +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmwPo +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wswN +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \ww2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmwPo +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wmwPo +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wwN2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wswN +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wsP +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wsP +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wsP +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wsw +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wwN2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wewN2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wewN2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wewP2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wewP2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wewP2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wewN2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we2 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wesP +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \we- +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \ww4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wwN4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wwP4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wwP4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wwN4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \wwP4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \w4 +.if \n(71<\n(38 .nr 71 \n(38 +.nr 38 \ww4 +.if \n(71<\n(38 .nr 71 \n(38 +.71 +.rm 71 +.nr 38 6n +.if \n(71<\n(38 .nr 71 \n(38 +.nr 72 0 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w2 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w28 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w2 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w3 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w7 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w2 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w5 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w4 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w2 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w2 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w2 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w4 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w2 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.nr 38 \w1 +.if \n(72<\n(38 .nr 72 \n(38 +.72 +.rm 72 +.nr 38 2n +.if \n(72<\n(38 .nr 72 \n(38 +.nr 73 0 +.nr 38 \w35 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w39 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w43 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w50 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w53 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w56 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w59 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w64 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w94 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w97 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w101 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w104 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w107 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w110 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w113 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w118 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w121 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w130 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w133 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w137 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w140 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w144 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w148 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w151 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w153 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w156 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w166 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w169 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w175 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w188 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w191 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w196 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w200 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w203 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w207 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w210 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w215 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w219 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w225 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w233 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w236 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w239 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w243 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w246 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w249 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w253 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w2 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w5 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w8 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w11 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w14 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w17 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w20 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w23 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w26 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w29 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w32 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w35 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w38 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w41 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w44 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w47 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w50 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w53 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w56 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w59 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w62 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w65 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w68 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w71 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w74 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w77 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w80 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w83 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w86 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w89 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w92 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w95 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w98 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w101 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w104 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w107 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w110 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w113 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w116 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w119 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w122 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w125 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w128 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w131 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w134 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w137 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w140 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w143 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w146 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w149 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w152 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w155 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w158 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w1 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w4 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w7 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w10 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w13 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w16 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w19 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w22 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w25 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w28 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w31 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w34 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w37 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w40 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w43 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w46 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w49 +.if \n(73<\n(38 .nr 73 \n(38 +.nr 38 \w52 +.if \n(73<\n(38 .nr 73 \n(38 +.73 +.rm 73 +.nr 38 5n +.if \n(73<\n(38 .nr 73 \n(38 +.nr 74 0 +.nr 38 \wadi +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wadp +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wand +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wbeq +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wbgt +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wblt +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wbra +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wcal +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wcii +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wcmp +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wcsb +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wdel +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wdvi +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wine +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \winl +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wior +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlal +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlal +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlar +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlde +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlfr +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlil +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlin +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wloc +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wloc +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlof +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wloi +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wloi +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlol +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlol +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wmlf +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wret +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsar +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsdl +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsil +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wste +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wstf +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsti +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wstl +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wteq +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wtne +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wzer +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wzle +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wzne +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wzrl +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \waar +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wadf +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wads +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wadu +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wasp +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wbge +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wblm +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wblt +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wcal +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wciu +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wcmi +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wcms +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wcom +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wcsa +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wcuf +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wdee +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wdup +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wdvf +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wdvi +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wfef +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wfif +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \winn +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wior +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wldc +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wldl +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlil +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlos +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlxa +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wmlf +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wmlu +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wngf +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wngi +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wrck +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wrmi +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wrol +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wror +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsar +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsbi +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsbs +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsde +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsdl +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsig +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsim +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wslu +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsri +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsti +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wstr +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wtrp +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wzer +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wzgt +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wzne +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wzrl +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wexg +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wgto +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlal +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wldf +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlil +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wloe +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlol +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wasp +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wbgt +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wblt +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wcal +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wdel +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wine +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wlin +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsdl +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wsil +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wstl +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wzge +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wzlt +.if \n(74<\n(38 .nr 74 \n(38 +.nr 38 \wzrl +.if \n(74<\n(38 .nr 74 \n(38 +.74 +.rm 74 +.nr 38 4n +.if \n(74<\n(38 .nr 74 \n(38 +.nr 75 0 +.nr 38 \wmwPo +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wmwPo +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \w2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsN +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \w- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \w- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wmwPo +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wswN +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wmwPo +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \ww2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wswN +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wP2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wmN +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wmwPo +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsw +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wmwPo +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wswP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wmP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsN +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \w2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \w2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wmwP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wswN +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wmwP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wmwPo +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wswN +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wswP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsw +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wmwP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \w- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \w- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wsN +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wmwN +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wew2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wew2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wewN2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wewN2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wewN2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wesP +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we- +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wewP2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \we2 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wP4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \w4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wwP4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \ww4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wwN4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \ww4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \w4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \w4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \w4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wwN4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \ww4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \w4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wwP4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wwN4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wwP4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \w4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \w4 +.if \n(75<\n(38 .nr 75 \n(38 +.nr 38 \wwP4 +.if \n(75<\n(38 .nr 75 \n(38 +.75 +.rm 75 +.nr 38 6n +.if \n(75<\n(38 .nr 75 \n(38 +.nr 76 0 +.nr 38 \w2 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w2 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w2 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w34 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w4 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w2 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w3 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w2 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w2 +.if \n(76<\n(38 .nr 76 \n(38 +.nr 38 \w1 +.if \n(76<\n(38 .nr 76 \n(38 +.76 +.rm 76 +.nr 38 2n +.if \n(76<\n(38 .nr 76 \n(38 +.nr 77 0 +.nr 38 \w36 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w41 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w44 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w51 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w54 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w57 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w60 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w92 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w95 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w99 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w102 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w105 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w108 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w111 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w116 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w119 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w128 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w131 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w135 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w138 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w141 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w145 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w149 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w0 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w154 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w161 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w167 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w173 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w176 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w189 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w193 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w197 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w201 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w205 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w208 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w211 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w217 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w223 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w226 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w234 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w237 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w241 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w244 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w247 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w250 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w0 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w3 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w6 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w9 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w12 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w15 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w18 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w21 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w24 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w27 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w30 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w33 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w36 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w39 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w42 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w45 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w48 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w51 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w54 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w57 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w60 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w63 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w66 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w69 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w72 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w75 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w78 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w81 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w84 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w87 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w90 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w93 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w96 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w99 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w102 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w105 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w108 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w111 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w114 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w117 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w120 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w123 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w126 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w129 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w132 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w135 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w138 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w141 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w144 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w147 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w150 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w153 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w156 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w159 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w2 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w5 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w8 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w11 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w14 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w17 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w20 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w23 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w26 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w29 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w32 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w35 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w38 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w41 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w44 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w47 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w50 +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 \w53 +.if \n(77<\n(38 .nr 77 \n(38 +.77 +.rm 77 +.nr 38 5n +.if \n(77<\n(38 .nr 77 \n(38 +.nr 38 1n +.nr 65 0 +.nr 40 \n(65+((0*\n(38)/2) +.nr 66 +\n(40 +.nr 41 \n(66+((0*\n(38)/2) +.nr 67 +\n(41 +.nr 42 \n(67+((0*\n(38)/2) +.nr 68 +\n(42 +.nr 43 \n(68+((0*\n(38)/2) +.nr 69 +\n(43 +.nr 44 \n(69+((16*\n(38)/2) +.nr 70 +\n(44 +.nr 45 \n(70+((0*\n(38)/2) +.nr 71 +\n(45 +.nr 46 \n(71+((0*\n(38)/2) +.nr 72 +\n(46 +.nr 47 \n(72+((0*\n(38)/2) +.nr 73 +\n(47 +.nr 48 \n(73+((16*\n(38)/2) +.nr 74 +\n(48 +.nr 49 \n(74+((0*\n(38)/2) +.nr 75 +\n(49 +.nr 50 \n(75+((0*\n(38)/2) +.nr 76 +\n(50 +.nr 51 \n(76+((0*\n(38)/2) +.nr 77 +\n(51 +.nr TW \n(77 +.if t .if (\n(TW+\n(.o)>7.65i .tm Table at line 121 file Input is too wide - \n(TW units +.fc   +.nr #T 0-1 +.nr #a 0-1 +.eo +.de T# +.nr 35 1m +.ds #d .d +.if \(ts\n(.z\(ts\(ts .ds #d nl +.mk ## +.nr ## -1v +.ls 1 +.ls +.. +.ec +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'aar\h'|\n(41u'mwPo\h'|\n(42u'1\h'|\n(43u'34\h'|\n(44u'adf\h'|\n(45u'sP\h'|\n(46u'1\h'|\n(47u'35\h'|\n(48u'adi\h'|\n(49u'mwPo\h'|\n(50u'2\h'|\n(51u'36 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'adp\h'|\n(41u'2\h'|\n(42u'\h'|\n(43u'38\h'|\n(44u'adp\h'|\n(45u'mPo\h'|\n(46u'2\h'|\n(47u'39\h'|\n(48u'adp\h'|\n(49u'sP\h'|\n(50u'1\h'|\n(51u'41 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'adp\h'|\n(41u'sN\h'|\n(42u'1\h'|\n(43u'42\h'|\n(44u'ads\h'|\n(45u'mwPo\h'|\n(46u'1\h'|\n(47u'43\h'|\n(48u'and\h'|\n(49u'mwPo\h'|\n(50u'1\h'|\n(51u'44 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'asp\h'|\n(41u'mwPo\h'|\n(42u'5\h'|\n(43u'45\h'|\n(44u'asp\h'|\n(45u'swP\h'|\n(46u'1\h'|\n(47u'50\h'|\n(48u'beq\h'|\n(49u'2\h'|\n(50u'\h'|\n(51u'51 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'beq\h'|\n(41u'sP\h'|\n(42u'1\h'|\n(43u'52\h'|\n(44u'bge\h'|\n(45u'sP\h'|\n(46u'1\h'|\n(47u'53\h'|\n(48u'bgt\h'|\n(49u'sP\h'|\n(50u'1\h'|\n(51u'54 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'ble\h'|\n(41u'sP\h'|\n(42u'1\h'|\n(43u'55\h'|\n(44u'blm\h'|\n(45u'sP\h'|\n(46u'1\h'|\n(47u'56\h'|\n(48u'blt\h'|\n(49u'sP\h'|\n(50u'1\h'|\n(51u'57 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'bne\h'|\n(41u'sP\h'|\n(42u'1\h'|\n(43u'58\h'|\n(44u'bra\h'|\n(45u'2\h'|\n(46u'\h'|\n(47u'59\h'|\n(48u'bra\h'|\n(49u'sN\h'|\n(50u'2\h'|\n(51u'60 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'bra\h'|\n(41u'sP\h'|\n(42u'2\h'|\n(43u'62\h'|\n(44u'cal\h'|\n(45u'mPo\h'|\n(46u'28\h'|\n(47u'64\h'|\n(48u'cal\h'|\n(49u'sP\h'|\n(50u'1\h'|\n(51u'92 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'cff\h'|\n(41u'-\h'|\n(42u'\h'|\n(43u'93\h'|\n(44u'cif\h'|\n(45u'-\h'|\n(46u'\h'|\n(47u'94\h'|\n(48u'cii\h'|\n(49u'-\h'|\n(50u'\h'|\n(51u'95 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'cmf\h'|\n(41u'sP\h'|\n(42u'1\h'|\n(43u'96\h'|\n(44u'cmi\h'|\n(45u'mwPo\h'|\n(46u'2\h'|\n(47u'97\h'|\n(48u'cmp\h'|\n(49u'-\h'|\n(50u'\h'|\n(51u'99 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'cms\h'|\n(41u'sP\h'|\n(42u'1\h'|\n(43u'100\h'|\n(44u'csa\h'|\n(45u'mwPo\h'|\n(46u'1\h'|\n(47u'101\h'|\n(48u'csb\h'|\n(49u'mwPo\h'|\n(50u'1\h'|\n(51u'102 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'dec\h'|\n(41u'-\h'|\n(42u'\h'|\n(43u'103\h'|\n(44u'dee\h'|\n(45u'sw\h'|\n(46u'1\h'|\n(47u'104\h'|\n(48u'del\h'|\n(49u'swN\h'|\n(50u'1\h'|\n(51u'105 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'dup\h'|\n(41u'mwPo\h'|\n(42u'1\h'|\n(43u'106\h'|\n(44u'dvf\h'|\n(45u'sP\h'|\n(46u'1\h'|\n(47u'107\h'|\n(48u'dvi\h'|\n(49u'mwPo\h'|\n(50u'1\h'|\n(51u'108 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'fil\h'|\n(41u'2\h'|\n(42u'\h'|\n(43u'109\h'|\n(44u'inc\h'|\n(45u'-\h'|\n(46u'\h'|\n(47u'110\h'|\n(48u'ine\h'|\n(49u'w2\h'|\n(50u'\h'|\n(51u'111 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'ine\h'|\n(41u'sw\h'|\n(42u'1\h'|\n(43u'112\h'|\n(44u'inl\h'|\n(45u'mwN\h'|\n(46u'3\h'|\n(47u'113\h'|\n(48u'inl\h'|\n(49u'swN\h'|\n(50u'1\h'|\n(51u'116 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'inn\h'|\n(41u'sP\h'|\n(42u'1\h'|\n(43u'117\h'|\n(44u'ior\h'|\n(45u'mwPo\h'|\n(46u'1\h'|\n(47u'118\h'|\n(48u'ior\h'|\n(49u'sP\h'|\n(50u'1\h'|\n(51u'119 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lae\h'|\n(41u'2\h'|\n(42u'\h'|\n(43u'120\h'|\n(44u'lae\h'|\n(45u'sw\h'|\n(46u'7\h'|\n(47u'121\h'|\n(48u'lal\h'|\n(49u'P2\h'|\n(50u'\h'|\n(51u'128 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lal\h'|\n(41u'N2\h'|\n(42u'\h'|\n(43u'129\h'|\n(44u'lal\h'|\n(45u'mP\h'|\n(46u'1\h'|\n(47u'130\h'|\n(48u'lal\h'|\n(49u'mN\h'|\n(50u'1\h'|\n(51u'131 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lal\h'|\n(41u'swP\h'|\n(42u'1\h'|\n(43u'132\h'|\n(44u'lal\h'|\n(45u'swN\h'|\n(46u'2\h'|\n(47u'133\h'|\n(48u'lar\h'|\n(49u'mwPo\h'|\n(50u'1\h'|\n(51u'135 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'ldc\h'|\n(41u'mP\h'|\n(42u'1\h'|\n(43u'136\h'|\n(44u'lde\h'|\n(45u'w2\h'|\n(46u'\h'|\n(47u'137\h'|\n(48u'lde\h'|\n(49u'sw\h'|\n(50u'1\h'|\n(51u'138 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'ldl\h'|\n(41u'mP\h'|\n(42u'1\h'|\n(43u'139\h'|\n(44u'ldl\h'|\n(45u'swN\h'|\n(46u'1\h'|\n(47u'140\h'|\n(48u'lfr\h'|\n(49u'mwPo\h'|\n(50u'2\h'|\n(51u'141 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lfr\h'|\n(41u'sP\h'|\n(42u'1\h'|\n(43u'143\h'|\n(44u'lil\h'|\n(45u'swN\h'|\n(46u'1\h'|\n(47u'144\h'|\n(48u'lil\h'|\n(49u'swP\h'|\n(50u'1\h'|\n(51u'145 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lil\h'|\n(41u'mwP\h'|\n(42u'2\h'|\n(43u'146\h'|\n(44u'lin\h'|\n(45u'2\h'|\n(46u'\h'|\n(47u'148\h'|\n(48u'lin\h'|\n(49u'sP\h'|\n(50u'1\h'|\n(51u'149 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lni\h'|\n(41u'-\h'|\n(42u'\h'|\n(43u'150\h'|\n(44u'loc\h'|\n(45u'2\h'|\n(46u'\h'|\n(47u'151\h'|\n(48u'loc\h'|\n(49u'mP\h'|\n(50u'34\h'|\n(51u'0 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'loc\h'|\n(41u'mN\h'|\n(42u'1\h'|\n(43u'152\h'|\n(44u'loc\h'|\n(45u'sP\h'|\n(46u'1\h'|\n(47u'153\h'|\n(48u'loc\h'|\n(49u'sN\h'|\n(50u'1\h'|\n(51u'154 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'loe\h'|\n(41u'w2\h'|\n(42u'\h'|\n(43u'155\h'|\n(44u'loe\h'|\n(45u'sw\h'|\n(46u'5\h'|\n(47u'156\h'|\n(48u'lof\h'|\n(49u'2\h'|\n(50u'\h'|\n(51u'161 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lof\h'|\n(41u'mwPo\h'|\n(42u'4\h'|\n(43u'162\h'|\n(44u'lof\h'|\n(45u'sP\h'|\n(46u'1\h'|\n(47u'166\h'|\n(48u'loi\h'|\n(49u'2\h'|\n(50u'\h'|\n(51u'167 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'loi\h'|\n(41u'mPo\h'|\n(42u'1\h'|\n(43u'168\h'|\n(44u'loi\h'|\n(45u'mwPo\h'|\n(46u'4\h'|\n(47u'169\h'|\n(48u'loi\h'|\n(49u'sP\h'|\n(50u'1\h'|\n(51u'173 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lol\h'|\n(41u'wP2\h'|\n(42u'\h'|\n(43u'174\h'|\n(44u'lol\h'|\n(45u'wN2\h'|\n(46u'\h'|\n(47u'175\h'|\n(48u'lol\h'|\n(49u'mwP\h'|\n(50u'4\h'|\n(51u'176 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lol\h'|\n(41u'mwN\h'|\n(42u'8\h'|\n(43u'180\h'|\n(44u'lol\h'|\n(45u'swP\h'|\n(46u'1\h'|\n(47u'188\h'|\n(48u'lol\h'|\n(49u'swN\h'|\n(50u'1\h'|\n(51u'189 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lxa\h'|\n(41u'mPo\h'|\n(42u'1\h'|\n(43u'190\h'|\n(44u'lxl\h'|\n(45u'mPo\h'|\n(46u'2\h'|\n(47u'191\h'|\n(48u'mlf\h'|\n(49u'sP\h'|\n(50u'1\h'|\n(51u'193 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'mli\h'|\n(41u'mwPo\h'|\n(42u'2\h'|\n(43u'194\h'|\n(44u'rck\h'|\n(45u'mwPo\h'|\n(46u'1\h'|\n(47u'196\h'|\n(48u'ret\h'|\n(49u'mwP\h'|\n(50u'2\h'|\n(51u'197 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'ret\h'|\n(41u'sP\h'|\n(42u'1\h'|\n(43u'199\h'|\n(44u'rmi\h'|\n(45u'mwPo\h'|\n(46u'1\h'|\n(47u'200\h'|\n(48u'sar\h'|\n(49u'mwPo\h'|\n(50u'1\h'|\n(51u'201 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'sbf\h'|\n(41u'sP\h'|\n(42u'1\h'|\n(43u'202\h'|\n(44u'sbi\h'|\n(45u'mwPo\h'|\n(46u'2\h'|\n(47u'203\h'|\n(48u'sdl\h'|\n(49u'swN\h'|\n(50u'1\h'|\n(51u'205 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'set\h'|\n(41u'sP\h'|\n(42u'1\h'|\n(43u'206\h'|\n(44u'sil\h'|\n(45u'swN\h'|\n(46u'1\h'|\n(47u'207\h'|\n(48u'sil\h'|\n(49u'swP\h'|\n(50u'1\h'|\n(51u'208 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'sli\h'|\n(41u'mwPo\h'|\n(42u'1\h'|\n(43u'209\h'|\n(44u'ste\h'|\n(45u'w2\h'|\n(46u'\h'|\n(47u'210\h'|\n(48u'ste\h'|\n(49u'sw\h'|\n(50u'3\h'|\n(51u'211 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'stf\h'|\n(41u'2\h'|\n(42u'\h'|\n(43u'214\h'|\n(44u'stf\h'|\n(45u'mwPo\h'|\n(46u'2\h'|\n(47u'215\h'|\n(48u'stf\h'|\n(49u'sP\h'|\n(50u'1\h'|\n(51u'217 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'sti\h'|\n(41u'mPo\h'|\n(42u'1\h'|\n(43u'218\h'|\n(44u'sti\h'|\n(45u'mwPo\h'|\n(46u'4\h'|\n(47u'219\h'|\n(48u'sti\h'|\n(49u'sP\h'|\n(50u'1\h'|\n(51u'223 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'stl\h'|\n(41u'wP2\h'|\n(42u'\h'|\n(43u'224\h'|\n(44u'stl\h'|\n(45u'wN2\h'|\n(46u'\h'|\n(47u'225\h'|\n(48u'stl\h'|\n(49u'mwP\h'|\n(50u'2\h'|\n(51u'226 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'stl\h'|\n(41u'mwN\h'|\n(42u'5\h'|\n(43u'228\h'|\n(44u'stl\h'|\n(45u'swN\h'|\n(46u'1\h'|\n(47u'233\h'|\n(48u'teq\h'|\n(49u'-\h'|\n(50u'\h'|\n(51u'234 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'tgt\h'|\n(41u'-\h'|\n(42u'\h'|\n(43u'235\h'|\n(44u'tlt\h'|\n(45u'-\h'|\n(46u'\h'|\n(47u'236\h'|\n(48u'tne\h'|\n(49u'-\h'|\n(50u'\h'|\n(51u'237 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'zeq\h'|\n(41u'2\h'|\n(42u'\h'|\n(43u'238\h'|\n(44u'zeq\h'|\n(45u'sP\h'|\n(46u'2\h'|\n(47u'239\h'|\n(48u'zer\h'|\n(49u'sP\h'|\n(50u'1\h'|\n(51u'241 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'zge\h'|\n(41u'sP\h'|\n(42u'1\h'|\n(43u'242\h'|\n(44u'zgt\h'|\n(45u'sP\h'|\n(46u'1\h'|\n(47u'243\h'|\n(48u'zle\h'|\n(49u'sP\h'|\n(50u'1\h'|\n(51u'244 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'zlt\h'|\n(41u'sP\h'|\n(42u'1\h'|\n(43u'245\h'|\n(44u'zne\h'|\n(45u'sP\h'|\n(46u'1\h'|\n(47u'246\h'|\n(48u'zne\h'|\n(49u'sN\h'|\n(50u'1\h'|\n(51u'247 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'zre\h'|\n(41u'w2\h'|\n(42u'\h'|\n(43u'248\h'|\n(44u'zre\h'|\n(45u'sw\h'|\n(46u'1\h'|\n(47u'249\h'|\n(48u'zrl\h'|\n(49u'mwN\h'|\n(50u'2\h'|\n(51u'250 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'zrl\h'|\n(41u'swN\h'|\n(42u'1\h'|\n(43u'252\h'|\n(44u'zrl\h'|\n(45u'wN2\h'|\n(46u'\h'|\n(47u'253\h'|\n(48u'aar\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'0 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'aar\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'1\h'|\n(44u'adf\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'2\h'|\n(48u'adf\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'3 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'adi\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'4\h'|\n(44u'adi\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'5\h'|\n(48u'ads\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'6 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'ads\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'7\h'|\n(44u'adu\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'8\h'|\n(48u'adu\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'9 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'and\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'10\h'|\n(44u'and\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'11\h'|\n(48u'asp\h'|\n(49u'ew2\h'|\n(50u'\h'|\n(51u'12 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'ass\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'13\h'|\n(44u'ass\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'14\h'|\n(48u'bge\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'15 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'bgt\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'16\h'|\n(44u'ble\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'17\h'|\n(48u'blm\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'18 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'bls\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'19\h'|\n(44u'bls\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'20\h'|\n(48u'blt\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'21 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'bne\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'22\h'|\n(44u'cai\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'23\h'|\n(48u'cal\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'24 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'cfi\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'25\h'|\n(44u'cfu\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'26\h'|\n(48u'ciu\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'27 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'cmf\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'28\h'|\n(44u'cmf\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'29\h'|\n(48u'cmi\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'30 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'cmi\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'31\h'|\n(44u'cms\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'32\h'|\n(48u'cms\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'33 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'cmu\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'34\h'|\n(44u'cmu\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'35\h'|\n(48u'com\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'36 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'com\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'37\h'|\n(44u'csa\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'38\h'|\n(48u'csa\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'39 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'csb\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'40\h'|\n(44u'csb\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'41\h'|\n(48u'cuf\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'42 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'cui\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'43\h'|\n(44u'cuu\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'44\h'|\n(48u'dee\h'|\n(49u'ew2\h'|\n(50u'\h'|\n(51u'45 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'del\h'|\n(41u'ewP2\h'|\n(42u'\h'|\n(43u'46\h'|\n(44u'del\h'|\n(45u'ewN2\h'|\n(46u'\h'|\n(47u'47\h'|\n(48u'dup\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'48 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'dus\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'49\h'|\n(44u'dus\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'50\h'|\n(48u'dvf\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'51 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'dvf\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'52\h'|\n(44u'dvi\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'53\h'|\n(48u'dvi\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'54 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'dvu\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'55\h'|\n(44u'dvu\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'56\h'|\n(48u'fef\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'57 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'fef\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'58\h'|\n(44u'fif\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'59\h'|\n(48u'fif\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'60 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'inl\h'|\n(41u'ewP2\h'|\n(42u'\h'|\n(43u'61\h'|\n(44u'inl\h'|\n(45u'ewN2\h'|\n(46u'\h'|\n(47u'62\h'|\n(48u'inn\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'63 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'inn\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'64\h'|\n(44u'ior\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'65\h'|\n(48u'ior\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'66 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lar\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'67\h'|\n(44u'lar\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'68\h'|\n(48u'ldc\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'69 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'ldf\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'70\h'|\n(44u'ldl\h'|\n(45u'ewP2\h'|\n(46u'\h'|\n(47u'71\h'|\n(48u'ldl\h'|\n(49u'ewN2\h'|\n(50u'\h'|\n(51u'72 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lfr\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'73\h'|\n(44u'lil\h'|\n(45u'ewP2\h'|\n(46u'\h'|\n(47u'74\h'|\n(48u'lil\h'|\n(49u'ewN2\h'|\n(50u'\h'|\n(51u'75 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lim\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'76\h'|\n(44u'los\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'77\h'|\n(48u'los\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'78 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lor\h'|\n(41u'esP\h'|\n(42u'1\h'|\n(43u'79\h'|\n(44u'lpi\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'80\h'|\n(48u'lxa\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'81 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lxl\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'82\h'|\n(44u'mlf\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'83\h'|\n(48u'mlf\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'84 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'mli\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'85\h'|\n(44u'mli\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'86\h'|\n(48u'mlu\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'87 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'mlu\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'88\h'|\n(44u'mon\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'89\h'|\n(48u'ngf\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'90 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'ngf\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'91\h'|\n(44u'ngi\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'92\h'|\n(48u'ngi\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'93 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'nop\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'94\h'|\n(44u'rck\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'95\h'|\n(48u'rck\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'96 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'ret\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'97\h'|\n(44u'rmi\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'98\h'|\n(48u'rmi\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'99 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'rmu\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'100\h'|\n(44u'rmu\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'101\h'|\n(48u'rol\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'102 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'rol\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'103\h'|\n(44u'ror\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'104\h'|\n(48u'ror\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'105 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'rtt\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'106\h'|\n(44u'sar\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'107\h'|\n(48u'sar\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'108 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'sbf\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'109\h'|\n(44u'sbf\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'110\h'|\n(48u'sbi\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'111 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'sbi\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'112\h'|\n(44u'sbs\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'113\h'|\n(48u'sbs\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'114 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'sbu\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'115\h'|\n(44u'sbu\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'116\h'|\n(48u'sde\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'117 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'sdf\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'118\h'|\n(44u'sdl\h'|\n(45u'ewP2\h'|\n(46u'\h'|\n(47u'119\h'|\n(48u'sdl\h'|\n(49u'ewN2\h'|\n(50u'\h'|\n(51u'120 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'set\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'121\h'|\n(44u'set\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'122\h'|\n(48u'sig\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'123 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'sil\h'|\n(41u'ewP2\h'|\n(42u'\h'|\n(43u'124\h'|\n(44u'sil\h'|\n(45u'ewN2\h'|\n(46u'\h'|\n(47u'125\h'|\n(48u'sim\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'126 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'sli\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'127\h'|\n(44u'sli\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'128\h'|\n(48u'slu\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'129 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'slu\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'130\h'|\n(44u'sri\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'131\h'|\n(48u'sri\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'132 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'sru\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'133\h'|\n(44u'sru\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'134\h'|\n(48u'sti\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'135 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'sts\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'136\h'|\n(44u'sts\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'137\h'|\n(48u'str\h'|\n(49u'esP\h'|\n(50u'1\h'|\n(51u'138 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'tge\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'139\h'|\n(44u'tle\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'140\h'|\n(48u'trp\h'|\n(49u'e-\h'|\n(50u'\h'|\n(51u'141 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'xor\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'142\h'|\n(44u'xor\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'143\h'|\n(48u'zer\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'144 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'zer\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'145\h'|\n(44u'zge\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'146\h'|\n(48u'zgt\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'147 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'zle\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'148\h'|\n(44u'zlt\h'|\n(45u'e2\h'|\n(46u'\h'|\n(47u'149\h'|\n(48u'zne\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'150 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'zrf\h'|\n(41u'e2\h'|\n(42u'\h'|\n(43u'151\h'|\n(44u'zrf\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'152\h'|\n(48u'zrl\h'|\n(49u'ewP2\h'|\n(50u'\h'|\n(51u'153 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'dch\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'154\h'|\n(44u'exg\h'|\n(45u'esP\h'|\n(46u'1\h'|\n(47u'155\h'|\n(48u'exg\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'156 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'exg\h'|\n(41u'e-\h'|\n(42u'\h'|\n(43u'157\h'|\n(44u'lpb\h'|\n(45u'e-\h'|\n(46u'\h'|\n(47u'158\h'|\n(48u'gto\h'|\n(49u'e2\h'|\n(50u'\h'|\n(51u'159 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'ldc\h'|\n(41u'4\h'|\n(42u'\h'|\n(43u'0\h'|\n(44u'lae\h'|\n(45u'4\h'|\n(46u'\h'|\n(47u'1\h'|\n(48u'lal\h'|\n(49u'P4\h'|\n(50u'\h'|\n(51u'2 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lal\h'|\n(41u'N4\h'|\n(42u'\h'|\n(43u'3\h'|\n(44u'lde\h'|\n(45u'w4\h'|\n(46u'\h'|\n(47u'4\h'|\n(48u'ldf\h'|\n(49u'4\h'|\n(50u'\h'|\n(51u'5 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'ldl\h'|\n(41u'wP4\h'|\n(42u'\h'|\n(43u'6\h'|\n(44u'ldl\h'|\n(45u'wN4\h'|\n(46u'\h'|\n(47u'7\h'|\n(48u'lil\h'|\n(49u'wP4\h'|\n(50u'\h'|\n(51u'8 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lil\h'|\n(41u'wN4\h'|\n(42u'\h'|\n(43u'9\h'|\n(44u'loc\h'|\n(45u'4\h'|\n(46u'\h'|\n(47u'10\h'|\n(48u'loe\h'|\n(49u'w4\h'|\n(50u'\h'|\n(51u'11 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lof\h'|\n(41u'4\h'|\n(42u'\h'|\n(43u'12\h'|\n(44u'lol\h'|\n(45u'wP4\h'|\n(46u'\h'|\n(47u'13\h'|\n(48u'lol\h'|\n(49u'wN4\h'|\n(50u'\h'|\n(51u'14 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'lpi\h'|\n(41u'4\h'|\n(42u'\h'|\n(43u'15\h'|\n(44u'adp\h'|\n(45u'4\h'|\n(46u'\h'|\n(47u'16\h'|\n(48u'asp\h'|\n(49u'w4\h'|\n(50u'\h'|\n(51u'17 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'beq\h'|\n(41u'4\h'|\n(42u'\h'|\n(43u'18\h'|\n(44u'bge\h'|\n(45u'4\h'|\n(46u'\h'|\n(47u'19\h'|\n(48u'bgt\h'|\n(49u'4\h'|\n(50u'\h'|\n(51u'20 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'ble\h'|\n(41u'4\h'|\n(42u'\h'|\n(43u'21\h'|\n(44u'blm\h'|\n(45u'4\h'|\n(46u'\h'|\n(47u'22\h'|\n(48u'blt\h'|\n(49u'4\h'|\n(50u'\h'|\n(51u'23 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'bne\h'|\n(41u'4\h'|\n(42u'\h'|\n(43u'24\h'|\n(44u'bra\h'|\n(45u'4\h'|\n(46u'\h'|\n(47u'25\h'|\n(48u'cal\h'|\n(49u'4\h'|\n(50u'\h'|\n(51u'26 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'dee\h'|\n(41u'w4\h'|\n(42u'\h'|\n(43u'27\h'|\n(44u'del\h'|\n(45u'wP4\h'|\n(46u'\h'|\n(47u'28\h'|\n(48u'del\h'|\n(49u'wN4\h'|\n(50u'\h'|\n(51u'29 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'fil\h'|\n(41u'4\h'|\n(42u'\h'|\n(43u'30\h'|\n(44u'gto\h'|\n(45u'4\h'|\n(46u'\h'|\n(47u'31\h'|\n(48u'ine\h'|\n(49u'w4\h'|\n(50u'\h'|\n(51u'32 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'inl\h'|\n(41u'wP4\h'|\n(42u'\h'|\n(43u'33\h'|\n(44u'inl\h'|\n(45u'wN4\h'|\n(46u'\h'|\n(47u'34\h'|\n(48u'lin\h'|\n(49u'4\h'|\n(50u'\h'|\n(51u'35 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'sde\h'|\n(41u'4\h'|\n(42u'\h'|\n(43u'36\h'|\n(44u'sdf\h'|\n(45u'4\h'|\n(46u'\h'|\n(47u'37\h'|\n(48u'sdl\h'|\n(49u'wP4\h'|\n(50u'\h'|\n(51u'38 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'sdl\h'|\n(41u'wN4\h'|\n(42u'\h'|\n(43u'39\h'|\n(44u'sil\h'|\n(45u'wP4\h'|\n(46u'\h'|\n(47u'40\h'|\n(48u'sil\h'|\n(49u'wN4\h'|\n(50u'\h'|\n(51u'41 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'ste\h'|\n(41u'w4\h'|\n(42u'\h'|\n(43u'42\h'|\n(44u'stf\h'|\n(45u'4\h'|\n(46u'\h'|\n(47u'43\h'|\n(48u'stl\h'|\n(49u'wP4\h'|\n(50u'\h'|\n(51u'44 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'stl\h'|\n(41u'wN4\h'|\n(42u'\h'|\n(43u'45\h'|\n(44u'zeq\h'|\n(45u'4\h'|\n(46u'\h'|\n(47u'46\h'|\n(48u'zge\h'|\n(49u'4\h'|\n(50u'\h'|\n(51u'47 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'zgt\h'|\n(41u'4\h'|\n(42u'\h'|\n(43u'48\h'|\n(44u'zle\h'|\n(45u'4\h'|\n(46u'\h'|\n(47u'49\h'|\n(48u'zlt\h'|\n(49u'4\h'|\n(50u'\h'|\n(51u'50 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'zne\h'|\n(41u'4\h'|\n(42u'\h'|\n(43u'51\h'|\n(44u'zre\h'|\n(45u'w4\h'|\n(46u'\h'|\n(47u'52\h'|\n(48u'zrl\h'|\n(49u'wP4\h'|\n(50u'\h'|\n(51u'53 +.ta \n(66u \n(67u \n(68u \n(69u \n(70u \n(71u \n(72u \n(73u \n(74u \n(75u \n(76u \n(77u +.nr 35 1m +.nr 31 \n(.f +\&\h'|\n(40u'zrl\h'|\n(41u'wN4\h'|\n(42u'\h'|\n(43u'54\h'|\n(44u'\h'|\n(45u'\h'|\n(46u'\h'|\n(47u'\h'|\n(48u'\h'|\n(49u'\h'|\n(50u'\h'|\n(51u' +.fc +.nr T. 1 +.T# 1 +.35 +.TE +.if \n-(b.=0 .nr c. \n(.c-\n(d.-120 diff --git a/doc/em/print b/doc/em/print new file mode 100755 index 00000000..a9b9b033 --- /dev/null +++ b/doc/em/print @@ -0,0 +1,5 @@ + +case $# in +1) make "$1".t ; ntlp "$1".t^lpr ;; +*) echo $0 heeft een argument nodig ;; +esac diff --git a/doc/em/show b/doc/em/show new file mode 100755 index 00000000..f60e8e46 --- /dev/null +++ b/doc/em/show @@ -0,0 +1,4 @@ +case $# in +1) make $1.t ; ntout $1.t ;; +*) echo $0 heeft een argument nodig ;; +esac diff --git a/doc/lint/Makefile b/doc/lint/Makefile new file mode 100644 index 00000000..3a17c50b --- /dev/null +++ b/doc/lint/Makefile @@ -0,0 +1,9 @@ +# $Header$ + +FP = frontpage + +DOC = abstract contents chap1 chap2 chap3 chap4 chap5 chap6 chap7\ + chap8 chap9 appendix_A appendix_B + +../lint.doc: $(FP) $(DOC) + cat $(FP) $(DOC) > ../lint.doc diff --git a/doc/occam/Makefile b/doc/occam/Makefile new file mode 100644 index 00000000..9a5ba5b4 --- /dev/null +++ b/doc/occam/Makefile @@ -0,0 +1,18 @@ +EMHOME=../.. +FILES= p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 + +PIC=pic +EQN=eqn +TBL=tbl +TARGET=-Tlp +../occam.doc: p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 channel.h.t channel.c.t + soelim $(FILES) | $(PIC) $(TARGET) | $(TBL) | $(EQN) $(TARGET) > $@ + +channel.h.t: $(EMHOME)/h/ocm_chan.h + ctot <$(EMHOME)/h/ocm_chan.h >channel.h.t + +channel.c.t: channel.c + ctot channel.c.t + +channel.c: $(EMHOME)/lang/occam/lib/tail_ocm.a + arch x $(EMHOME)/lang/occam/lib/tail_ocm.a channel.c diff --git a/doc/sparc/Makefile b/doc/sparc/Makefile new file mode 100644 index 00000000..6bff6816 --- /dev/null +++ b/doc/sparc/Makefile @@ -0,0 +1,10 @@ +# $Header$ + +REFER=refer +TBL=tbl +TARGET=-Tlp +PIC=pic +GRAP=grap + +../sparc.doc: refs title intro 1 2 3 4 5 A B init + $(REFER) -sA+T '-l\", ' -p refs title intro 1 2 3 4 5 A B | $(GRAP) | $(PIC) | $(TBL) | soelim > $@ diff --git a/doc/top/Makefile b/doc/top/Makefile new file mode 100644 index 00000000..3884528d --- /dev/null +++ b/doc/top/Makefile @@ -0,0 +1,8 @@ +# $Header$ + +REFER=refer +TBL=tbl +TARGET=-Tlp + +../top.doc: top.n refs.top + $(REFER) -sA+T -l4,2 -p refs.top top.n | $(TBL) > $@ diff --git a/emtest/last b/emtest/last new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/emtest/last @@ -0,0 +1 @@ +0 diff --git a/emtest/test.e b/emtest/test.e new file mode 100644 index 00000000..7f26cf5f --- /dev/null +++ b/emtest/test.e @@ -0,0 +1,28 @@ +#define WS EM_WSIZE +#define PS EM_PSIZE +#include "test.h" + mes 2,WS,PS + mes 1 + mes 4,300 +.000 + con "tst000" + exp $m_a_i_n + pro $m_a_i_n,0 + loc 123 + loc -98 +; TEST 000: empty + fil .000 + loc -98 + bne *1 + loc 123 + bne *1 + lin 0 + nop + loc 0 + ret WS +1 + lin 1 + nop + loc 1 + ret WS + end diff --git a/etc/pc_errors b/etc/pc_errors new file mode 100644 index 00000000..688e4b37 --- /dev/null +++ b/etc/pc_errors @@ -0,0 +1,289 @@ +non-standard feature used +identifier '%s' declared twice +end of file encountered +bad line directive +unsigned real: digit of fraction expected +unsigned real: digit of exponent expected +unsigned real: too many digits (>72) +unsigned integer: too many digits (>72) +unsigned integer: overflow (>32767) +string constant: must not exceed one line +string constant: at least one character expected +string constant: double quotes not allowed (see c option) +string constant: too long (>72 chars) +bad character +identifier '%s' not declared +location counter overflow: arrays too big +location counter overflow: arrays too big +arraysize too big +variable '%s' never used +variable '%s' never assigned +the files contained in '%s' are not closed automatically +constant expected +constant: only integers and reals may be signed +constant: out of bounds +simple type expected +enumerated type: element identifier expected +enumerated type: ',' or ')' expected +enumerated type: ',' expected +enumerated type: ')' expected +subrange type: type must be scalar, but not real +subrange type: '..' expected +subrange type: type of lower and upper bound incompatible +subrange type: lower bound exceeds upper bound +array type: '[' expected +conformant array: low bound identifier expected +conformant array: '..' expected +conformant array: high bound identifier expected +conformant array: ':' expected +conformant array: index type identifier expected +array type: index type not bounded +array type: index separator or ']' expected +array type: index separator expected +array type: ']' expected +array type: 'of' expected +record variant part: tag type identifier expected +record variant part: tag type identifier expected +record variant part: type must be bounded +record variant part: 'of' expected +record variant: type of case label and tag incompatible +record variant: multiple defined case label +record variant: ',' or ':' expected +record variant: ',' expected +record variant: ':' expected +record variant: '(' expected +record variant: ')' expected +record variant part: ';' or end of variant list expected +record variant part: ';' expected +record variant part: end of variant list expected +record variant part: there must be a variant for each tag value +field list: record section expected +record section: field identifier expected +record section: ',' or ':' expected +record section: ',' expected +record section: ':' expected +field list: ';' or end of record section list expected +field list: ';' expected +field list: end of record section list expected +type expected +type: simple and pointer type may not be packed +pointer type: type identifier expected +pointer type: type identifier expected +record type: 'end' expected +set type: 'of' expected +set type: too many elements in set +set type: bad subrange of integer +set of integer: the i option dictates the number of bits (default 16) +set type: base type not bounded +file type: 'of' expected +file type: files within files not allowed +var parameter: type identifier or conformant array expected +var parameter: type identifier expected +label declaration: unsigned integer expected +label declaration: label '%i' multiple declared +label declaration: ',' or ';' expected +label declaration: ',' expected +label declaration: ';' expected +const declaration: constant identifier expected +const declaration: '=' expected +const declaration: ';' expected +const declaration: constant identifier or 'type', 'var', 'procedure', 'function' or 'begin' expected +type declaration: type identifier expected +type declaration: '=' expected +type declaration: ';' expected +type declaration: type identifier or 'var', 'procedure', 'function' or 'begin' expected +var declaration: var identifier expected +var declaration: ',' or ':' expected +var declaration: ',' expected +var declaration: ':' expected +var declaration: ';' expected +var declaration: var identifier or 'procedure', 'function' or 'begin' expected +parameter list: 'var','procedure','function' or identifier expected +parameter list: parameter identifier expected +parameter list: ',' or ':' expected +parameter list: ',' expected +parameter list: ':' expected +parameter list: type identifier expected +parameter list: ';' or ')' expected +parameter list: ';' expected +proc/func declaration: proc/func identifier expected +proc/func declaration: previous declaration of '%s' was not forward +proc/func declaration: parameter list expected +parameterlist: ')' expected +func declaration: ':' expected +func declaration: result type identifier expected +func declaration: result type must be scalar, subrange or pointer +proc/func declaration: ';' expected +proc/func declaration: block or directive expected +proc/func declaration: '%s' unknown directive +proc/func declaration: '%s' again forward declared +proc/func declaration: ';' expected +indexed variable: '[' only allowed following array variables +indexed variable: index type not compatible with declaration +indexed variable: ',' or ']' expected +indexed variable: ',' expected +assignment: standard function not allowed as destination +assignment: cannot store the function result +assignment: formal parameter function not allowed as destination +assignment: function identifier may not be de-referenced +variable: '[', '.', '^' or end of variable expected +indexed variable: ']' expected +field designator: field identifier expected +field designator: '.' only allowed following record variables +field designator: no field '%s' in this record +referenced variable: '^' not allowed following zero-terminated strings +referenced variable: '^' only allowed following pointer or file variables +variable: var or field identifier expected +call: too many actual parameters supplied +call: proc/func identifier expected +call: standard proc/func may not be used as parameter +call: parameter lists of actual and formal proc/func incompatible +call: type of actual and formal value parameter not compatible +call: array parameter not conformable +call: type of actual and formal variable parameter not similar +call: packed elements not allowed as variable parameter +call: ',' or ')' expected +call: too few actual parameters supplied +read(ln): type must be integer, char or real +write(ln): type must be integer, char, real, string or boolean +write(ln): ':', ',' or ')' expected +write(ln): field width must be integer +write(ln): ':', ',' or ')' expected +write(ln): precision must be integer +write(ln): precision may only be specified for reals +read/write: too few actual parameters supplied +read/write: standard input/output not mentioned in program heading +read/write: ',' or ')' expected +read/write: type of parameter not the same as that of the file elements +read/write: parameter list expected +readln/writeln: standard input/output not mentioned in program heading +readln/writeln: only allowed on text files +new/dispose: C-type strings not allowed here +new/dispose: ',' or ')' expected +new/dispose: too many actual parameters supplied +new/dispose: type of tagfield value is incompatible with declaration +call: '(' or end of call expected +standard proc/func: parameter list expected +standard input/output not mentioned in program heading +file variable expected +pointer variable expected +pack: ',' expected +pack: ',' expected +unpack: ',' expected +unpack: ',' expected +standard proc/func: parameter type incompatible with specification +eoln/page: text file variable expected +pack/unpack: array types are incompatible +pack/unpack: only for arrays +abs: integer or real expected +sqr: integer or real expected +ord: type must be scalar or subrange, but not real +pred/succ: type must be scalar or subrange, but not real +trunc/round: real argument required +call: ')' expected +expression: left and right operand are incompatible +set: incompatible elements +set: base type must be bounded or of type integer +set: base type upper bound exceeds maximum set element number +set: element out of range +set: ']' or element list expected +set: '..', ',' or ']' expected +set: ',' or ']' expected +set: ',' expected +factor expected +factor: ')' expected +factor: type of factor must be boolean +set: ']' expected +term: multiplying operator or end of term expected +term: '*' only defined for integers, reals and sets +term: '/' only defined for integers and reals +term: 'div' only defined for integers +term: 'mod' only defined for integers +term: 'and' only defined for booleans +simple expression: only integers and reals may be signed +simple expression: adding operator or end of simple expression expected +simple expression: '+' only defined for integers, reals and sets +simple expression: '-' only defined for integers, reals and sets +simple expression: 'or' only defined for booleans +expression: relational operator or end of expression expected +expression: set expected +expression: left operand of 'in' not compatible with base type of right operand +expression: only '=' and '<>' allowed on pointers +expression: '<' and '>' not allowed on sets +expression: comparison of arrays only allowed for strings +expression: comparison of records not allowed +expression: comparison of files not allowed +assignment: ':=' expected +assignment: left and right hand side incompatible +goto statement: unsigned integer expected +goto statement: label '%i' not declared +if statement: type of expression must be boolean +if statement: 'then' expected +if statement: 'else' or end of if statement expected +case statement: type must be scalar or subrange, but not real +case statement: 'of' expected +case statement: incompatible case label +case statement: multiple defined case label +case statement: ',' or ':' expected +case statement: ',' expected +case statement: ':' expected +case statement: ';' or 'end' expected +case statement: ';' expected +case statement: 'end' expected +repeat statement: ';' or 'until' expected +repeat statement: ';' expected +repeat statement: 'until' expected +repeat statement: type of expression must be boolean +while statement: type of expression must be boolean +while statement: 'do' expected +for statement: type of bound and control variable incompatible +for statement: control variable expected +for statement: control variable must be local +for statement: type must be scalar or subrange, but not real +for statement: ':=' expected +for statement: 'to' or 'downto' expected +for statement: upper bound not assignment compatible +for statement: 'do' expected +with statement: record variable expected +with statement: ',' or 'do' expected +with statement: ',' expected +with statement: 'do' expected +assertion: type of expression must be boolean +statement expected +label '%i' not declared +label '%i' multiple defined +statement: ':' expected +unlabeled statement expected +compound statement: ';' or 'end' expected +compound statement: ';' expected +compound statement: 'end' expected +case statement: 'end' expected +body: ';' or 'end' expected +body: ';' expected +body: label '%i' declared, but never defined +program parameter '%s' not declared +function '%s' never assigned +block: declaration or body expected +block: 'const', 'type', 'var', 'procedure', 'function' or 'begin' expected +block: 'type', 'var', 'procedure', 'function' or 'begin' expected +block: 'var', 'procedure', 'function' or 'begin' expected +block: 'procedure', 'function' or 'begin' expected +block: unsatisfied forward proc/func declaration(s) +block: 'begin' expected +block: 'end' expected +program heading: 'program' expected +program heading: program identifier expected +program heading: file identifier list expected +program heading: file identifier expected +program heading: ',' or ')' expected +program heading: ',' expected +program heading: maximum number of file arguments exceeded (12) +program heading: ')' expected +program heading: ';' expected +program: '.' expected +'program' expected +module: 'const', 'type', 'var', 'procedure' or 'function' expected +module: 'type', 'var', 'procedure' or 'function' expected +module: 'var', 'procedure' or 'function' expected +module: 'procedure' or 'function' expected +garbage at end of program diff --git a/etc/pc_rt_errors b/etc/pc_rt_errors new file mode 100644 index 00000000..53060496 --- /dev/null +++ b/etc/pc_rt_errors @@ -0,0 +1,107 @@ +array bound error +range bound error +set bound error +integer overflow +real overflow +real underflow +divide by 0 +divide by 0.0 +undefined integer +real undefined +conversion error +error 11 +error 12 +error 13 +error 14 +error 15 +stack overflow +heap error +illegal instruction +odd or zero byte count +case error +memory fault +bad pointer +bad program counter +bad external address +bad monitor call +bad line number +error 27 +error 28 +error 29 +error 30 +error 31 +error 32 +error 33 +error 34 +error 35 +error 36 +error 37 +error 38 +error 39 +error 40 +error 41 +error 42 +error 43 +error 44 +error 45 +error 46 +error 47 +error 48 +error 49 +error 50 +error 51 +error 52 +error 53 +error 54 +error 55 +error 56 +error 57 +error 58 +error 59 +error 60 +error 61 +error 62 +error 63 +more args expected +error in exp +error in ln +error in sqrt +assertion failed +array bound error in pack +array bound error in unpack +only positive j in 'i mod j' +file not yet open +dispose error +error 74 +error 75 +error 76 +error 77 +error 78 +error 79 +error 80 +error 81 +error 82 +error 83 +error 84 +error 85 +error 86 +error 87 +error 88 +error 89 +error 90 +error 91 +error 92 +error 93 +error 94 +error 95 +not writable +not readable +end of file +truncated +reset error +rewrite error +close error +read error +write error +digit expected +non-ASCII char read diff --git a/examples/hilo.mod b/examples/hilo.mod index 11f494c7..701cd786 100644 --- a/examples/hilo.mod +++ b/examples/hilo.mod @@ -6,13 +6,22 @@ MODULE HiLo; FROM InOut IMPORT WriteInt, WriteLn, WriteString, ReadString, ReadInt; FROM random IMPORT Uniform; +FROM Streams IMPORT FlushStream, OutputStream, StreamResult; VAR buffer : ARRAY [0..32] OF CHAR; +PROCEDURE flush; +VAR + strus : StreamResult; +BEGIN + FlushStream(OutputStream, strus); +END flush; + PROCEDURE reads; BEGIN WriteString("> "); + flush; ReadString(buffer); END reads; @@ -31,8 +40,8 @@ BEGIN finished := FALSE; WHILE NOT finished DO - WriteLn; WriteString("> "); + flush; ReadInt(guess); IF guess = Number THEN diff --git a/first/cc.xenix.src b/first/cc.xenix.src new file mode 100644 index 00000000..b178c081 --- /dev/null +++ b/first/cc.xenix.src @@ -0,0 +1,70 @@ +trap "rm -f x$$.c" 0 1 2 3 15 +EMHOME=/usr/em +CFLAG=0 +TARGET=a.out +while : +do + case $# in + 0) break;; + esac + case $1 in + -I*|-D*|-U*) + PREP=$PREP" "$1 + ;; + -c) CFLAG=1 + ;; + -o) shift + TARGET=$1 + ;; + -F) shift + LFLAG="-F $1" + ;; + -*) FLAGS=$FLAGS" "$1 + ;; + *) ARG=$ARG" "$1 + ;; + esac + shift +done +for i in $ARG +do + case $i in + *.c) + nm=`basename $i .c` + if [ -x $EMHOME/lib/cpp ] + then + cpp=$EMHOME/lib/cpp + cppf=-P + else + cpp=/bin/cc + cppf=-E + fi + if $cpp $cppf $PREP $i > x$$.c && /bin/cc $FLAGS -c x$$.c + then + mv x$$.o $nm.o + LDARG=$LDARG" "$nm.o + else + rm -f x$$.c + exit 1 + fi + rm -f x$$.c + ;; + *.s) + if /bin/cc $FLAGS -c $i + then + LDARG=$LDARG" "`basename $i .s`.o + else exit 1 + fi + ;; + *) LDARG=$LDARG" "$i + ;; + esac +done +case $CFLAG in +1) ;; +*) if /bin/cc $FLAGS $LFLAG $LDARG -o $TARGET + then : + else exit 1 + fi + ;; +esac diff --git a/first/ckpath b/first/ckpath new file mode 100644 index 00000000..57eb4723 --- /dev/null +++ b/first/ckpath @@ -0,0 +1,67 @@ +rm -f ../bin/x_tpath x_tpath +echo 'Checking out your $PATH; . and $ACK/bin should be in front ...' +echo "echo $$" >../bin/x_tpath +rm -f x_tpath +chmod +x ../bin/x_tpath +case x`(x_tpath) 2>/dev/null` +in +x$$) + STAT=0 ;; +x) + (cd ../bin ; echo Sorry, `pwd` is not in your shell PATH" ($PATH)") + STAT=1 ;; +*) + echo "Sorry, there is something wrong with your PATH ($PATH)" ;; +esac +echo "echo t_$$" > X_Y_Z_ +chmod +x X_Y_Z_ +case x`X_Y_Z_` +in +xt_$$) + ;; +x) + (cd ../bin ; echo Sorry, . is not in your shell PATH" ($PATH)") + STAT=2 ;; +*) + echo "Sorry, there is something wrong with your PATH ($PATH)" ;; +esac +rm -f X_Y_Z_ +case $STAT +in +2) + ;; +*) + hash -r ;; +esac +echo "echo l_$$" >x_tpath +chmod +x x_tpath +case x`(x_tpath) 2>/dev/null` +in +xl_$$) + ;; +x) + (cd ../bin ; echo Sorry, . is not in your shell PATH" ($PATH)") + STAT=2 ;; +x$$) + echo Sorry, . is not in your PATH" ($PATH)" or after the ACK bin directory + STAT=3 ;; +*) + echo "Sorry, there is something wrong with your PATH ($PATH)" + STAT=4 ;; +esac +rm -f ../bin/x_tpath x_tpath +echo "echo 93" > ../bin/cat +chmod +x ../bin/cat +hash -r +case x`cat < /dev/null 2>/dev/null` +in +x93) + rm -f ../bin/cat + ;; +*) + rm -f ../bin/cat + (cd ../bin ; echo Sorry, `pwd` comes too late in your PATH" ($PATH)" ) + STAT=13 + ;; +esac +exit $STAT diff --git a/first/did_first b/first/did_first new file mode 100755 index 00000000..f0d920a9 --- /dev/null +++ b/first/did_first @@ -0,0 +1,7 @@ +if (ack_sys ) >/dev/null 2>&1 +then + exit 0 +else + echo "You need to run 'first' first" + exit 1 +fi diff --git a/first/fixlexlib b/first/fixlexlib new file mode 100755 index 00000000..f7c53825 --- /dev/null +++ b/first/fixlexlib @@ -0,0 +1,75 @@ +FL=succes +TRIES= +case X$# in +X0) + if (.Xlex) > /dev/null 2>&1 + then + TRY=`.Xlex` + else TRY=-lln + fi + echo "trying to find your lex library ..." + cat > x.l <<'EOF' +%% +[A-Z] putchar(yytext[0]+'a'-'A'); +EOF + if lex x.l > /dev/null 2>&1 && cc -c lex.yy.c > /dev/null 2>&1 + then : + else echo "Sorry, your lex does not seem to work" + exit 2 + fi + cat > trylib <<'EOF' +if cc lex.yy.o $1 > /dev/null 2>&1 +then + rm -f lex.yy.* a.out + exit 0 +else + exit 1 +fi +EOF + if sh trylib $TRY + then + LEX=$TRY + else + exec $0 -ll $TRY + fi + ;; +*) if sh trylib $1 + then + LEX=$1 + else + TRIES="$2 and $1" + FL=fail + fi + ;; +esac +case X$FL in +Xfail) echo 'What option do I have to give to cc to get the LEX library?' + echo "I tried " $TRIES "but these don't seem to work." + echo -n 'LEX library option: ' + if read ANSWER + then : + else echo "Sorry, got EOF while reading your answer" + exit 9 + fi + exec $0 $ANSWER "$TRIES" + ;; +Xsucces) + for i in ../util/opt ../util/cgg ../util/ncgg ../lang/occam/comp ../modules/src/em_opt ../util/ceg/as_parser + do + ( cd $i + cp Makefile makefile + ed - makefile << EOF +/^LEXLIB/c +LEXLIB = $LEX +. +w +q +EOF + ) + done + ;; +esac +rm -f x.l trylib lex.yy.* +echo echo "$LEX" > .Xlex +chmod +x .Xlex +echo "apparently, \"cc ... $LEX\" works" diff --git a/first/hash b/first/hash new file mode 100755 index 00000000..e69de29b diff --git a/first/myecho.c b/first/myecho.c new file mode 100644 index 00000000..d74c09a3 --- /dev/null +++ b/first/myecho.c @@ -0,0 +1,21 @@ +#include + +main(argc, argv) + int argc; + char *argv[]; +{ + int nflag = 0; + + if(argc > 1 && ! strncmp(argv[1], "-n", 2)) { + nflag++; + argc--; + argv++; + } + while (--argc > 0) { + fputs(argv[1], stdout); + argv++; + if (argc > 1) putchar(' '); + } + if (!nflag) putchar('\n'); + exit(0); +} diff --git a/h/pc_size.h b/h/pc_size.h new file mode 100644 index 00000000..b0eb5f74 --- /dev/null +++ b/h/pc_size.h @@ -0,0 +1,26 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ + +/*fundamental */ +#define sz_byte 1 +#define sz_bool 1 +#define sz_char 1 + +/* target machine characteristics */ +/* variable (see pc.c) */ +#define sz_addr sizes[0] +#define sz_real sizes[1] +#define sz_head sizes[2] +#define sz_buff sizes[3] +#define sz_mset sizes[4] +#define sz_iset sizes[5] +#define sz_word sizes[6] +#define sz_int sizes[7] +#define sz_long sizes[8] + +#define sz_last 8 + +#define sz_proc 2*sz_addr diff --git a/include/_tail_cc/termio.h b/include/_tail_cc/termio.h new file mode 100644 index 00000000..c8224a76 --- /dev/null +++ b/include/_tail_cc/termio.h @@ -0,0 +1,28 @@ +#ifdef __CHANNEL__ +#define NCC 8 + +#define VMIN 4 +#define VTIME 5 + +#define ICRNL 0000400 + +#define ONLCR 0000004 + +#define ICANON 0000002 +#define ECHO 0000010 + +struct termio { + unsigned short c_iflag; + unsigned short c_oflag; + unsigned short c_cflag; + unsigned short c_lflag; + char c_line; + unsigned char c_cc[NCC]; +}; + +#define TIOC ('T'<<8) +#define TCGETA (TIOC|1) +#define TCSETA (TIOC|2) +#else +#include "/usr/include/termio.h" +#endif diff --git a/lang/basic/src/Makefile b/lang/basic/src/Makefile new file mode 100644 index 00000000..f1d61a49 --- /dev/null +++ b/lang/basic/src/Makefile @@ -0,0 +1,64 @@ +# $Header$ + +EMHOME=../../.. +h=$(EMHOME)/h +m=$(EMHOME)/modules/h +LIBDIR= $(EMHOME)/modules/lib +LIBDIR2= $(EMHOME)/lib +CFLAGS = -I$h -I$m -O + +FILES= bem.o symbols.o initialize.o compile.o \ + parsepar.o gencode.o util.o graph.o \ + eval.o func.o basic.o Lpars.o + +CSRCFILES= bem.c symbols.c initialize.c compile.c \ + parsepar.c gencode.c util.c graph.c \ + eval.c func.c +CGENFILES= basic.c Lpars.c +CFILES=$(CSRCFILES) $(CGENFILES) + +LIBFILES= $(LIBDIR)/libem_mes.a $(LIBDIR)/libemk.a \ + $(LIBDIR2)/em_data.a $(LIBDIR)/libprint.a \ + $(LIBDIR)/liballoc.a \ + $(LIBDIR)/libsystem.a $(LIBDIR)/libstring.a + +LINTLIBFILES= $(LIBDIR)/llib-lem_mes.ln $(LIBDIR)/llib-lemk.ln \ + $(LIBDIR)/llib-lprint.ln \ + $(LIBDIR)/llib-lalloc.ln \ + $(LIBDIR)/llib-lsystem.ln $(LIBDIR)/llib-lstring.ln + +all: dummy bem + +dummy: basic.g + LLgen basic.g + touch dummy + +install: all + cp bem $(EMHOME)/lib/em_bem + +cmp: all + cmp bem $(EMHOME)/lib/em_bem + +pr: + @pr Makefile maketokentab bem.h symbols.h graph.h basic.g basic.lex $(CSRCFILES) + +opr: + make pr | opr + +bem: $(FILES) $(LIBFILES) + $(CC) -o bem $(FILES) $(LIBFILES) + +basic.o : basic.c basic.lex Lpars.h llmess.c tokentab.h + $(CC) $(CFLAGS) -c basic.c + +$(FILES): bem.h symbols.h graph.h + +tokentab.h: Lpars.h + maketokentab + +lint: dummy $(CFILES) tokentab.h + lint -b $(CFLAGS) $(CFILES) $(LINTLIBFILES) + +clean: + rm -f *.o + rm -f basic.c Lpars.h Lpars.c dummy tokentab.h bem diff --git a/lang/cem/cemcom.ansi/LintPars b/lang/cem/cemcom.ansi/LintPars new file mode 100644 index 00000000..46f66e2a --- /dev/null +++ b/lang/cem/cemcom.ansi/LintPars @@ -0,0 +1,143 @@ +!File: lint.h +#define LINT 1 /* if defined, 'lint' is produced */ +#define ANSI 1 /* tell l_* files it's ANSI */ + + +!File: pathlength.h +#define PATHLENGTH 1024 /* max. length of path to file */ + + +!File: errout.h +#define ERROUT STDERR /* file pointer for writing messages */ +#define ERR_SHADOW 0 /* a syntax error overshadows error messages + until ERR_SHADOW symbols have been + accepted without syntax error */ + + +!File: idfsize.h +#define IDFSIZE 64 /* maximum significant length of an identifier */ + + +!File: numsize.h +#define NUMSIZE 256 /* maximum length of a numeric constant */ + + +!File: nparams.h +#define NPARAMS 32 /* maximum number of parameters */ +#define STDC_NPARAMS 31 /* ANSI limit on number of parameters */ + + +!File: ifdepth.h +#define IFDEPTH 256 /* maximum number of nested if-constructions */ + + +!File: density.h +#define DENSITY 2 /* see switch.[ch] for an explanation */ + + +!File: macbuf.h +#define LAPBUF 128 /* initial size of macro replacement buffer */ +#define ARGBUF 128 /* initial size of macro parameter buffer(s) */ + + +!File: strsize.h +#define ISTRSIZE 32 /* minimum number of bytes allocated for + storing a string */ +#define RSTRSIZE 16 /* step size in enlarging the memory for + the storage of a string */ + + +!File: trgt_sizes.h +#define MAXSIZE 8 /* the maximum of the SZ_* constants */ + +/* target machine sizes */ +#define SZ_CHAR 1 +#define SZ_SHORT 2 +#define SZ_WORD 4 +#define SZ_INT 4 +#define SZ_LONG 4 +#define SZ_FLOAT 4 +#define SZ_DOUBLE 8 +#define SZ_POINTER 4 +#define SZ_LNGDBL 8 /* for now */ + +/* target machine alignment requirements */ +#define AL_CHAR 1 +#define AL_SHORT SZ_SHORT +#define AL_WORD SZ_WORD +#define AL_INT SZ_WORD +#define AL_LONG SZ_WORD +#define AL_FLOAT SZ_WORD +#define AL_DOUBLE SZ_WORD +#define AL_LNGDBL SZ_WORD +#define AL_POINTER SZ_WORD +#define AL_STRUCT 1 +#define AL_UNION 1 + + +!File: botch_free.h +#undef BOTCH_FREE 1 /* when defined, botch freed memory, as a check */ + + +!File: dataflow.h +#undef DATAFLOW 1 /* produce some compile-time xref */ + + +!File: debug.h +#undef DEBUG 1 /* perform various self-tests */ + + +!File: use_tmp.h +#undef PREPEND_SCOPES 1 /* collect exa, exp, ina and inp commands + and if USE_TMP is defined let them + precede the rest of the generated + compact code */ +#undef USE_TMP 1 /* use C_insertpart, C_endpart mechanism + to generate EM-code in the order needed + for the code-generators. If not defined, + the old-style peephole optimizer is + needed. */ + + +!File: parbufsize.h +#define PARBUFSIZE 1024 + + +!File: textsize.h +#define ITEXTSIZE 32 /* 1st piece of memory for repl. text */ + + +!File: inputtype.h +#define INP_READ_IN_ONE 1 /* read input file in one */ + + +!File: nopp.h +#undef NOPP 1 /* if NOT defined, use built-int preprocessor */ + + +!File: nobitfield.h +#undef NOBITFIELD 1 /* if NOT defined, implement bitfields */ + + +!File: spec_arith.h +/* describes internal compiler arithmetics */ +#undef SPECIAL_ARITHMETICS /* something different from native long */ +#undef UNSIGNED_ARITH unsigned arith + + +!File: static.h +#define GSTATIC /* for large global "static" arrays */ + + +!File: nocross.h +#undef NOCROSS 1 /* if NOT defined, cross compiler */ + + +!File: regcount.h +#undef REGCOUNT 1 /* count occurrences for register messages */ + + +!File: dbsymtab.h +#undef DBSYMTAB 1 /* ability to produce symbol table for debugger */ + + diff --git a/lang/cem/cemcom.ansi/Makefile.erik b/lang/cem/cemcom.ansi/Makefile.erik new file mode 100644 index 00000000..195e07fc --- /dev/null +++ b/lang/cem/cemcom.ansi/Makefile.erik @@ -0,0 +1,718 @@ +# $Header$ +# M A K E F I L E F O R A C K C - C O M P I L E R + +# Machine and environ dependent definitions +EMHOME = /usr/em# # ACK tree on this machine +DESTINATION = /user1/$$USER/bin# # where to put the stuff +MKDEP = $(EMHOME)/bin/mkdep# # dependency generator +MAP = +#MAP = -DInsertFile=ins_file -DInsertText=ins_text# bug in m68k2 back end +SIM = /user1/dick/bin/sim# # Dicks sim program +LINT = /usr/new/lint + +# Libraries and EM interface definitions +SYSLIB = $(EMHOME)/modules/lib/libsystem.a +EMKLIB = $(EMHOME)/modules/lib/libemk.a +EMELIB = $(EMHOME)/modules/lib/libeme.a $(EMHOME)/lib/em_data.a +STRLIB = $(EMHOME)/modules/lib/libstring.a +PRTLIB = $(EMHOME)/modules/lib/libprint.a +EMMESLIB = $(EMHOME)/modules/lib/libem_mes.a +INPLIB = $(EMHOME)/modules/lib/libinput.a +ALLOCLIB = $(EMHOME)/modules/lib/liballoc.a +MALLOC = $(EMHOME)/modules/lib/malloc.o +#CH3LIB = $(EMHOME)/modules/lib/libch3.a +CH3LIB = +LIBS = $(INPLIB) $(CH3LIB) $(EMMESLIB) $(EMKLIB) \ + $(PRTLIB) $(STRLIB) $(ALLOCLIB) $(MALLOC) $(SYSLIB) +ELIBS = $(INPLIB) $(CH3LIB) $(EMMESLIB) $(EMELIB) \ + $(PRTLIB) $(STRLIB) $(ALLOCLIB) $(MALLOC) $(SYSLIB) +LIB_INCLUDES = -I$(EMHOME)/modules/h -I$(EMHOME)/modules/pkg +EM_INCLUDES = -I$(EMHOME)/h +SYSLLIB = $(EMHOME)/modules/lib/llib-lsys.ln +EMKLLIB = $(EMHOME)/modules/lib/llib-lemk.ln +EMELLIB = $(EMHOME)/modules/lib/llib-leme.ln +STRLLIB = $(EMHOME)/modules/lib/llib-lstr.ln +PRTLLIB = $(EMHOME)/modules/lib/llib-lprint.ln +EMMESLLIB = $(EMHOME)/modules/lib/llib-lmes.ln +INPLLIB = $(EMHOME)/modules/lib/llib-linput.ln +CH3LLIB = $(EMHOME)/modules/lib/llib-lch3.ln +ALLOCLLIB = $(EMHOME)/modules/lib/llib-alloc.ln +LINTLIBS = +#LINTLIBS = $(CH3LLIB) $(INPLLIB) $(EMMESLLIB) $(EMKLLIB) \ +# $(PRTLLIB) $(STRLLIB) $(SYSLLIB) $(ALLOCLLIB) + +# Where to install the compiler and its driver +CEMCOM = $(DESTINATION)/cemcom +DRIVER = $(DESTINATION)/cem + +# What C compiler to use and how +# CC = $(ACK) -.c +# CC = CC +# CC = /bin/cc +COPTIONS = + +# What parser generator to use and how +GEN = $(EMHOME)/bin/LLgen +GENOPTIONS = -vv + +# Special #defines during compilation +CDEFS = $(MAP) $(EM_INCLUDES) $(LIB_INCLUDES) +CFLAGS = $(CDEFS) $(COPTIONS) -O# we cannot pass the COPTIONS to lint! + +# Grammar files and their objects +LSRC = tokenfile.g declar.g statement.g expression.g program.g ival.g +GLCSRC = tokenfile.c declar.c statement.c expression.c program.c Lpars.c ival.c +LOBJ = tokenfile.o declar.o statement.o expression.o program.o Lpars.o ival.o + +CSRC = main.c idf.c declarator.c decspecs.c struct.c \ + expr.c ch7.c ch7bin.c cstoper.c arith.c \ + asm.c code.c dumpidf.c error.c field.c\ + tokenname.c LLlex.c LLmessage.c \ + input.c domacro.c replace.c init.c options.c \ + scan.c skip.c stack.c type.c ch7mon.c label.c eval.c \ + switch.c conversion.c util.c \ + blocks.c dataflow.c Version.c +# Objects of hand-written C files +COBJ = main.o idf.o declarator.o decspecs.o struct.o \ + expr.o ch7.o ch7bin.o cstoper.o arith.o \ + asm.o code.o dumpidf.o error.o field.o\ + tokenname.o LLlex.o LLmessage.o \ + input.o domacro.o replace.o init.o options.o \ + scan.o skip.o stack.o type.o ch7mon.o label.o eval.o \ + switch.o conversion.o util.o \ + blocks.o dataflow.o Version.o + +# Objects of other generated C files +GCSRC = char.c symbol2str.c next.c +GOBJ = char.o symbol2str.o next.o + +# generated source files +GSRC = char.c symbol2str.c next.c \ + code.h declar.h decspecs.h def.h expr.h field.h estack.h \ + idf.h macro.h stack.h stmt.h struct.h switch.h type.h util.h + +# .h files generated by `make hfiles'; PLEASE KEEP THIS UP-TO-DATE! +GHSRC = botch_free.h dataflow.h debug.h density.h errout.h \ + idfsize.h ifdepth.h inputtype.h inumlength.h lapbuf.h \ + nobitfield.h nofloat.h nopp.h noRoption.h nocross.h \ + nparams.h numsize.h parbufsize.h pathlength.h \ + strsize.h target_sizes.h textsize.h use_tmp.h spec_arith.h static.h \ + reg_count.h + +# Other generated files, for 'make clean' only +GENERATED = tokenfile.g Lpars.h LLfiles LL.output lint.out \ + print Xref lxref hfiles cfiles $(GLCSRC) + +# include files containing ALLOCDEF specifications +NEXTFILES = code.str declar.str decspecs.str def.str expr.str field.str \ + estack.str util.str \ + idf.str macro.str stack.str stmt.str struct.str switch.str type.str + +.SUFFIXES: .str .h +.str.h: + ./make.allocd <$*.str >$*.h + +all: cc + +cc: + make "EMHOME="$(EMHOME) "CC=$(CC)" hfiles + make "EMHOME="$(EMHOME) "CC=$(CC)" LLfiles + make "EMHOME="$(EMHOME) "CC=$(CC)" main + +cem: cem.c + $(CC) -O cem.c $(SYSLIB) -o cem + +lint.cem: cem.c + $(LINT) -bx cem.c + +hfiles: ./make.hfiles Parameters + ./make.hfiles Parameters + @touch hfiles + +LLfiles: $(LSRC) + $(GEN) $(GENOPTIONS) $(LSRC) + @touch LLfiles + +tokenfile.g: tokenname.c make.tokfile + tokenfile.g + +symbol2str.c: tokenname.c make.tokcase + symbol2str.c + +char.c: char.tab + $(EMHOME)/bin/tabgen -fchar.tab >char.c + +next.c: make.next $(NEXTFILES) + ./make.next $(NEXTFILES) >next.c + +code.h: make.allocd +declar.h: make.allocd +decspecs.h: make.allocd +def.h: make.allocd +estack.h: make.allocd +expr.h: make.allocd +field.h: make.allocd +idf.h: make.allocd +macro.h: make.allocd +stack.h: make.allocd +stmt.h: make.allocd +struct.h: make.allocd +switch.h: make.allocd +type.h: make.allocd +util.h: make.allocd + +# Objects needed for 'main' +OBJ = $(COBJ) $(LOBJ) $(GOBJ) +SRC = $(CSRC) $(LCSRC) $(GCSRC) + +main: $(OBJ) Makefile.erik + $(CC) $(COPTIONS) $(LFLAGS) $(OBJ) $(LIBS) -o main + size main + +emain: $(OBJ) Makefile.erik + $(CC) $(COPTIONS) $(LFLAGS) $(OBJ) $(ELIBS) -o emain + size emain + +cfiles: hfiles LLfiles $(GSRC) + @touch cfiles + +install: main cem + cp main $(CEMCOM) + cp cem $(DRIVER) + +print: files + pr `cat files` > print + +tags: cfiles + ctags $(SRC) + +shar: files + shar `cat files` + +listcfiles: + @echo $(SRC) + +listobjects: + @echo $(OBJ) + +depend: cfiles + sed '/^#AUTOAUTO/,$$d' Makefile.erik >Makefile.erik.new + echo '#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO' >>Makefile.erik.new + $(MKDEP) $(SRC) | sed 's/\.c:/.o:/' >>Makefile.erik.new + mv Makefile.erik Makefile.erik.old + mv Makefile.erik.new Makefile.erik + +xref: + ctags -x `grep "\.[ch]" files`|sed "s/).*/)/">Xref + +lxref: + lxref $(OBJ) -lc >lxref + +lint: lint.main lint.cem + +lint.main: cfiles + $(LINT) -bx $(CDEFS) $(SRC) $(LINTLIBS) >lint.out + +cchk: + cchk $(SRC) + +clean: + rm -f $(LCSRC) $(OBJ) $(GENERATED) $(GSRC) $(GHSRC) + +sim: cfiles + $(SIM) $(SIMFLAGS) $(CSRC) $(GSRC) $(LSRC) + +#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO +main.o: LLlex.h +main.o: Lpars.h +main.o: align.h +main.o: arith.h +main.o: debug.h +main.o: declar.h +main.o: file_info.h +main.o: idf.h +main.o: input.h +main.o: inputtype.h +main.o: level.h +main.o: noRoption.h +main.o: nobitfield.h +main.o: nocross.h +main.o: nofloat.h +main.o: nopp.h +main.o: sizes.h +main.o: spec_arith.h +main.o: specials.h +main.o: target_sizes.h +main.o: tokenname.h +main.o: type.h +main.o: use_tmp.h +idf.o: LLlex.h +idf.o: Lpars.h +idf.o: align.h +idf.o: arith.h +idf.o: assert.h +idf.o: botch_free.h +idf.o: debug.h +idf.o: declar.h +idf.o: decspecs.h +idf.o: def.h +idf.o: file_info.h +idf.o: idf.h +idf.o: idfsize.h +idf.o: label.h +idf.o: level.h +idf.o: noRoption.h +idf.o: nobitfield.h +idf.o: nocross.h +idf.o: nofloat.h +idf.o: nopp.h +idf.o: sizes.h +idf.o: spec_arith.h +idf.o: specials.h +idf.o: stack.h +idf.o: struct.h +idf.o: target_sizes.h +idf.o: type.h +declarator.o: Lpars.h +declarator.o: arith.h +declarator.o: botch_free.h +declarator.o: declar.h +declarator.o: expr.h +declarator.o: idf.h +declarator.o: label.h +declarator.o: nobitfield.h +declarator.o: nocross.h +declarator.o: nofloat.h +declarator.o: nopp.h +declarator.o: sizes.h +declarator.o: spec_arith.h +declarator.o: target_sizes.h +declarator.o: type.h +decspecs.o: Lpars.h +decspecs.o: arith.h +decspecs.o: decspecs.h +decspecs.o: def.h +decspecs.o: level.h +decspecs.o: noRoption.h +decspecs.o: nobitfield.h +decspecs.o: nofloat.h +decspecs.o: spec_arith.h +decspecs.o: type.h +struct.o: LLlex.h +struct.o: Lpars.h +struct.o: align.h +struct.o: arith.h +struct.o: assert.h +struct.o: botch_free.h +struct.o: debug.h +struct.o: def.h +struct.o: field.h +struct.o: file_info.h +struct.o: idf.h +struct.o: level.h +struct.o: noRoption.h +struct.o: nobitfield.h +struct.o: nocross.h +struct.o: nofloat.h +struct.o: nopp.h +struct.o: sizes.h +struct.o: spec_arith.h +struct.o: stack.h +struct.o: struct.h +struct.o: target_sizes.h +struct.o: type.h +expr.o: LLlex.h +expr.o: Lpars.h +expr.o: arith.h +expr.o: botch_free.h +expr.o: declar.h +expr.o: decspecs.h +expr.o: def.h +expr.o: expr.h +expr.o: file_info.h +expr.o: idf.h +expr.o: label.h +expr.o: level.h +expr.o: noRoption.h +expr.o: nobitfield.h +expr.o: nocross.h +expr.o: nofloat.h +expr.o: nopp.h +expr.o: sizes.h +expr.o: spec_arith.h +expr.o: target_sizes.h +expr.o: type.h +ch7.o: Lpars.h +ch7.o: arith.h +ch7.o: assert.h +ch7.o: debug.h +ch7.o: def.h +ch7.o: expr.h +ch7.o: idf.h +ch7.o: label.h +ch7.o: nobitfield.h +ch7.o: nofloat.h +ch7.o: nopp.h +ch7.o: spec_arith.h +ch7.o: struct.h +ch7.o: type.h +ch7bin.o: Lpars.h +ch7bin.o: arith.h +ch7bin.o: botch_free.h +ch7bin.o: expr.h +ch7bin.o: idf.h +ch7bin.o: label.h +ch7bin.o: noRoption.h +ch7bin.o: nobitfield.h +ch7bin.o: nofloat.h +ch7bin.o: nopp.h +ch7bin.o: spec_arith.h +ch7bin.o: struct.h +ch7bin.o: type.h +cstoper.o: Lpars.h +cstoper.o: arith.h +cstoper.o: assert.h +cstoper.o: debug.h +cstoper.o: expr.h +cstoper.o: idf.h +cstoper.o: label.h +cstoper.o: nobitfield.h +cstoper.o: nocross.h +cstoper.o: nofloat.h +cstoper.o: nopp.h +cstoper.o: sizes.h +cstoper.o: spec_arith.h +cstoper.o: target_sizes.h +cstoper.o: type.h +arith.o: Lpars.h +arith.o: arith.h +arith.o: botch_free.h +arith.o: expr.h +arith.o: field.h +arith.o: idf.h +arith.o: label.h +arith.o: mes.h +arith.o: noRoption.h +arith.o: nobitfield.h +arith.o: nofloat.h +arith.o: nopp.h +arith.o: spec_arith.h +arith.o: type.h +code.o: Lpars.h +code.o: arith.h +code.o: assert.h +code.o: atw.h +code.o: botch_free.h +code.o: code.h +code.o: dataflow.h +code.o: debug.h +code.o: declar.h +code.o: decspecs.h +code.o: def.h +code.o: expr.h +code.o: file_info.h +code.o: idf.h +code.o: label.h +code.o: level.h +code.o: noRoption.h +code.o: nobitfield.h +code.o: nocross.h +code.o: nofloat.h +code.o: nopp.h +code.o: sizes.h +code.o: spec_arith.h +code.o: specials.h +code.o: stack.h +code.o: stmt.h +code.o: target_sizes.h +code.o: type.h +code.o: use_tmp.h +dumpidf.o: Lpars.h +dumpidf.o: arith.h +dumpidf.o: debug.h +dumpidf.o: def.h +dumpidf.o: expr.h +dumpidf.o: field.h +dumpidf.o: idf.h +dumpidf.o: label.h +dumpidf.o: nobitfield.h +dumpidf.o: nofloat.h +dumpidf.o: nopp.h +dumpidf.o: spec_arith.h +dumpidf.o: stack.h +dumpidf.o: static.h +dumpidf.o: struct.h +dumpidf.o: type.h +error.o: LLlex.h +error.o: arith.h +error.o: debug.h +error.o: errout.h +error.o: expr.h +error.o: file_info.h +error.o: label.h +error.o: nofloat.h +error.o: nopp.h +error.o: spec_arith.h +error.o: tokenname.h +field.o: Lpars.h +field.o: align.h +field.o: arith.h +field.o: assert.h +field.o: code.h +field.o: debug.h +field.o: expr.h +field.o: field.h +field.o: idf.h +field.o: label.h +field.o: nobitfield.h +field.o: nocross.h +field.o: nofloat.h +field.o: nopp.h +field.o: sizes.h +field.o: spec_arith.h +field.o: target_sizes.h +field.o: type.h +tokenname.o: LLlex.h +tokenname.o: Lpars.h +tokenname.o: arith.h +tokenname.o: file_info.h +tokenname.o: idf.h +tokenname.o: nofloat.h +tokenname.o: nopp.h +tokenname.o: spec_arith.h +tokenname.o: tokenname.h +LLlex.o: LLlex.h +LLlex.o: Lpars.h +LLlex.o: arith.h +LLlex.o: assert.h +LLlex.o: class.h +LLlex.o: debug.h +LLlex.o: def.h +LLlex.o: file_info.h +LLlex.o: idf.h +LLlex.o: idfsize.h +LLlex.o: input.h +LLlex.o: nocross.h +LLlex.o: nofloat.h +LLlex.o: nopp.h +LLlex.o: numsize.h +LLlex.o: sizes.h +LLlex.o: spec_arith.h +LLlex.o: strsize.h +LLlex.o: target_sizes.h +LLmessage.o: LLlex.h +LLmessage.o: Lpars.h +LLmessage.o: arith.h +LLmessage.o: file_info.h +LLmessage.o: idf.h +LLmessage.o: nofloat.h +LLmessage.o: nopp.h +LLmessage.o: spec_arith.h +input.o: file_info.h +input.o: input.h +input.o: inputtype.h +input.o: nopp.h +domacro.o: LLlex.h +domacro.o: Lpars.h +domacro.o: arith.h +domacro.o: assert.h +domacro.o: botch_free.h +domacro.o: class.h +domacro.o: debug.h +domacro.o: file_info.h +domacro.o: idf.h +domacro.o: idfsize.h +domacro.o: ifdepth.h +domacro.o: input.h +domacro.o: interface.h +domacro.o: macro.h +domacro.o: nofloat.h +domacro.o: nopp.h +domacro.o: nparams.h +domacro.o: parbufsize.h +domacro.o: spec_arith.h +domacro.o: textsize.h +replace.o: LLlex.h +replace.o: arith.h +replace.o: assert.h +replace.o: class.h +replace.o: debug.h +replace.o: file_info.h +replace.o: idf.h +replace.o: input.h +replace.o: interface.h +replace.o: macro.h +replace.o: nofloat.h +replace.o: nopp.h +replace.o: pathlength.h +replace.o: spec_arith.h +replace.o: static.h +replace.o: strsize.h +init.o: class.h +init.o: idf.h +init.o: interface.h +init.o: macro.h +init.o: nopp.h +options.o: align.h +options.o: arith.h +options.o: botch_free.h +options.o: class.h +options.o: dataflow.h +options.o: idf.h +options.o: idfsize.h +options.o: macro.h +options.o: noRoption.h +options.o: nobitfield.h +options.o: nocross.h +options.o: nofloat.h +options.o: nopp.h +options.o: sizes.h +options.o: spec_arith.h +options.o: target_sizes.h +options.o: use_tmp.h +scan.o: class.h +scan.o: idf.h +scan.o: input.h +scan.o: interface.h +scan.o: lapbuf.h +scan.o: macro.h +scan.o: nopp.h +scan.o: nparams.h +skip.o: LLlex.h +skip.o: arith.h +skip.o: class.h +skip.o: file_info.h +skip.o: input.h +skip.o: interface.h +skip.o: nofloat.h +skip.o: nopp.h +skip.o: spec_arith.h +stack.o: Lpars.h +stack.o: arith.h +stack.o: botch_free.h +stack.o: debug.h +stack.o: def.h +stack.o: idf.h +stack.o: level.h +stack.o: mes.h +stack.o: noRoption.h +stack.o: nobitfield.h +stack.o: nofloat.h +stack.o: nopp.h +stack.o: spec_arith.h +stack.o: stack.h +stack.o: struct.h +stack.o: type.h +type.o: Lpars.h +type.o: align.h +type.o: arith.h +type.o: botch_free.h +type.o: def.h +type.o: idf.h +type.o: nobitfield.h +type.o: nocross.h +type.o: nofloat.h +type.o: nopp.h +type.o: sizes.h +type.o: spec_arith.h +type.o: target_sizes.h +type.o: type.h +ch7mon.o: Lpars.h +ch7mon.o: arith.h +ch7mon.o: botch_free.h +ch7mon.o: def.h +ch7mon.o: expr.h +ch7mon.o: idf.h +ch7mon.o: label.h +ch7mon.o: nobitfield.h +ch7mon.o: nofloat.h +ch7mon.o: nopp.h +ch7mon.o: spec_arith.h +ch7mon.o: type.h +label.o: Lpars.h +label.o: arith.h +label.o: def.h +label.o: idf.h +label.o: label.h +label.o: level.h +label.o: noRoption.h +label.o: nobitfield.h +label.o: nofloat.h +label.o: nopp.h +label.o: spec_arith.h +label.o: type.h +eval.o: Lpars.h +eval.o: align.h +eval.o: arith.h +eval.o: assert.h +eval.o: atw.h +eval.o: code.h +eval.o: dataflow.h +eval.o: debug.h +eval.o: def.h +eval.o: expr.h +eval.o: idf.h +eval.o: label.h +eval.o: level.h +eval.o: mes.h +eval.o: nobitfield.h +eval.o: nocross.h +eval.o: nofloat.h +eval.o: nopp.h +eval.o: sizes.h +eval.o: spec_arith.h +eval.o: specials.h +eval.o: stack.h +eval.o: target_sizes.h +eval.o: type.h +switch.o: Lpars.h +switch.o: arith.h +switch.o: assert.h +switch.o: botch_free.h +switch.o: code.h +switch.o: debug.h +switch.o: density.h +switch.o: expr.h +switch.o: idf.h +switch.o: label.h +switch.o: noRoption.h +switch.o: nobitfield.h +switch.o: nofloat.h +switch.o: nopp.h +switch.o: spec_arith.h +switch.o: switch.h +switch.o: type.h +conversion.o: Lpars.h +conversion.o: arith.h +conversion.o: nobitfield.h +conversion.o: nocross.h +conversion.o: nofloat.h +conversion.o: sizes.h +conversion.o: spec_arith.h +conversion.o: target_sizes.h +conversion.o: type.h +util.o: Lpars.h +util.o: align.h +util.o: def.h +util.o: nocross.h +util.o: nofloat.h +util.o: regcount.h +util.o: sizes.h +util.o: stack.h +util.o: target_sizes.h +util.o: use_tmp.h +util.o: util.h +blocks.o: Lpars.h +blocks.o: align.h +blocks.o: arith.h +blocks.o: atw.h +blocks.o: label.h +blocks.o: nocross.h +blocks.o: nofloat.h +blocks.o: sizes.h +blocks.o: spec_arith.h +blocks.o: stack.h +blocks.o: target_sizes.h +dataflow.o: dataflow.h +char.o: class.h +symbol2str.o: Lpars.h diff --git a/lang/cem/cemcom.ansi/Resolve b/lang/cem/cemcom.ansi/Resolve new file mode 100755 index 00000000..acb50f49 --- /dev/null +++ b/lang/cem/cemcom.ansi/Resolve @@ -0,0 +1,67 @@ +: create a directory Xsrc with name clashes resolved +: and run make in that directory +: '$Header$' + +case $# in +1) + ;; +*) echo "$0: one argument expected" 1>&2 + exit 1 + ;; +esac +PW=`pwd` +options= +case $1 in +main|emain|lnt) + target=$PW/$1 + ;; +omain) + target=$PW/$1 + options=-DPEEPHOLE + ;; +cemain) + target=$PW/$1 + options=-DCODE_EXPANDER + ;; +Xlint) + target=$1 + ;; +*) echo "$0: $1: Illegal argument" 1>&2 + exit 1 + ;; +esac +if test -d ../Xsrc +then + : +else mkdir ../Xsrc +fi +make EMHOME=$EMHOME longnames +: remove code generating routines from the clashes list as they are defines. +: code generating routine names start with C_ +sed '/^C_/d' < longnames > tmp$$ +cclash -c -l7 tmp$$ > ../Xsrc/Xclashes +rm -f tmp$$ +cd ../Xsrc +if cmp -s Xclashes clashes +then + : +else + mv Xclashes clashes +fi +rm -f Makefile +for i in `cat $PW/Cfiles` +do + cat >> Makefile < $i +EOF +done +make EMHOME=$EMHOME `cat $PW/Cfiles` +rm -f Makefile +ed - $PW/Makefile <<'EOF' +/^#EXCLEXCL/,/^#INCLINCL/d +w Makefile +q +EOF +make EMHOME=$EMHOME COPTIONS=$options MACH=$mach CURRDIR=$PW/ $target diff --git a/lang/cem/cemcom.ansi/Version.c b/lang/cem/cemcom.ansi/Version.c new file mode 100644 index 00000000..c10d537e --- /dev/null +++ b/lang/cem/cemcom.ansi/Version.c @@ -0,0 +1,8 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef lint +static char Version[] = "ACK CEM compiler Version 3.1"; +#endif lint diff --git a/lang/cem/cemcom.ansi/asm.c b/lang/cem/cemcom.ansi/asm.c new file mode 100644 index 00000000..4900ea90 --- /dev/null +++ b/lang/cem/cemcom.ansi/asm.c @@ -0,0 +1,16 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ +/* A S M */ + +/*ARGSUSED*/ +code_asm(s, l) + char *s; + int l; +{ + /* 'asm' '(' string ')' ';' + */ + error("\"asm\" instruction not implemented"); +} diff --git a/lang/cem/cemcom.ansi/cem.1 b/lang/cem/cemcom.ansi/cem.1 new file mode 100644 index 00000000..ea79f3aa --- /dev/null +++ b/lang/cem/cemcom.ansi/cem.1 @@ -0,0 +1,230 @@ +.TH CEM 1L 86/11/12 +.SH NAME +cem \- ACK C compiler +.SH SYNOPSIS +.B cem +[ option ] ... file ... +.SH DESCRIPTION +.I Cem +is a +.I cc (1)-like +C compiler that uses the C front-end compiler +.I cemcom (1) +of the Amsterdam Compiler Kit. +.I Cem +interprets its arguments not starting with a '\-' as +source files, to be compiled by the various parts of the compilation process, +which are listed below. +File arguments whose names end with \fB.\fP\fIcharacter\fP are interpreted as +follows: +.IP .[ao] +object file. +.IP .[ci] +C source code +.IP .e +EM assembler source file. +.IP .k +compact EM file, not yet optimized by the EM peephole optimizer. +.IP .m +compact EM file, already optimized by the peephole optimizer. +.IP .s +assembler file. +.LP +The actions to be taken by +.I cem +are directed by the type of file argument and the various options that are +presented to it. +.PP +The following set of options, which is a mixture of options interpreted by +.I cc (1) +and +.I ack (?) +are interpreted by +.I cem . +(The options not specified here are passed to the loader.) +.IP \fB\-B\fP\fIname\fP +Use +.I name +as front-end compiler instead of the default +.I cemcom (1). +.br +Same as "\fB\-Rcem=\fP\fIname\fP". +.IP \fB\-C\fP +Run C preprocessor +.I /lib/cpp +only and prevent it from eliding comments. +.IP \fB\-D\fP\fIname\fP\fB=\fP\fIdef\fP +Define the +.I name +to the preprocessor, as if by "#define". +.IP \fB\-D\fP\fIname\fP +.br +Same as "\fB\-D\fP\fIname\fP\fB=1\fP". +.IP \fB\-E\fP +Run only the macro preprocessor on the named files and send the +result to standard output. +.IP \fB\-I\fP\fIdir\fP +\&"#include" files whose names do not begin with '/' are always +sought first in the directory of the \fIfile\fP argument, then in directories +in \fB\-I\fP options, then in directories on a standard list (which in fact +consists of "/usr/include"). +.IP \fB\-L\fP\fIdir\fP +Use \fIdir\fP as library-containing directory instead of the default. +.IP \fB\-N\fP\fIc\fP +Only effective if ACK pipeline is used. +This option causes some default actions and options to be suppressed, according +to +.I c : +.RS +.IP \fBc\fP +do not convert from EM a.out to local a.out format (i.e., skip the +.B cv +pass.) +.IP \fBl\fP +do not pass the default loader flags to the +.B ld +pass. +.RE +.IP \fB\-P\fP +Same as \fB\-E\fP, but sending the result of input file \fIfile\fP\fB.[ceis]\fP +to \fIfile\fP\fB.i\fP. +.IP \fB\-R\fP +Passed to \fIcemcom\fP(1) in order to parse the named C programs according +to the C language as described in [K&R] (also called \fIRestricted\fP C). +.IP \fB\-R\fP\fIprog\fP\fB=\fP\fIname\fP +.br +Use \fIname\fP as program for phase \fIprog\fP of the compilation instead of +the default. +\&\fIProg\fP is one of the following names: +.RS +.IP \fBcpp\fP +macro preprocessor +.IP \fBcem\fP +front\-end compiler +.IP \fBopt\fP +EM peephole optimizer +.IP \fBdecode\fP +EM compact to EM assembler translator +.IP \fBencode\fP +EM assembler to EM compact translator +.IP \fBbe\fP +EM compact code to target\-machine assembly code compiler +.IP \fBcg\fP +same as \fBbe\fP +.IP \fBas\fP +assembler +.IP \fBld\fP +linker/loader +.IP \fBcv\fP +a.out format converting program (only if ACK pipeline is used) +.RE +.IP \fB\-R\fP\fIprog\fP\fB\-\fP\fIoption\fP +.br +Pass \fB\-\fP\fIoption\fP to the compilation phase indicated by \fIprog\fP. +.IP \fB\-S\fP +Same as \fB\-c.s\fP. +.IP \fB\-U\fP\fIname\fP +.br +Remove any initial definition of \fIname\fP. +.IP \fB\-V\fP\fIcm\fP.\fIn\fP,\ \fB\-V\fIcm\fP.\fIncm\fP.\fIn\fP\ ... +.br +Set the size and alignment requirements of the C constructs of the named +C input files. +The letter \fIc\fP indicates the simple type, which is one of +\fBs\fP(short), \fBi\fP(int), \fBl\fP(long), \fBf\fP(float), \fBd\fP(double) or +\fBp\fP(pointer). +The \fIm\fP parameter can be used to specify the length of the type (in bytes) +and the \fIn\fP parameter for the alignment of that type. +Absence of \fIm\fP or \fIn\fP causes the default value to be retained. +To specify that the bitfields should be right adjusted instead of the +default left adjustment, specify \fBr\fP as \fIc\fP parameter +without parameters. +.br +This option is passed directly to \fIcemcom\fP(1). +.IP \fB\-c\fP +Same as \fB\-c.o\fP. +.IP \fB\-c.e\fP +Produce human-readable EM assembly code on \fIfile\fP\fB.e\fP for the +named files \fIfile\fP\fB.[cikm]\fP +.IP \fB\-c.k\fP +Compile C source \fIfile\fP\fB.[ci]\fP or +encode human-readable EM assembly code from \fIfile\fP\fB.e\fP +into non-optimized compact EM code and write the result on \fIfile\fP\fB.k\fP +.IP \fB\-c.m\fP +Compile C source \fIfile\fP\fB.[ci]\fP, +translate non-optimized EM code from \fIfile\fP\fB.k\fP or +encode EM assembly code from \fIfile\fP\fB.e\fP +into optimized compact EM code and write the result on \fIfile\fP\fB.m\fP +.IP \fB\-c.o\fP +Suppress the loading phase of the compilation, and force an object file to +be produced even if only one program is compiled +.IP \fB\-c.s\fP +Compile the named \fIfile\fP\fB.[ceikm]\fP input files, and leave the +assembly language output on corresponding files suffixed ".s". +.IP \fB\-k\fP +Same as \fB\-c.k\fP. +.IP \fB\-l\fP\fIname\fP +.br +Append the library \fBlib\fP\fIname\fP\fB.a\fP to the list of files that +should be loaded and linked into the final output file. +The library is searched for in the library directory. +.IP \fB\-m\fP +Same as \fB\-c.m\fP. +.IP \fB\-o\fP\ \fIoutput\fP +.br +Name the final output file \fIoutput\fP. +If this option is used, the default "a.out" will be left undisturbed. +.IP \fB\-p\fP +Produce EM profiling code (\fBfil\fP and \fBlin\fP instructions to +enable an interpreter to keep track of the current location in the +source code) +.IP \fB\-t\fP +Keep the intermediate files, produced during the various phases of the +compilation. +The produced files are named \fIfile\fP\fB.\fP\fIcharacter\fP where +\&\fIcharacter\fP indicates the type of the file as listed before. +.IP \fB\-v\fP +Verbose. +Print the commands before they are executed. +.IP \fB\-vn\fP +Do not really execute (for debugging purposes only). +.IP \fB\-vd\fP +Print some additional information (for debugging purposes only). +.IP \fB\-\-\fP\fIanything\fP +.br +Equivalent to \fB\-Rcem\-\-\fP\fIanything\fP. +The options +.B \-\-C , +.B \-\-E +and +.B \-\-P +all have the same effect as respectively +.B \-C , +.B \-E +and +.B \-P +except for the fact that the macro preprocessor is taken to be the +built\-in preprocessor of the \fBcem\fP phase. +Most "\-\-" options are used by +.I cemcom (1) +to set some internal debug switches. +.LP +.SH SEE ALSO +cemcom(1), cc(1), ack(?), as(1), ld(1) +.br +.IP [K&R] +B.W. Kernighan and D.M. Ritchie, \fIThe C Programming Language\fP, +Prentice-Hall, 1978. +.SH DIAGNOSTICS +.I Cem +reports any failure of its components. +.SH BUGS +.IP \(bu +All intermediate files are placed in the current working directory which +causes files with the same name as the intermediate files to be overwritten. +.IP \(bu +.B Cem +only accepts a limited number of arguments to be passed to the components. +(e.g., 256). +.IP \(bu +Please report suggestions and other bugs to erikb@vu44.uucp diff --git a/lang/cem/cemcom.ansi/cem.c b/lang/cem/cemcom.ansi/cem.c new file mode 100644 index 00000000..22095301 --- /dev/null +++ b/lang/cem/cemcom.ansi/cem.c @@ -0,0 +1,764 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ +/* + Driver for the CEMCOM compiler: works like /bin/cc and accepts + most of the options accepted by /bin/cc and /usr/em/bin/ack. + Date written: dec 4, 1985 + Adapted for 68000 (Aug 19, 1986) + Merged the vax and mantra versions (Nov 10, 1986) + Author: Erik Baalbergen +*/ + +#include +#include +#include +#include +#include + +#define MAXARGC 256 /* maximum number of arguments allowed in a list */ +#define USTR_SIZE 1024 /* maximum length of string variable */ + +struct arglist { + int al_argc; + char *al_argv[MAXARGC]; +}; + +/* some system-dependent variables */ +char *PP = "/lib/cpp"; +char *CEM = "/usr/em/lib/em_cemcom"; +char *ENCODE = "/usr/em/lib/em_encode"; +char *DECODE = "/usr/em/lib/em_decode"; +char *OPT = "/usr/em/lib/em_opt"; +char *SHELL = "/bin/sh"; + +#ifndef MANTRA +char *CG = "/usr/em/lib/vax4/cg"; +char *AS = "/bin/as"; +char *AS_FIX = "/user1/erikb/bin/mcomm"; +char *LD = "/bin/ld"; +char *LIBDIR = "/user1/cem/lib"; +char *V_FLAG = "-Vs2.2w4.4i4.4l4.4f4.4d8.4p4.4"; +#else MANTRA +char *CG = "/usr/em/lib/m68k2/cg"; +char *AS = "/usr/em/lib/m68k2/as"; +char *LD = "/usr/em/lib/em_led"; +char *CV = "/usr/em/lib/m68k2/cv"; +char *LIBDIR = "/usr/em/lib/m68k2"; +char *V_FLAG = "-Vs2.2w2.2i2.2l4.2f4.2d8.2p4.2"; +#endif MANTRA + +struct arglist LD_HEAD = { + 2, + { +#ifndef MANTRA + "/usr/em/lib/vax4/head_em", + "/usr/em/lib/vax4/head_cc" +#else MANTRA + "/usr/em/lib/m68k2/head_em", + "/usr/em/lib/m68k2/head_cc" +#endif MANTRA + } +}; + +struct arglist LD_TAIL = { +#ifndef MANTRA + 4, + { + "/user1/cem/lib/libc.a", + "/user1/cem/lib/stb.o", + "/usr/em/lib/vax4/tail_mon", + "/usr/em/lib/vax4/tail_em" + } +#else MANTRA + 7, + { + "/usr/em/lib/m68k2/tail_cc.1s", + "/usr/em/lib/m68k2/tail_cc.2g", + "/usr/em/lib/m68k2/tail_cem", + "/usr/em/lib/m68k2/tail_fp.a", + "/usr/em/lib/m68k2/tail_em.rt", + "/usr/em/lib/m68k2/tail_mon", + "/usr/em/lib/m68k2/end_em" + } +#endif MANTRA +}; + +char *o_FILE = "a.out"; +#ifdef MANTRA +char *cv_FILE = "cv.out"; +#endif MANTRA + +#define remove(str) (((FLAG(t) == 0) && unlink(str)), (str)[0] = '\0') +#define cleanup(str) (str && remove(str)) +#define mkname(dst, s1, s2) mkstr(dst, (s1), (s2), 0) +#define init(al) (al)->al_argc = 1 +#define library(nm) \ + mkstr(alloc((unsigned int)strlen(nm) + strlen(LIBDIR) + 7), \ + LIBDIR, "/lib", nm, ".a", 0) + +struct arglist SRCFILES, LDFILES, GEN_LDFILES, PP_FLAGS, CEM_FLAGS, + OPT_FLAGS, DECODE_FLAGS, ENCODE_FLAGS, CG_FLAGS, AS_FLAGS, + O_FLAGS, DEBUG_FLAGS, CALL_VEC; + +#ifndef MANTRA +struct arglist LD_FLAGS; +#else MANTRA +struct arglist LD_FLAGS = { + 5, + { + "-b0:0x80000", + "-a0:2", + "-a1:2", + "-a2:2", + "-a3:2" + } +}; +struct arglist CV_FLAGS; +int Nc_flag = 0; +#endif MANTRA + +/* option naming */ +#define NAME(chr) chr +#define FLAG(chr) NAME(chr)_flag +int E_flag, P_flag, S_flag, c_flag, e_flag, k_flag, + m_flag, o_flag, t_flag, v_flag; + +/* various passes */ +struct prog { + char *p_name; + char **p_task; + struct arglist *p_flags; +} ProgParts[] = { + { "cpp", &PP, &PP_FLAGS }, + { "cem", &CEM, &CEM_FLAGS }, + { "opt", &OPT, &OPT_FLAGS }, + { "decode", &DECODE, &DECODE_FLAGS }, + { "encode", &ENCODE, &ENCODE_FLAGS }, + { "be", &CG, &CG_FLAGS }, + { "cg", &CG, &CG_FLAGS }, + { "as", &AS, &AS_FLAGS }, + { "ld", &LD, &LD_FLAGS }, +#ifdef MANTRA + { "cv", &CV, &CV_FLAGS }, +#endif MANTRA + { 0, 0, 0 } +}; + +/* various forward declarations */ +int trap(); +char *mkstr(); +char *alloc(); +long sizeof_file(); + +/* various globals */ +char *ProgCall = 0; +int debug = 0; +int exec = 1; +int RET_CODE = 0; + +main(argc, argv) + char *argv[]; +{ + char *str, **argvec, *file, *ldfile = 0; + int count, ext; + char Nfile[USTR_SIZE], kfile[USTR_SIZE], sfile[USTR_SIZE], + mfile[USTR_SIZE], ofile[USTR_SIZE], BASE[USTR_SIZE]; + register struct arglist *call = &CALL_VEC; + + set_traps(trap); + ProgCall = *argv++; + append(&CEM_FLAGS, "-L"); + while (--argc > 0) { + if (*(str = *argv++) != '-') { + append(&SRCFILES, str); + continue; + } + switch (str[1]) { + case '-': + switch (str[2]) { + case 'C': + case 'E': + case 'P': + FLAG(E) = 1; + append(&PP_FLAGS, str); + PP = CEM; + FLAG(P) = (str[2] == 'P'); + break; + default: + append(&DEBUG_FLAGS, str); + break; + } + break; + case 'B': + PP = CEM = &str[2]; + break; + case 'C': + case 'E': + case 'P': + FLAG(E) = 1; + append(&PP_FLAGS, str); + FLAG(P) = (str[1] == 'P'); + break; + case 'c': + if (str[2] == '.') { + switch (str[3]) { + case 's': + FLAG(S) = 1; + break; + case 'k': + FLAG(k) = 1; + break; + case 'o': + FLAG(c) = 1; + break; + case 'm': + FLAG(m) = 1; + break; + case 'e': + FLAG(e) = 1; + break; + default: + bad_option(str); + } + } + else + if (str[2] == '\0') + FLAG(c) = 1; + else + bad_option(str); + break; + case 'D': + case 'I': + case 'U': + append(&PP_FLAGS, str); + break; + case 'k': + FLAG(k) = 1; + break; + case 'l': + if (str[2] == '\0') /* no standard libraries */ + LD_HEAD.al_argc = LD_TAIL.al_argc = 0; + else /* use library from library directory */ + append(&SRCFILES, library(&str[2])); + break; + case 'L': /* change default library directory */ + LIBDIR = &str[2]; + break; + case 'm': + FLAG(m) = 1; + break; +#ifdef MANTRA + case 'N': + switch (str[2]) { + case 'c': /* no a.out conversion */ + Nc_flag = 1; + break; + case 'l': /* no default options to led */ + LD_FLAGS.al_argc = 0; + break; + default: + bad_option(str); + } + break; +#endif MANTRA + case 'o': + FLAG(o) = 1; + if (argc-- < 0) + bad_option(str); + else + o_FILE = *argv++; + break; + case 'O': + append(&O_FLAGS, "-O"); + break; + case 'R': + if (str[2] == '\0') + append(&CEM_FLAGS, str); + else + Roption(str); + break; + case 'S': + FLAG(S) = 1; + break; + case 't': + FLAG(t) = 1; + break; + case 'v': /* set debug switches */ + FLAG(v) = 1; + switch (str[2]) { + case 'd': + debug = 1; + break; + case 'n': /* no execute */ + exec = 0; + break; + case '\0': + break; + default: + bad_option(str); + } + break; + case 'V': + V_FLAG = str; + break; + default: + append(&LD_FLAGS, str); + } + } + if (debug) report("Note: debug output"); + if (exec == 0) + report("Note: no execution"); + count = SRCFILES.al_argc; + argvec = &(SRCFILES.al_argv[0]); + Nfile[0] = '\0'; + while (count-- > 0) { + basename(file = *argvec++, BASE); + if (FLAG(E)) { + char ifile[USTR_SIZE]; + + init(call); + append(call, PP); + concat(call, &DEBUG_FLAGS); + concat(call, &PP_FLAGS); + append(call, file); + runvec(call, FLAG(P) ? mkname(ifile, BASE, ".i") : 0); + continue; + } + ext = extension(file); + /* .c to .k and .N */ + if (ext == 'c' || ext == 'i') { + init(call); + append(call, CEM); + concat(call, &DEBUG_FLAGS); + append(call, V_FLAG); + concat(call, &CEM_FLAGS); + concat(call, &PP_FLAGS); + append(call, file); + append(call, mkname(kfile, BASE, ".k")); + append(call, mkname(Nfile, BASE, ".N")); + if (runvec(call, (char *)0)) { + file = kfile; + ext = 'k'; + if (sizeof_file(Nfile) <= 0L) + remove(Nfile); + } + else { + remove(kfile); + remove(Nfile); + continue; + } + } + /* .e to .k */ + if (ext == 'e') { + init(call); + append(call, ENCODE); + concat(call, &ENCODE_FLAGS); + append(call, file); + append(call, mkname(kfile, BASE, ".k")); + if (runvec(call, (char *)0) == 0) + continue; + file = kfile; + ext = 'k'; + } + if (FLAG(k)) + continue; + /* decode .k or .m */ + if (FLAG(e) && (ext == 'k' || ext == 'm')) { + char efile[USTR_SIZE]; + init(call); + append(call, DECODE); + concat(call, &DECODE_FLAGS); + append(call, file); + append(call, mkname(efile, BASE, ".e")); + runvec(call, (char *)0); + cleanup(kfile); + continue; + } + /* .k to .m */ + if (ext == 'k') { + init(call); + append(call, OPT); + concat(call, &OPT_FLAGS); + append(call, file); + if (runvec(call, mkname(mfile, BASE, ".m")) == 0) + continue; + file = mfile; + ext = 'm'; + cleanup(kfile); + } + if (FLAG(m)) + continue; + /* .m to .s */ + if (ext == 'm') { + init(call); + append(call, CG); + concat(call, &CG_FLAGS); + append(call, file); + append(call, mkname(sfile, BASE, ".s")); + if (runvec(call, (char *)0) == 0) + continue; + if (Nfile[0] != '\0') { +#ifndef MANTRA + init(call); + append(call, AS_FIX); + append(call, Nfile); + append(call, sfile); + runvec(call, (char *)0); +#endif MANTRA + remove(Nfile); + } + cleanup(mfile); + file = sfile; + ext = 's'; + } + if (FLAG(S)) + continue; + /* .s to .o */ + if (ext == 's') { + ldfile = FLAG(c) ? + ofile : + alloc((unsigned)strlen(BASE) + 3); + init(call); + append(call, AS); + concat(call, &AS_FLAGS); +#ifdef MANTRA + append(call, "-"); +#endif MANTRA + append(call, "-o"); + append(call, mkname(ldfile, BASE, ".o")); + append(call, file); + if (runvec(call, (char *)0) == 0) + continue; + file = ldfile; + ext = 'o'; + cleanup(sfile); + } + if (FLAG(c)) + continue; + append(&LDFILES, file); + if (ldfile) { + append(&GEN_LDFILES, ldfile); + ldfile = 0; + } + } + /* *.o to a.out */ + if (RET_CODE == 0 && LDFILES.al_argc > 0) { + init(call); + append(call, LD); + concat(call, &LD_FLAGS); + append(call, "-o"); +#ifndef MANTRA + append(call, o_FILE); +#else MANTRA + append(call, Nc_flag ? o_FILE : cv_FILE); +#endif MANTRA + concat(call, &LD_HEAD); + concat(call, &LDFILES); + concat(call, &LD_TAIL); + if (runvec(call, (char *)0)) { + register i = GEN_LDFILES.al_argc; + + while (i-- > 0) + remove(GEN_LDFILES.al_argv[i]); +#ifdef MANTRA + /* convert to local a.out format */ + if (Nc_flag == 0) { + init(call); + append(call, CV); + concat(call, &CV_FLAGS); + append(call, cv_FILE); + append(call, o_FILE); + if (runvec(call, (char *)0)) + remove(cv_FILE); + } +#endif MANTRA + } + } + exit(RET_CODE); +} + +#define BUFSIZE (USTR_SIZE * MAXARGC) +char alloc_buf[BUFSIZE]; + +char * +alloc(u) + unsigned u; +{ + static char *bufptr = &alloc_buf[0]; + register char *p = bufptr; + + if ((bufptr += u) >= &alloc_buf[BUFSIZE]) + panic("no space"); + return p; +} + +append(al, arg) + register struct arglist *al; + char *arg; +{ + if (al->al_argc >= MAXARGC) + panic("argument list overflow"); + al->al_argv[(al->al_argc)++] = arg; +} + +concat(al1, al2) + struct arglist *al1, *al2; +{ + register int i = al2->al_argc; + register char **p = &(al1->al_argv[al1->al_argc]); + register char **q = &(al2->al_argv[0]); + + if ((al1->al_argc += i) >= MAXARGC) + panic("argument list overflow"); + while (i-- > 0) + *p++ = *q++; +} + +/* The next function is a dirty old one, taking a variable number of + arguments. + Take care that the last argument is a null-valued pointer! +*/ +/*VARARGS1*/ +char * +mkstr(dst, arg) + char *dst, *arg; +{ + char **vec = (char **) &arg; + register char *p; + register char *q = dst; + + while (p = *vec++) { + while (*q++ = *p++); + q--; + } + return dst; +} + +Roption(str) + char *str; /* of the form "prog=/-arg" */ +{ + char *eq; + char *prog, *arg; + char bc; + char *cindex(); + + prog = &str[2]; + if (eq = cindex(prog, '=')) + bc = '='; + else + if (eq = cindex(prog, '-')) + bc = '-'; + else { + bad_option(str); + return; + } + *eq++ = '\0'; + if (arg = eq) { + char *opt = 0; + struct prog *pp = &ProgParts[0]; + + if (bc == '-') + opt = mkstr(alloc((unsigned)strlen(arg) + 2), + "-", arg, 0); + while (pp->p_name) { + if (strcmp(prog, pp->p_name) == 0) { + if (opt) + append(pp->p_flags, opt); + else + *(pp->p_task) = arg; + return; + } + pp++; + } + } + bad_option(str); +} + +basename(str, dst) + char *str; + register char *dst; +{ + register char *p1 = str; + register char *p2 = p1; + + while (*p1) + if (*p1++ == '/') + p2 = p1; + p1--; + if (*--p1 == '.') { + *p1 = '\0'; + while (*dst++ = *p2++) {} + *p1 = '.'; + } + else + while (*dst++ = *p2++) {} +} + +int +extension(fn) + register char *fn; +{ + char c; + + while (*fn++) {} + fn--; + c = *--fn; + return (*--fn == '.') ? c : 0; +} + +long +sizeof_file(nm) + char *nm; +{ + struct stat stbuf; + + if (stat(nm, &stbuf) == 0) + return stbuf.st_size; + return -1; +} + +char * sysmsg[] = { + 0, + "Hangup", + "Interrupt", + "Quit", + "Illegal instruction", + "Trace/BPT trap", + "IOT trap", + "EMT trap", + "Floating exception", + "Killed", + "Bus error", + "Memory fault", + "Bad system call", + "Broken pipe", + "Alarm call", + "Terminated", + "Signal 16" +}; + +runvec(vec, outp) + struct arglist *vec; + char *outp; +{ + int status, fd; + char *task = vec->al_argv[1]; + + vec->al_argv[vec->al_argc] = 0; + if (FLAG(v)) + print_vec(vec); + if (exec == 0) + return 1; + if (fork() == 0) { /* start up the process */ + extern int errno; + if (outp) { /* redirect standard output */ + close(1); + if ((fd = creat(outp, 0666)) < 0) + panic("cannot create %s", outp); + if (fd != 1) + panic("illegal redirection"); + } + if (debug) report("exec %s", task); + execv(task, &(vec->al_argv[1])); + /* not an a.out file, let's try it with the SHELL */ + if (debug) report("try it with %s", SHELL); + if (errno == ENOEXEC) { + vec->al_argv[0] = SHELL; + execv(SHELL, &(vec->al_argv[0])); + } + /* failed, so ... */ + panic("cannot execute %s", task); + exit(1); + } + else { + int loworder, highorder, sig; + + wait(&status); + loworder = status & 0377; + highorder = (status >> 8) & 0377; + if (loworder == 0) { + if (highorder) + report("%s: exit status %d", task, highorder); + return highorder ? ((RET_CODE = 1), 0) : 1; + } + else { + sig = loworder & 0177; + if (sig == 0177) + report("%s: stopped by ptrace", task); + else + if (sysmsg[sig]) + report("%s: %s%s", task, sysmsg[sig], + (loworder & 0200) + ? " - core dumped" + : ""); + RET_CODE = 1; + return 0; + } + } + /*NOTREACHED*/ +} + +bad_option(str) + char *str; +{ + report("bad option %s", str); +} + +/*VARARGS1*/ +report(fmt, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) + char *fmt; +{ + fprintf(stderr, "%s: ", ProgCall); + fprintf(stderr, fmt, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); + fprintf(stderr, "\n"); +} + +/*VARARGS1*/ +panic(fmt, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) + char *fmt; +{ + fprintf(stderr, "%s: ", ProgCall); + fprintf(stderr, fmt, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); + fprintf(stderr, "\n"); + exit(1); +} + +set_traps(f) + int (*f)(); +{ + signal(SIGHUP, f); + signal(SIGINT, f); + signal(SIGQUIT, f); + signal(SIGALRM, f); + signal(SIGTERM, f); +} + +/*ARGSUSED*/ +trap(sig) +{ + set_traps(SIG_IGN); + panic("Trapped"); +} + +print_vec(vec) + struct arglist *vec; +{ + register i; + + for (i = 1; i < vec->al_argc; i++) + printf("%s ", vec->al_argv[i]); + printf("\n"); +} + +char * +cindex(s, c) + char *s, c; +{ + while (*s) + if (*s++ == c) + return s - 1; + return (char *) 0; +} diff --git a/lang/cem/cemcom.ansi/cemcom.1 b/lang/cem/cemcom.ansi/cemcom.1 new file mode 100644 index 00000000..0d2b8225 --- /dev/null +++ b/lang/cem/cemcom.ansi/cemcom.1 @@ -0,0 +1,104 @@ +.TH EM_CEMCOM 6ACK +.ad +.SH NAME +em_cemcom \- C to EM compiler +.SH SYNOPSIS +\fB~/em/lib/em_cemcom\fP [\fIoptions\fP] \fIsource \fP[\fIdestination \fP[\fInamelist\fP]] +.SH DESCRIPTION +\fICemcom\fP is a compiler that translates C programs +into EM compact code. +The input is taken from \fIsource\fP, while the +EM code is written on \fIdestination\fP. +If either of these two names is "\fB-\fP", standard input or output respectively +is taken. +The file \fInamelist\fP, if supplied, will contain a list of the names +of external, so-called \fBcommon\fP, variables. +When the preprocessor is invoked to run stand-alone, \fIdestination\fP +needs not be specified. +.br +\fIOptions\fP is a, possibly empty, sequence of the following combinations: +.IP \fB\-D\fIname\fR=\fItext\fR +.br +define \fIname\fR as a macro with \fItext\fR as its replacement text. +.IP \fB\-D\fIname\fR +.br +the same as \fB\-D\fIname\fR=1. +.IP \fB\-I\fIdirname\fR +.br +insert \fIdirname\fR in the list of include directories. +.IP \fB\-M\fP\fIn\fP +set maximum identifier length to \fIn\fP. +.IP \fB\-g\fP +produce a DBX-style symbol table. +.IP \fB\-n\fR +do not generate EM register messages. +The user-declared variables are not stored into registers on the target +machine. +.IP \fB\-L\fR +don't generate the EM \fBfil\fR and \fBlin\fR instructions +that usually are generated to enable +an interpreter to keep track of the current location in the source code. +.IP \fB\-p\fR +generate code at each procedure entry to call the routine +.BR procentry , +and at each return to call the routine +.BE procexit . +These routines are supplied with one parameter, a pointer to a +string containing the name of the procedure. +.IP \fB\-A\fR[\fIfile\fR] +.br +if \fIfile\fR is not given, generate a list +of makefile dependencies and write them to the standard output. +If \fIfile\fP is given, +generate the list of makefile dependencies on file \fIfile\fP. +.IP \fB-i\fR +when generating makefile dependencies, do not include files from +/usr/include. +.IP \fB-m\fR +when generating makefile dependencies, generate them in the following format: +.RS +.IP "file.o: file1.h" +.RE +.IP "" +where "file.o" is derived from the source file name. Normally, only a list +of files included is generated. +.IP \fB\-R\fR +interpret the input as restricted C (according to the language as +described in \fIThe C programming language\fR by Kernighan and Ritchie.) +.IP \fB\-U\fIname\fR +.br +get rid of the compiler-predefined macro \fIname\fR. +.IP \fB\-V\fIcm\fR.\fIn\fR,\ \fB\-V\fIcm\fR.\fIncm\fR.\fIn\fR\ ... +.br +set the size and alignment requirements. +The letter \fIc\fR indicates the simple type, which is one of +\fBs\fR(short), \fBi\fR(int), \fBl\fR(long), \fBf\fR(float), \fBd\fR(double) or +\fBp\fR(pointer). +The \fIm\fR parameter can be used to specify the length of the type (in bytes) +and the \fIn\fR parameter for the alignment of that type. +Absence of \fIm\fR or \fIn\fR causes the default value to be retained. +To specify that the bitfields should be right adjusted instead of the +default left adjustment, specify \fBr\fR as \fIc\fR parameter. +.IP \fB\-w\fR +suppress warning messages. +.IP \fB\-s\fR +suppress stricts. +.IP \fB\-a\fR +suppress warnings and stricts. +.IP \fB\-o\fR +suppress warnings and stricts about old-style. +.IP \fB\-\-\fItext\fR +.br +where \fItext\fR can be either of the above or +a debug flag of the compiler (which is not useful for the common user.) +This feature can be used in various shell scripts and surrounding programs +to force a certain option to be handed over to \fBcemcom\fR. +.LP +.SH FILES +.IR ~em/lib/em_cemcom : +the compiler +.SH DIAGNOSTICS +All warning and error messages are written on standard error output. +.SH REFERENCE +Baalbergen, E.H., D. Grune, M. Waage ;"\fIThe CEM compiler\fR", +Informatica Manual IM-4 diff --git a/lang/cem/cemcom.ansi/ch7.c b/lang/cem/cemcom.ansi/ch7.c new file mode 100644 index 00000000..022521b8 --- /dev/null +++ b/lang/cem/cemcom.ansi/ch7.c @@ -0,0 +1,641 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ +/* S E M A N T I C A N A L Y S I S -- C H A P T E R 3.3 */ + +#include "lint.h" +#include "debug.h" +#include "nobitfield.h" +#include "idf.h" +#include +#include "arith.h" +#include "proto.h" +#include "type.h" +#include "struct.h" +#include "label.h" +#include "expr.h" +#include "def.h" +#include "Lpars.h" +#include "assert.h" +#include "file_info.h" + +extern char options[]; +extern char *symbol2str(); +extern struct type *qualifier_type(); + +/* Most expression-handling routines have a pointer to a + (struct type *) as first parameter. The object under the pointer + gets updated in the process. +*/ + +ch7sel(expp, oper, idf) + struct expr **expp; + struct idf *idf; +{ + /* The selector idf is applied to *expp; oper may be '.' or + ARROW. + */ + register struct expr *exp; + register struct type *tp; + register struct sdef *sd; + + any2opnd(expp, oper); + exp = *expp; + tp = exp->ex_type; + if (oper == ARROW) { + if (tp->tp_fund == POINTER && + ( tp->tp_up->tp_fund == STRUCT || + tp->tp_up->tp_fund == UNION)) /* normal case */ + tp = tp->tp_up; + else { /* constructions like "12->selector" and + "char c; c->selector" + */ + switch (tp->tp_fund) { + case POINTER: + break; + case INT: + case LONG: + /* An error is given in idf2sdef() */ + ch7cast(expp, CAST, pa_type); + sd = idf2sdef(idf, tp); + tp = sd->sd_stype; + break; + default: + expr_error(exp, "-> applied to %s", + symbol2str(tp->tp_fund)); + case ERRONEOUS: + exp->ex_type = error_type; + return; + } + } + } else { /* oper == '.' */ + /* nothing */ + } + exp = *expp; + switch (tp->tp_fund) { + case POINTER: /* for int *p; p->next = ... */ + case STRUCT: + case UNION: + break; + case INT: + case LONG: + /* warning will be given by idf2sdef() */ + break; + default: + if (!is_anon_idf(idf)) + expr_error(exp, "selector %s applied to %s", + idf->id_text, symbol2str(tp->tp_fund)); + case ERRONEOUS: + exp->ex_type = error_type; + return; + } + sd = idf2sdef(idf, tp); + if (oper == '.') { + /* there are 3 cases in which the selection can be + performed compile-time: + I: n.sel (n either an identifier or a constant) + II: (e.s1).s2 (transformed into (e.(s1+s2))) + III: (e->s1).s2 (transformed into (e->(s1+s2))) + The code performing these conversions is + extremely obscure. + */ + if (exp->ex_class == Value) { + /* It is an object we know the address of; so + we can calculate the address of the + selected member + */ + exp->VL_VALUE += sd->sd_offset; + exp->ex_type = sd->sd_type; + exp->ex_lvalue = exp->ex_type->tp_fund != ARRAY; + if (exp->ex_type == error_type) { + exp->ex_flags |= EX_ERROR; + } + } + else + if (exp->ex_class == Oper) { + struct oper *op = &(exp->ex_object.ex_oper); + + if (op->op_oper == '.' || op->op_oper == ARROW) { + ASSERT(is_cp_cst(op->op_right)); + op->op_right->VL_VALUE += sd->sd_offset; + exp->ex_type = sd->sd_type; + exp->ex_lvalue = exp->ex_type->tp_fund != ARRAY; + if (exp->ex_type == error_type) { + exp->ex_flags |= EX_ERROR; + } + } + else { + exp = new_oper(sd->sd_type, exp, '.', + intexpr(sd->sd_offset, INT)); + exp->ex_lvalue = sd->sd_type->tp_fund != ARRAY; + if (!exp->OP_LEFT->ex_lvalue) + exp->ex_flags |= EX_ILVALUE; + } + } + } + else { /* oper == ARROW */ + exp = new_oper(sd->sd_type, + exp, oper, intexpr(sd->sd_offset, INT)); + exp->ex_lvalue = (sd->sd_type->tp_fund != ARRAY); + exp->ex_flags &= ~EX_ILVALUE; + } + if (sd->sd_type->tp_typequal & TQ_CONST) + exp->ex_flags |= EX_READONLY; + if (sd->sd_type->tp_typequal & TQ_VOLATILE) + exp->ex_flags |= EX_VOLATILE; + if (oper == '.' && exp->ex_flags & EX_READONLY) { + exp->ex_type = qualifier_type(exp->ex_type, TQ_CONST); + } + *expp = exp; +} + +ch7incr(expp, oper) + struct expr **expp; +{ + /* The monadic prefix/postfix incr/decr operator oper is + applied to *expp. + */ + ch7asgn(expp, oper, intexpr((arith)1, INT)); +} + +ch7cast(expp, oper, tp) + register struct expr **expp; + register struct type *tp; +{ + /* The expression *expp is cast to type tp; the cast is + caused by the operator oper. If the cast has + to be passed on to run time, its left operand will be an + expression of class Type. + */ + register struct type *oldtp; + + if ((*expp)->ex_type->tp_fund == FUNCTION) + function2pointer(*expp); + if ((*expp)->ex_type->tp_fund == ARRAY) + array2pointer(*expp); + if ((*expp)->ex_class == String) + string2pointer(*expp); + oldtp = (*expp)->ex_type; + +#ifndef NOBITFIELD + if (oldtp->tp_fund == FIELD) { + field2arith(expp); + ch7cast(expp, oper, tp); + } + else + if (tp->tp_fund == FIELD) { + ch7cast(expp, oper, tp->tp_up); + } + else +#endif NOBITFIELD + if (equal_type(tp, oldtp)) { + /* life is easy */ + } + else + if (tp->tp_fund == VOID) { + /* easy again */ + (*expp)->ex_type = void_type; + } + else + if (is_arith_type(oldtp) && is_arith_type(tp)) { + int oldi = is_integral_type(oldtp); + int i = is_integral_type(tp); + + if (oldi && i) { +#ifdef LINT + if (oper == CAST) + (*expp)->ex_type = tp; + else + int2int(expp, tp); +#else LINT + int2int(expp, tp); +#endif LINT + } + else + if (oldi && !i) { +#ifdef LINT + if (oper == CAST) + (*expp)->ex_type = tp; + else + int2float(expp, tp); +#else LINT + int2float(expp, tp); +#endif LINT + } + else + if (!oldi && i) { +#ifdef LINT + if (oper == CAST) + (*expp)->ex_type = tp; + else + float2int(expp, tp); +#else LINT + float2int(expp, tp); +#endif LINT + } + else { + /* !oldi && !i */ +#ifdef LINT + if (oper == CAST) + (*expp)->ex_type = tp; + else + float2float(expp, tp); +#else LINT + float2float(expp, tp); +#endif LINT + } + } + else + if (oldtp->tp_fund == POINTER && tp->tp_fund == POINTER) { + if (oper == CASTAB) + expr_warning(*expp, "incompatible pointers"); + else + if (oper != CAST) + expr_warning(*expp, "incompatible pointers in %s", + symbol2str(oper)); +#ifdef LINT + if (oper != CAST) + lint_ptr_conv(oldtp->tp_up->tp_fund, tp->tp_up->tp_fund); +#endif LINT + (*expp)->ex_type = tp; /* free conversion */ + } + else + if (oldtp->tp_fund == POINTER && is_integral_type(tp)) { + /* from pointer to integral */ + if (oper != CAST) + expr_warning(*expp, + "illegal conversion of pointer to %s", + symbol2str(tp->tp_fund)); + if (oldtp->tp_size > tp->tp_size) + expr_warning(*expp, + "conversion of pointer to %s loses accuracy", + symbol2str(tp->tp_fund)); + if (oldtp->tp_size != tp->tp_size) + int2int(expp, tp); + else + (*expp)->ex_type = tp; + } + else + if (tp->tp_fund == POINTER && is_integral_type(oldtp)) { + /* from integral to pointer */ + switch (oper) { + case CAST: + break; + case CASTAB: + case EQUAL: + case NOTEQUAL: + case '=': + case RETURN: + if (is_cp_cst(*expp) && (*expp)->VL_VALUE == (arith)0) + break; + default: + expr_warning(*expp, + "illegal conversion of %s to pointer", + symbol2str(oldtp->tp_fund)); + break; + } + if (oldtp->tp_size > tp->tp_size) + expr_warning(*expp, + "conversion of %s to pointer loses accuracy", + symbol2str(oldtp->tp_fund)); + if (oldtp->tp_size != tp->tp_size) + int2int(expp, tp); + else + (*expp)->ex_type = tp; + } + else + if (oldtp->tp_fund == ERRONEOUS) { + /* we just won't look */ + (*expp)->ex_type = tp; /* brute force */ + } + else + if (oldtp->tp_size == tp->tp_size && oper == CAST) { + expr_warning(*expp, "dubious conversion based on equal size"); + (*expp)->ex_type = tp; /* brute force */ + } + else { + if (oldtp->tp_fund != ERRONEOUS && tp->tp_fund != ERRONEOUS) + expr_error(*expp, "cannot convert %s to %s", + symbol2str(oldtp->tp_fund), + symbol2str(tp->tp_fund) + ); + (*expp)->ex_type = tp; /* brute force */ + } + if (oper == CAST) { + (*expp)->ex_flags |= EX_ILVALUE; + } +} + +/* Determine whether two types are equal. +*/ +equal_type(tp, otp) + register struct type *tp, *otp; +{ + if (tp == otp) + return 1; + if (!tp || !otp) + return 0; + + if (tp->tp_fund != otp->tp_fund) + return 0; + if (tp->tp_unsigned != otp->tp_unsigned) + return 0; + if (tp->tp_align != otp->tp_align) + return 0; + if (tp->tp_fund != ARRAY /* && tp->tp_fund != STRUCT */ ) { /* UNION ??? */ + if (tp->tp_size != otp->tp_size) + return 0; + } + + switch (tp->tp_fund) { + + case FUNCTION: + /* If both types have parameter type lists, the type of + each parameter in the composite parameter type list + is the composite type of the corresponding paramaters. + */ + if (tp->tp_proto && otp->tp_proto) { + if (!equal_proto(tp->tp_proto, otp->tp_proto)) + return 0; + } else if (tp->tp_proto || otp->tp_proto) { + if (!legal_mixture(tp, otp)) + return 0; + } + return equal_type(tp->tp_up, otp->tp_up); + + case ARRAY: + /* If one type is an array of known size, the composite + type is an array of that size + */ + if (tp->tp_size != otp->tp_size && + (tp->tp_size != -1 && otp->tp_size != -1)) + return 0; + return equal_type(tp->tp_up, otp->tp_up); + + case POINTER: + if (equal_type(tp->tp_up, otp->tp_up)) { + if (otp->tp_up->tp_typequal & TQ_CONST) { + if (!(tp->tp_up->tp_typequal & TQ_CONST)) { + strict("illegal use of pointer to const object"); + } + } + return 1; + } + else return 0; + + case FIELD: + return equal_type(tp->tp_up, otp->tp_up); + + case STRUCT: + case UNION: + case ENUM: + return tp->tp_idf == otp->tp_idf && tp->tp_sdef == otp->tp_sdef; + + default: + return 1; + } +} + +check_pseudoproto(pl, opl) + register struct proto *pl, *opl; +{ + int retval = 1; + + if (pl->pl_flag & PL_ELLIPSIS) { + error("illegal ellipsis terminator"); + return 2; + } + while (pl && opl) { + if (!equal_type(pl->pl_type, opl->pl_type)) { + if (!(pl->pl_flag & PL_ERRGIVEN) + && !(opl->pl_flag & PL_ERRGIVEN)) + error("incorrect type for parameter %s of definition", + opl->pl_idf->id_text); + pl->pl_flag |= PL_ERRGIVEN; + opl->pl_flag |= PL_ERRGIVEN; + retval = 2; + } + pl = pl->next; + opl = opl->next; + } + if (pl || opl) { + error("incorrect number of parameters"); + retval = 2; + } + return retval; +} + +legal_mixture(tp, otp) + struct type *tp, *otp; +{ + register struct proto *pl = tp->tp_proto, *opl = otp->tp_proto; + int retval = 1; + struct proto *prot; + int fund; + + ASSERT( (pl != 0) ^ (opl != 0)); + if (pl) { + prot = pl; + } else { + prot = opl; + } + if (!opl && otp->tp_pseudoproto) { + return check_pseudoproto(tp->tp_proto, otp->tp_pseudoproto); + } + + if (prot->pl_flag & PL_ELLIPSIS) { + if (!(prot->pl_flag & PL_ERRGIVEN)) { + if (pl) + error("illegal ellipsis terminator"); + else error("ellipsis terminator in previous (prototype) declaration"); + } + prot->pl_flag |= PL_ERRGIVEN; + prot = prot->next; + return 2; + } + while (prot) { + /* if (!(prot->pl_flag & PL_ELLIPSIS)) {} */ + fund = prot->pl_type->tp_fund; + if (fund == CHAR || fund == SHORT || fund == FLOAT) { + if (!(prot->pl_flag & PL_ERRGIVEN)) + error("illegal %s parameter in %sdeclaration", + symbol2str(fund), (opl ? "previous (prototype) " : "" )); + prot->pl_flag |= PL_ERRGIVEN; + retval = 2; + } + prot = prot->next; + } + return retval; +} + +equal_proto(pl, opl) + register struct proto *pl, *opl; +{ + if (pl == opl) + return 1; + + /* If only one type is a function type with a parameter type list + (a function prototype), the composite type is a function + prototype with parameter type list. + */ + while ( pl && opl) { + + if ((pl->pl_flag & ~PL_ERRGIVEN) != (opl->pl_flag & ~PL_ERRGIVEN)) + return 0; + + if (!equal_type(pl->pl_type, opl->pl_type)) + return 0; + + pl = pl->next; + opl = opl->next; + } + return !(pl || opl); +} + +recurconst(tp) +struct type *tp; +{ + register struct sdef *sdf; + + ASSERT(tp); + if (!tp) return 0; + if (tp->tp_typequal & TQ_CONST) return 1; + sdf = tp->tp_sdef; + while (sdf) { + if (recurconst(sdf->sd_type)) + return 1; + sdf = sdf->sd_sdef; + } + return 0; +} + +ch7asgn(expp, oper, expr) + struct expr **expp; + struct expr *expr; +{ + /* The assignment operators. + "f op= e" should be interpreted as + "f = (typeof f)((typeof (f op e))f op (typeof (f op e))e)" + and not as "f = f op (typeof f)e". + Consider, for example, (i == 10) i *= 0.9; (i == 9), where + typeof i == int. + The resulting expression tree becomes: + op= + / \ + / \ + f (typeof (f op e))e + EVAL should however take care of evaluating (typeof (f op e))f + */ + register struct expr *exp = *expp; + int fund = exp->ex_type->tp_fund; + int vol = 0; + struct type *tp; + + /* We expect an lvalue */ + if (!exp->ex_lvalue) { + expr_error(exp, "no lvalue in operand of %s", symbol2str(oper)); + } else if (exp->ex_flags & EX_ILVALUE) { + strict("incorrect lvalue in operand of %s", symbol2str(oper)); + } else if (exp->ex_flags & EX_READONLY) { + expr_error(exp, "operand of %s is read-only", symbol2str(oper)); + } else if (fund == STRUCT || fund == UNION) { + if (recurconst(exp->ex_type)) + expr_error(expr,"operand of %s contains a const-qualified member", + symbol2str(oper)); + } + + /* Preserve volatile markers across the tree. + This is questionable, depending on the way the optimizer + wants this information. + vol = (exp->ex_flags & EX_VOLATILE) || (expr->ex_flags & EX_VOLATILE); + */ + + if (oper == '=') { + ch7cast(&expr, oper, exp->ex_type); + tp = expr->ex_type; + } + else { /* turn e into e' where typeof(e') = typeof (f op e) */ + struct expr *extmp = intexpr((arith)0, INT); + + /* this is really $#@&*%$# ! */ + /* if you correct this, please correct lint_new_oper() too */ + extmp->ex_lvalue = 1; + extmp->ex_type = exp->ex_type; + ch7bin(&extmp, oper, expr); + /* Note that ch7bin creates a tree of the expression + ((typeof (f op e))f op (typeof (f op e))e), + where f ~ extmp and e ~ expr. + We want to use (typeof (f op e))e. + Ch7bin does not create a tree if both operands + were illegal or constants! + */ + tp = extmp->ex_type; /* perform the arithmetic in type tp */ + if (extmp->ex_class == Oper) { + expr = extmp->OP_RIGHT; + extmp->OP_RIGHT = NILEXPR; + free_expression(extmp); + } + else + expr = extmp; + } +#ifndef NOBITFIELD + if (fund == FIELD) + exp = new_oper(exp->ex_type->tp_up, exp, oper, expr); + else + exp = new_oper(exp->ex_type, exp, oper, expr); +#else NOBITFIELD + exp = new_oper(exp->ex_type, exp, oper, expr); +#endif NOBITFIELD + exp->OP_TYPE = tp; /* for EVAL() */ + exp->ex_flags |= vol ? (EX_SIDEEFFECTS|EX_VOLATILE) : EX_SIDEEFFECTS; + *expp = exp; +} + +/* Some interesting (?) questions answered. +*/ +int +is_integral_type(tp) + register struct type *tp; +{ + switch (tp->tp_fund) { + case GENERIC: + case CHAR: + case SHORT: + case INT: + case LONG: + case ENUM: + return 1; +#ifndef NOBITFIELD + case FIELD: + return is_integral_type(tp->tp_up); +#endif NOBITFIELD + default: + return 0; + } +} + +int +is_arith_type(tp) + register struct type *tp; +{ + switch (tp->tp_fund) { + case GENERIC: + case CHAR: + case SHORT: + case INT: + case LONG: + case ENUM: + case FLOAT: + case DOUBLE: + case LNGDBL: + return 1; +#ifndef NOBITFIELD + case FIELD: + return is_arith_type(tp->tp_up); +#endif NOBITFIELD + default: + return 0; + } +} diff --git a/lang/cem/cemcom.ansi/ch7bin.c b/lang/cem/cemcom.ansi/ch7bin.c new file mode 100644 index 00000000..66d3ff6f --- /dev/null +++ b/lang/cem/cemcom.ansi/ch7bin.c @@ -0,0 +1,352 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ +/* SEMANTIC ANALYSIS (CHAPTER 3.3) -- BINARY OPERATORS */ + +#include "botch_free.h" +#include +#include "lint.h" +#include "idf.h" +#include +#include "arith.h" +#include "type.h" +#include "struct.h" +#include "label.h" +#include "expr.h" +#include "Lpars.h" + +extern char options[]; +extern char *symbol2str(); + +/* This chapter asks for the repeated application of code to handle + an operation that may be executed at compile time or at run time, + depending on the constancy of the operands. +*/ + +#define commutative_binop(expp, oper, expr) mk_binop(expp, oper, expr, 1) +#define non_commutative_binop(expp, oper, expr) mk_binop(expp, oper, expr, 0) + +ch7bin(expp, oper, expr) + register struct expr **expp; + struct expr *expr; +{ + /* apply binary operator oper between *expp and expr. + NB: don't swap operands if op is one of the op= operators!!! + */ + + any2opnd(expp, oper); + any2opnd(&expr, oper); + switch (oper) { + case '[': /* 3.3.2.1 */ + /* indexing follows the commutative laws */ + switch ((*expp)->ex_type->tp_fund) { + case POINTER: + case ARRAY: + break; + case ERRONEOUS: + return; + default: /* unindexable */ + switch (expr->ex_type->tp_fund) { + case POINTER: + case ARRAY: + break; + case ERRONEOUS: + return; + default: + expr_error(*expp, + "indexing an object of type %s", + symbol2str((*expp)->ex_type->tp_fund)); + return; + } + break; + } + ch7bin(expp, '+', expr); + ch7mon('*', expp); + break; + + case '(': /* 3.3.2.2 */ + if ( (*expp)->ex_type->tp_fund == POINTER && + (*expp)->ex_type->tp_up->tp_fund == FUNCTION + ) { + ch7mon('*', expp); + } + if ((*expp)->ex_type->tp_fund != FUNCTION) { + expr_error(*expp, "call of non-function (%s)", + symbol2str((*expp)->ex_type->tp_fund)); + /* leave the expression; it may still serve */ + free_expression(expr); /* there go the parameters */ + *expp = new_oper(error_type, + *expp, '(', (struct expr *)0); + } + else + *expp = new_oper((*expp)->ex_type->tp_up, + *expp, '(', expr); + (*expp)->ex_flags |= EX_SIDEEFFECTS; + break; + + case PARCOMMA: /* 3.3.2.2 */ + if ((*expp)->ex_type->tp_fund == FUNCTION) + function2pointer(*expp); + *expp = new_oper(expr->ex_type, *expp, PARCOMMA, expr); + break; + + case '%': + case MODAB: + case ANDAB: + case XORAB: + case ORAB: + opnd2integral(expp, oper); + opnd2integral(&expr, oper); + /* fallthrough */ + case '/': + case DIVAB: + case TIMESAB: + arithbalance(expp, oper, &expr); + non_commutative_binop(expp, oper, expr); + break; + + case '&': + case '^': + case '|': + opnd2integral(expp, oper); + opnd2integral(&expr, oper); + /* fallthrough */ + case '*': + arithbalance(expp, oper, &expr); + commutative_binop(expp, oper, expr); + break; + + case '+': + if (expr->ex_type->tp_fund == POINTER) { /* swap operands */ + struct expr *etmp = expr; + expr = *expp; + *expp = etmp; + } + /* fallthrough */ + case PLUSAB: + case POSTINCR: + case PLUSPLUS: + if ((*expp)->ex_type->tp_fund == POINTER) { + pointer_arithmetic(expp, oper, &expr); + if (expr->ex_type->tp_size != (*expp)->ex_type->tp_size) + ch7cast(&expr, CAST, (*expp)->ex_type); + pointer_binary(expp, oper, expr); + } + else { + arithbalance(expp, oper, &expr); + if (oper == '+') + commutative_binop(expp, oper, expr); + else + non_commutative_binop(expp, oper, expr); + } + break; + + case '-': + case MINAB: + case POSTDECR: + case MINMIN: + if ((*expp)->ex_type->tp_fund == POINTER) { + if (expr->ex_type->tp_fund == POINTER) + pntminuspnt(expp, oper, expr); + else { + pointer_arithmetic(expp, oper, &expr); + pointer_binary(expp, oper, expr); + } + } + else { + arithbalance(expp, oper, &expr); + non_commutative_binop(expp, oper, expr); + } + break; + + case LEFT: + case RIGHT: + case LEFTAB: + case RIGHTAB: + opnd2integral(expp, oper); + opnd2integral(&expr, oper); + arithbalance(expp, oper, &expr); /* ch. 7.5 */ + ch7cast(&expr, oper, int_type); /* cvt. rightop to int */ + non_commutative_binop(expp, oper, expr); + break; + + case '<': + case '>': + case LESSEQ: + case GREATEREQ: + case EQUAL: + case NOTEQUAL: + relbalance(expp, oper, &expr); + non_commutative_binop(expp, oper, expr); + (*expp)->ex_type = int_type; + break; + + case AND: + case OR: + opnd2test(expp, oper); + opnd2test(&expr, oper); + if (is_cp_cst(*expp)) { + register struct expr *ex = *expp; + + /* the following condition is a short-hand for + ((oper == AND) && o1) || ((oper == OR) && !o1) + where o1 == (*expp)->VL_VALUE; + and ((oper == AND) || (oper == OR)) + */ + if ((oper == AND) == (ex->VL_VALUE != (arith)0)) + *expp = expr; + else { + ex->ex_flags |= expr->ex_flags; + free_expression(expr); + *expp = intexpr((arith)((oper == AND) ? 0 : 1), + INT); + } + (*expp)->ex_flags |= ex->ex_flags; + free_expression(ex); + } + else + if (is_cp_cst(expr)) { + /* Note!!!: the following condition is a short-hand for + ((oper == AND) && o2) || ((oper == OR) && !o2) + where o2 == expr->VL_VALUE + and ((oper == AND) || (oper == OR)) + */ + if ((oper == AND) == (expr->VL_VALUE != (arith)0)) { + (*expp)->ex_flags |= expr->ex_flags; + free_expression(expr); + } + else { + if (oper == OR) + expr->VL_VALUE = (arith)1; + ch7bin(expp, ',', expr); + } + } + else { + *expp = new_oper(int_type, *expp, oper, expr); + } + (*expp)->ex_flags |= EX_LOGICAL; + break; + + case ':': + if ( is_struct_or_union((*expp)->ex_type->tp_fund) + || is_struct_or_union(expr->ex_type->tp_fund) + ) { + if (!equal_type((*expp)->ex_type, expr->ex_type)) + expr_error(*expp, "illegal balance"); + } + else + relbalance(expp, oper, &expr); +#ifdef LINT + if ( (is_cp_cst(*expp) && is_cp_cst(expr)) + && (*expp)->VL_VALUE == expr->VL_VALUE + ) { + hwarning("operands of : are constant and equal"); + } +#endif LINT + *expp = new_oper((*expp)->ex_type, *expp, oper, expr); + break; + + case '?': + opnd2logical(expp, oper); + if (is_cp_cst(*expp)) { +#ifdef LINT + hwarning("condition in ?: expression is constant"); +#endif LINT + *expp = (*expp)->VL_VALUE ? + expr->OP_LEFT : expr->OP_RIGHT; + } + else { + *expp = new_oper(expr->ex_type, *expp, oper, expr); + } + break; + + case ',': + if (is_cp_cst(*expp)) + *expp = expr; + else + *expp = new_oper(expr->ex_type, *expp, oper, expr); + (*expp)->ex_flags |= EX_COMMA; + break; + } +} + +pntminuspnt(expp, oper, expr) + register struct expr **expp, *expr; +{ + /* Subtracting two pointers is so complicated it merits a + routine of its own. + */ + struct type *up_type = (*expp)->ex_type->tp_up; + + if (!equal_type(up_type, expr->ex_type->tp_up)) { + expr_error(*expp, "subtracting incompatible pointers"); + free_expression(expr); + erroneous2int(expp); + return; + } + /* we hope the optimizer will eliminate the load-time + pointer subtraction + */ + *expp = new_oper((*expp)->ex_type, *expp, oper, expr); + ch7cast(expp, CAST, pa_type); /* ptr-ptr: result has pa_type */ + ch7bin(expp, '/', + intexpr(size_of_type(up_type, "object"), pa_type->tp_fund)); + ch7cast(expp, CAST, int_type); /* result will be an integer expr */ +} + +mk_binop(expp, oper, expr, commutative) + struct expr **expp; + register struct expr *expr; +{ + /* Constructs in *expp the operation indicated by the operands. + "commutative" indicates whether "oper" is a commutative + operator. + */ + register struct expr *ex = *expp; + + if (is_cp_cst(expr) && is_cp_cst(ex)) + cstbin(expp, oper, expr); + else if (is_fp_cst(expr) && is_fp_cst(ex)) + fltcstbin(expp, oper, expr); + else { + *expp = (commutative && expr->ex_depth >= ex->ex_depth) ? + new_oper(ex->ex_type, expr, oper, ex) : + new_oper(ex->ex_type, ex, oper, expr); + } +} + +pointer_arithmetic(expp1, oper, expp2) + register struct expr **expp1, **expp2; +{ + int typ; + /* prepares the integral expression expp2 in order to + apply it to the pointer expression expp1 + */ + if ((typ = any2arith(expp2, oper)) == FLOAT + || typ == DOUBLE + || typ == LNGDBL) { + expr_error(*expp2, + "illegal combination of %s and pointer", + symbol2str(typ)); + erroneous2int(expp2); + } + ch7bin( expp2, '*', + intexpr(size_of_type((*expp1)->ex_type->tp_up, "object"), + pa_type->tp_fund) + ); +} + +pointer_binary(expp, oper, expr) + register struct expr **expp, *expr; +{ + /* constructs the pointer arithmetic expression out of + a pointer expression, a binary operator and an integral + expression. + */ + if (is_ld_cst(expr) && is_ld_cst(*expp)) + cstbin(expp, oper, expr); + else + *expp = new_oper((*expp)->ex_type, *expp, oper, expr); +} diff --git a/lang/cem/cemcom.ansi/ch7mon.c b/lang/cem/cemcom.ansi/ch7mon.c new file mode 100644 index 00000000..ab3e3864 --- /dev/null +++ b/lang/cem/cemcom.ansi/ch7mon.c @@ -0,0 +1,168 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ +/* SEMANTIC ANALYSIS (CHAPTER 3.3) -- MONADIC OPERATORS */ + +#include "botch_free.h" +#include +#include "nobitfield.h" +#include "Lpars.h" +#include +#include "arith.h" +#include "type.h" +#include "label.h" +#include "expr.h" +#include "idf.h" +#include "def.h" + +extern char options[]; +extern arith full_mask[/*MAXSIZE*/]; /* cstoper.c */ +char *symbol2str(); + +ch7mon(oper, expp) + register struct expr **expp; +{ + /* The monadic prefix operator oper is applied to *expp. + */ + register struct expr *expr; + + switch (oper) { + case '*': /* 3.3.3.2 */ + /* no FIELD type allowed */ + if ((*expp)->ex_type->tp_fund == ARRAY) + array2pointer(*expp); + if ((*expp)->ex_type->tp_fund != POINTER) { + if ((*expp)->ex_type->tp_fund != FUNCTION) { + expr_error(*expp, + "* applied to non-pointer (%s)", + symbol2str((*expp)->ex_type->tp_fund)); + } else { + warning("superfluous use of * on function"); + /* ignore indirection (yegh) */ + } + } else { + expr = *expp; + if (expr->ex_lvalue == 0 && expr->ex_class != String) + /* dereference in administration only */ + expr->ex_type = expr->ex_type->tp_up; + else /* runtime code */ + *expp = new_oper(expr->ex_type->tp_up, NILEXPR, + '*', expr); + (*expp)->ex_lvalue = ( + (*expp)->ex_type->tp_fund != ARRAY && + (*expp)->ex_type->tp_fund != FUNCTION + ); + if ((*expp)->ex_type->tp_typequal & TQ_CONST) + (*expp)->ex_flags |= EX_READONLY; + if ((*expp)->ex_type->tp_typequal & TQ_VOLATILE) + (*expp)->ex_flags |= EX_VOLATILE; + (*expp)->ex_flags &= ~EX_ILVALUE; + } + break; + case '&': + if ((*expp)->ex_type->tp_fund == ARRAY) { + expr_warning(*expp, "& before array ignored"); + array2pointer(*expp); + } + else + if ((*expp)->ex_type->tp_fund == FUNCTION) { + expr_warning(*expp, "& before function ignored"); + function2pointer(*expp); + } + else +#ifndef NOBITFIELD + if ((*expp)->ex_type->tp_fund == FIELD) + expr_error(*expp, "& applied to field variable"); + else +#endif NOBITFIELD + if (!(*expp)->ex_lvalue) + expr_error(*expp, "& applied to non-lvalue"); + else if ((*expp)->ex_flags & EX_ILVALUE) + expr_error(*expp, "& applied to illegal lvalue"); + else { + /* assume that enums are already filtered out */ + if (ISNAME(*expp)) { + register struct def *def = + (*expp)->VL_IDF->id_def; + + /* & indicates that + cannot be used as register + anymore + */ + if (def->df_sc == REGISTER) { + expr_error(*expp, + "& on register variable not allowed"); + break; /* break case '&' */ + } + } + (*expp)->ex_type = pointer_to((*expp)->ex_type, + (*expp)->ex_type->tp_typequal); + (*expp)->ex_lvalue = 0; + (*expp)->ex_flags &= ~EX_READONLY; + } + break; + case '~': + { + int fund = (*expp)->ex_type->tp_fund; + + if (fund == FLOAT || fund == DOUBLE || fund == LNGDBL) { + expr_error( *expp, + "~ not allowed on %s operands", + symbol2str(fund)); + erroneous2int(expp); + break; + } + /* FALLTHROUGH */ + } + case '-': + any2arith(expp, oper); + if (is_cp_cst(*expp)) { + arith o1 = (*expp)->VL_VALUE; + + (*expp)->VL_VALUE = (oper == '-') ? -o1 : + ((*expp)->ex_type->tp_unsigned ? + (~o1) & full_mask[(*expp)->ex_type->tp_size] : + ~o1 + ); + } + else + if (is_fp_cst(*expp)) + switch_sign_fp(*expp); + else + *expp = new_oper((*expp)->ex_type, + NILEXPR, oper, *expp); + break; + case '!': + if ((*expp)->ex_type->tp_fund == FUNCTION) + function2pointer(*expp); + if ((*expp)->ex_type->tp_fund != POINTER) + any2arith(expp, oper); + opnd2test(expp, '!'); + if (is_cp_cst(*expp)) { + (*expp)->VL_VALUE = !((*expp)->VL_VALUE); + (*expp)->ex_type = int_type; /* a cast ???(EB) */ + } + else + *expp = new_oper(int_type, NILEXPR, oper, *expp); + (*expp)->ex_flags |= EX_LOGICAL; + break; + case PLUSPLUS: + case MINMIN: + ch7incr(expp, oper); + break; + case SIZEOF: + if (ISNAME(*expp) && (*expp)->VL_IDF->id_def->df_formal_array) + expr_warning(*expp, "sizeof formal array %s is sizeof pointer!", + (*expp)->VL_IDF->id_text); + expr = intexpr((*expp)->ex_class == String ? + (arith)((*expp)->SG_LEN) : + size_of_type((*expp)->ex_type, "object"), + INT); + expr->ex_flags |= EX_SIZEOF; + free_expression(*expp); + *expp = expr; + break; + } +} diff --git a/lang/cem/cemcom.ansi/decspecs.str b/lang/cem/cemcom.ansi/decspecs.str new file mode 100644 index 00000000..0895f972 --- /dev/null +++ b/lang/cem/cemcom.ansi/decspecs.str @@ -0,0 +1,21 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ +/* DECLARATION SPECIFIER DEFINITION */ + +struct decspecs { + struct decspecs *next; + struct type *ds_type; /* single type */ + int ds_notypegiven; /* set if type not given explicitly */ + int ds_typedef; /* 1 if type was a user typedef */ + int ds_sc_given; /* 1 if the st. class is explicitly given */ + int ds_sc; /* storage class, given or implied */ + int ds_size; /* LONG, SHORT or 0 */ + int ds_unsigned; /* SIGNED, UNSIGNED or 0 */ + int ds_typequal; /* type qualifiers - see type.str */ +}; + +extern struct type *qualifier_type(); +extern struct decspecs null_decspecs; diff --git a/lang/cem/cemcom.ansi/l_dummy.c b/lang/cem/cemcom.ansi/l_dummy.c new file mode 100644 index 00000000..f0633a61 --- /dev/null +++ b/lang/cem/cemcom.ansi/l_dummy.c @@ -0,0 +1,74 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +/* + *The following functions are hacked to null-functions (i.e. they + * do nothing). This needs another solution in the future. + */ +#include "lint.h" + +#ifdef LINT + +#include "arith.h" +#include "label.h" + +C_close(){} +int C_busy(){return 0;} + + +/* More routines */ +/* ARGSUSED */ +CC_bhcst(ps_xxx,n,w,i) arith n,w; {} +/* ARGSUSED */ +CC_crcst(ps_xxx,v) arith v; {} +/* ARGSUSED */ +CC_crdlb(ps_xxx,v,s) label v; arith s; {} +/* ARGSUSED */ +CC_crdnam(ps_xxx,v,s) char *v; arith s; {} +/* ARGSUSED */ +CC_crfcon(ps_xxx,v,s) char *v; arith s; {} +/* ARGSUSED */ +CC_cricon(ps_xxx,v,s) char *v; arith s; {} +/* ARGSUSED */ +CC_crilb(ps_xxx,v) label v; {} +/* ARGSUSED */ +CC_crpnam(ps_xxx,v) char *v; {} +/* ARGSUSED */ +CC_crscon(ps_xxx,v,s) char *v; arith s; {} +/* ARGSUSED */ +CC_crucon(ps_xxx,v,s) char *v; arith s; {} +/* ARGSUSED */ +CC_cst(l) {} +/* ARGSUSED */ +CC_dfdlb(l) label l; {} +/* ARGSUSED */ +CC_dfdnam(s) char *s; {} +/* ARGSUSED */ +CC_dfilb(l) label l; {} +/* ARGSUSED */ +CC_end(l) arith l; {} +CC_msend() {} +/* ARGSUSED */ +CC_msstart(ms) {} +/* ARGSUSED */ +CC_opcst(op_xxx,c) arith c; {} +/* ARGSUSED */ +CC_opdlb(op_xxx,g,o) label g; arith o; {} +/* ARGSUSED */ +CC_opilb(op_xxx,b) label b; {} +/* ARGSUSED */ +CC_oppnam(op_xxx,p) char *p; {} +/* ARGSUSED */ +CC_pronarg(s) char *s; {} +/* ARGSUSED */ +CC_psdlb(ps_xxx,l) label l; {} +/* ARGSUSED */ +CC_psdnam(ps_xxx,s) char *s; {} +/* ARGSUSED */ +CC_pspnam(ps_xxx,s) char *s; {} +/* ARGSUSED */ +CC_scon(v,s) char *s; {} +#endif LINT diff --git a/lang/cem/cemcom.ansi/mcomm.c b/lang/cem/cemcom.ansi/mcomm.c new file mode 100644 index 00000000..c811685c --- /dev/null +++ b/lang/cem/cemcom.ansi/mcomm.c @@ -0,0 +1,246 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* mcomm.c -- change ".lcomm name" into ".comm name" where "name" + is specified in a list. +*/ +#include + +#define IDFSIZE 4096 + +char *readfile(); + +struct node { + char *name; + struct node *left, *right; +}; + +char * +Malloc(n) + unsigned n; +{ + char *space; + char *malloc(); + + if ((space = malloc(n)) == 0) { + fprintf(stderr, "out of memory\n"); + exit(1); + } + return space; +} + +struct node *make_tree(); + +#define new_node() ((struct node *) Malloc(sizeof (struct node))) + +main(argc, argv) + char *argv[]; +{ + char *nl_file, *as_file; + char *nl_text, *as_text; + struct node *nl_tree = 0; + int nl_siz, as_siz; + + if (argc != 3) { + fprintf(stderr, "use: %s namelist assembler_file\n", argv[0]); + exit(1); + } + nl_file = argv[1]; + as_file = argv[2]; + + if ((nl_text = readfile(nl_file, &nl_siz)) == 0) { + fprintf(stderr, "%s: cannot read namelist %s\n", + argv[0], nl_file); + exit(1); + } + + if ((as_text = readfile(as_file, &as_siz)) == 0) { + fprintf(stderr, "%s: cannot read assembler file %s\n", + argv[0], as_file); + exit(1); + } + + nl_tree = make_tree(nl_text); + edit(as_text, nl_tree); + + if (writefile(as_file, as_text, as_siz) == 0) { + fprintf(stderr, "%s: cannot write to %s\n", argv[0], as_file); + exit(1); + } + return 0; +} + +#include +#include + +char * +readfile(filename, psiz) + char *filename; + int *psiz; +{ + struct stat stbuf; /* for `stat' to get filesize */ + register int fd; /* filedescriptor for `filename' */ + register char *cbuf; /* pointer to buffer to be returned */ + + if (((fd = open(filename, 0)) < 0) || (fstat(fd, &stbuf) != 0)) + return 0; + cbuf = Malloc(stbuf.st_size + 1); + if (read(fd, cbuf, stbuf.st_size) != stbuf.st_size) + return 0; + cbuf[stbuf.st_size] = '\0'; + close(fd); /* filedes no longer needed */ + *psiz = stbuf.st_size; + return cbuf; +} + +int +writefile(filename, text, size) + char *filename, *text; +{ + register fd; + + if ((fd = open(filename, 1)) < 0) + return 0; + if (write(fd, text, size) != size) + return 0; + close(fd); + return 1; +} + +struct node * +make_tree(nl) + char *nl; +{ + char *id = nl; + struct node *tree = 0; + + while (*nl) { + if (*nl == '\n') { + *nl = '\0'; + insert(&tree, id); + id = ++nl; + } + else { + ++nl; + } + } + return tree; +} + +insert(ptree, id) + struct node **ptree; + char *id; +{ + register cmp; + + if (*ptree == 0) { + register struct node *nnode = new_node(); + + nnode->name = id; + nnode->left = nnode->right = 0; + *ptree = nnode; + } + else + if ((cmp = strcmp((*ptree)->name, id)) < 0) + insert(&((*ptree)->right), id); + else + if (cmp > 0) + insert(&((*ptree)->left), id); +} + +struct node * +find(tree, id) + struct node *tree; + char *id; +{ + register cmp; + + if (tree == 0) + return 0; + if ((cmp = strcmp(tree->name, id)) < 0) + return find(tree->right, id); + if (cmp > 0) + return find(tree->left, id); + return tree; +} + +edit(text, tree) + char *text; + struct node *tree; +{ + register char *ptr = text; + char idbuf[IDFSIZE]; + register char *id; + register char *save_ptr; + + while (*ptr) { + if ( + *ptr == '.' && + *++ptr == 'l' && + *++ptr == 'c' && + *++ptr == 'o' && + *++ptr == 'm' && + *++ptr == 'm' && + (*++ptr == ' ' || *ptr == '\t') + ) + { + save_ptr = ptr - 6; + while (*++ptr == ' ' || *ptr == '\t') + ; + if (*ptr == '_') + ++ptr; + if (InId(*ptr)) { + id = &idbuf[0]; + *id++ = *ptr++; + while (InId(*ptr)) + *id++ = *ptr++; + *id = '\0'; + if (find(tree, idbuf) != 0) { + *save_ptr++ = ' '; + *save_ptr++ = '.'; + } + } + } + while (*ptr && *ptr++ != '\n') + ; + } +} + +InId(c) +{ + switch (c) { + + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '_': + case '.': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + return 1; + + default: + return 0; + } +} + +puttree(nd) + struct node *nd; +{ + if (nd) { + puttree(nd->left); + printf("%s\n", nd->name); + puttree(nd->right); + } +} diff --git a/lang/cem/cemcom.ansi/nmclash.c b/lang/cem/cemcom.ansi/nmclash.c new file mode 100644 index 00000000..e820442d --- /dev/null +++ b/lang/cem/cemcom.ansi/nmclash.c @@ -0,0 +1,9 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* Accepted if many characters of long names are significant */ +/* $Header$ */ +abcdefghijklmnopr() { } +abcdefghijklmnopq() { } +main() { } diff --git a/lang/cem/cemcom.ansi/scan.c b/lang/cem/cemcom.ansi/scan.c new file mode 100644 index 00000000..d5b259e1 --- /dev/null +++ b/lang/cem/cemcom.ansi/scan.c @@ -0,0 +1,237 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ +/* PREPROCESSOR: SCANNER FOR THE ACTUAL PARAMETERS OF MACROS */ + +#include "nopp.h" + +#ifndef NOPP +/* This file contains the function getactuals() which scans an actual + parameter list and splits it up into a list of strings, each one + representing an actual parameter. +*/ + +#include "lapbuf.h" /* UF */ +#include "nparams.h" /* UF */ + +#include "input.h" +#include "class.h" +#include "idf.h" +#include "macro.h" +#include "interface.h" +#include "file_info.h" + +#define EOS '\0' +#define overflow() (fatal("actual parameter buffer overflow")) + +PRIVATE char apbuf[LAPBUF]; /* temporary storage for actual parameters */ +PRIVATE char *actparams[NPARAMS]; /* pointers to the text of the actuals */ +PRIVATE char *aptr; /* pointer to last inserted character in apbuf */ + +#define copy(ch) ((aptr < &apbuf[LAPBUF]) ? (*aptr++ = ch) : overflow()) + +PRIVATE int nr_of_params; /* number of actuals read until now */ + +PRIVATE char ** +getactuals(idef) + register struct idf *idef; +{ + /* getactuals() collects the actual parameters and turns them + into a list of strings, a pointer to which is returned. + */ + register acnt = idef->id_macro->mc_nps; + + nr_of_params = 0; + actparams[0] = aptr = &apbuf[0]; + copyact('(', ')', 0); /* read the actual parameters */ + copy(EOS); /* mark the end of it all */ + + if (!nr_of_params++) { /* 0 or 1 parameter */ + /* there could be a ( ) + */ + register char *p = actparams[0]; + + while ((class(*p) == STSKIP) || (*p == '\n')) { + ++p; + } + + if (!*p) { /* the case () : 0 parameters */ + nr_of_params--; + } + } + + if (nr_of_params != acnt) { + /* argument mismatch: too many or too few + actual parameters. + */ + lexwarning("argument mismatch, %s", idef->id_text); + + while (nr_of_params < acnt) { + /* too few paraeters: remaining actuals are "" + */ + actparams[nr_of_params] = ""; + nr_of_params++; + } + } + + return actparams; +} + +PRIVATE +copyact(ch1, ch2, lvl) + char ch1, ch2; + int lvl; +{ + /* copyact() is taken from Ceriel Jacobs' LLgen, with + permission. Its task is to build a list of actuals + parameters, which list is surrounded by '(' and ')' and in + which the parameters are separated by ',' if there are + more than 1. The balancing of '(',')' and '[',']' and + '{','}' is taken care of by calling this function + recursively. At each level lvl, copyact() reads the input, + upto the corresponding closing bracket. + + Opening bracket is ch1, closing bracket is ch2. If + lvl != 0, copy opening and closing parameters too. + */ + register int ch; /* Current char */ + register int match; /* used to read strings */ + + if (lvl) { + copy(ch1); + } + + for (;;) { + LoadChar(ch); + + if (ch == ch2) { + if (lvl) { + copy(ch); + } + return; + } + + switch(ch) { + +#ifdef __MATCHING_PAR__ + case ')': + case '}': + case ']': + lexerror("unbalanced parenthesis"); + break; +#endif __MATCHING_PAR__ + + case '(': + copyact('(', ')', lvl+1); + break; + +#ifdef __MATCHING_PAR__ + case '{': + /* example: + #define declare(v, t) t v + declare(v, union{int i, j; float r;}); + */ + copyact('{', '}', lvl+1); + break; + + case '[': + copyact('[', ']', lvl+1); + break; +#endif __MATCHING_PAR__ + + case '\n': + LineNumber++; + while (LoadChar(ch), ch == '#') { + /* This piece of code needs some + explanation: consider the call of + the macro defined as: + #define sum(b,c) (b + c) + in the following form: + sum( + #include my_phone_number + ,2) + in which case the include must be + interpreted as such. + */ + domacro(); /* has read nl, vt or ff */ + /* Loop, for another control line */ + } + + PushBack(); + copy(' '); + break; + + case '/': + LoadChar(ch); + + if (ch == '*' && !InputLevel) { /* skip comment */ + skipcomment(); + continue; + } + + PushBack(); + copy('/'); + break; + + case ',': + if (!lvl) { + /* next parameter encountered */ + copy(EOS); + + if (++nr_of_params >= NPARAMS) { + fatal("too many actual parameters"); + } + + actparams[nr_of_params] = aptr; + } + else { + copy(ch); + } + break; + + case '\'': + case '"' : + /* watch out for brackets in strings, they do + not count ! + */ + match = ch; + copy(ch); + while (LoadChar(ch), ch != EOI) { + if (ch == match) { + break; + } + + if (ch == '\\') { + copy(ch); + LoadChar(ch); + } + else + if (ch == '\n') { + lexerror("newline in string"); + LineNumber++; + copy(match); + break; + } + + copy(ch); + } + + if (ch == match) { + copy(ch); + break; + } + /* Fall through */ + + case EOI : + lexerror("unterminated macro call"); + return; + + default: + copy(ch); + break; + } + } +} +#endif NOPP diff --git a/lang/cem/cemcom/Files b/lang/cem/cemcom/Files new file mode 100644 index 00000000..13726df5 --- /dev/null +++ b/lang/cem/cemcom/Files @@ -0,0 +1,88 @@ +Files +cem.1 +cem.c +cemcom.1 +Parameters +Makefile +LLlex.c +LLlex.h +LLmessage.c +align.h +alloc.c +alloc.h +arith.c +arith.h +asm.c +assert.h +atw.h +blocks.c +char.tab +ch7.c +ch7bin.c +ch7mon.c +class.h +code.c +code.str +conversion.c +cstoper.c +dataflow.c +declar.g +declarator.c +declar.str +decspecs.c +decspecs.str +def.str +domacro.c +dumpidf.c +error.c +eval.c +expr.c +expr.str +expression.g +faulty.h +field.c +field.str +file_info.h +idf.c +idf.str +init.c +input.c +input.h +interface.h +ival.c +label.c +label.h +level.h +macro.str +main.c +make.allocd +make.hfiles +make.next +make.tokcase +make.tokfile +mcomm.c +mes.h +options +options.c +program.g +replace.c +scan.c +sizes.h +skip.c +specials.h +stack.c +stack.str +statement.g +stb.c +storage.c +storage.h +stmt.str +struct.c +struct.str +switch.c +switch.str +tab.c +tokenname.c +tokenname.h +type.c +type.str diff --git a/lang/cem/cemcom/LintPars b/lang/cem/cemcom/LintPars new file mode 100644 index 00000000..82273bc3 --- /dev/null +++ b/lang/cem/cemcom/LintPars @@ -0,0 +1,146 @@ +!File: lint.h +#define LINT 1 /* if defined, 'lint' is produced */ + + +!File: pathlength.h +#define PATHLENGTH 1024 /* max. length of path to file */ + + +!File: errout.h +#define ERROUT STDERR /* file pointer for writing messages */ +#define ERR_SHADOW 0 /* a syntax error overshadows error messages + until ERR_SHADOW symbols have been + accepted without syntax error */ + + +!File: idfsize.h +#define IDFSIZE 64 /* maximum significant length of an identifier */ + + +!File: numsize.h +#define NUMSIZE 256 /* maximum length of a numeric constant */ + + +!File: nparams.h +#define NPARAMS 32 /* maximum number of parameters of macros */ + + +!File: ifdepth.h +#define IFDEPTH 256 /* maximum number of nested if-constructions */ + + +!File: density.h +#define DENSITY 2 /* see switch.[ch] for an explanation */ + + +!File: lapbuf.h +#define LAPBUF 4096 /* size of macro actual parameter buffer */ + + +!File: strsize.h +#define ISTRSIZE 32 /* minimum number of bytes allocated for + storing a string */ +#define RSTRSIZE 8 /* step size in enlarging the memory for + the storage of a string */ + + +!File: target_sizes.h +#define MAXSIZE 8 /* the maximum of the SZ_* constants */ + +/* target machine sizes */ +#define SZ_CHAR (arith)1 +#define SZ_SHORT (arith)2 +#define SZ_WORD (arith)4 +#define SZ_INT (arith)4 +#define SZ_LONG (arith)4 +#ifndef NOFLOAT +#define SZ_FLOAT (arith)4 +#define SZ_DOUBLE (arith)8 +#endif NOFLOAT +#define SZ_POINTER (arith)4 + +/* target machine alignment requirements */ +#define AL_CHAR 1 +#define AL_SHORT SZ_SHORT +#define AL_WORD SZ_WORD +#define AL_INT SZ_WORD +#define AL_LONG SZ_WORD +#ifndef NOFLOAT +#define AL_FLOAT SZ_WORD +#define AL_DOUBLE SZ_WORD +#endif NOFLOAT +#define AL_POINTER SZ_WORD +#define AL_STRUCT 1 +#define AL_UNION 1 + + +!File: botch_free.h +#undef BOTCH_FREE 1 /* when defined, botch freed memory, as a check */ + + +!File: dataflow.h +#undef DATAFLOW 1 /* produce some compile-time xref */ + + +!File: debug.h +#undef DEBUG 1 /* perform various self-tests */ + + +!File: use_tmp.h +#undef PREPEND_SCOPES 1 /* collect exa, exp, ina and inp commands + and if USE_TMP is defined let them + precede the rest of the generated + compact code */ +#undef USE_TMP 1 /* use C_insertpart, C_endpart mechanism + to generate EM-code in the order needed + for the code-generators. If not defined, + the old-style peephole optimizer is + needed. */ + + +!File: parbufsize.h +#define PARBUFSIZE 1024 + + +!File: textsize.h +#define ITEXTSIZE 8 /* 1st piece of memory for repl. text */ +#define RTEXTSIZE 8 /* stepsize for enlarging repl.text */ + + +!File: inputtype.h +#define INP_READ_IN_ONE 1 /* read input file in one */ + + +!File: nopp.h +#undef NOPP 1 /* if NOT defined, use built-int preprocessor */ + + +!File: nobitfield.h +#undef NOBITFIELD 1 /* if NOT defined, implement bitfields */ + + +!File: spec_arith.h +/* describes internal compiler arithmetics */ +#undef SPECIAL_ARITHMETICS /* something different from native long */ + + +!File: static.h +#define GSTATIC /* for large global "static" arrays */ + + +!File: nofloat.h +#undef NOFLOAT 1 /* if NOT defined, floats are implemented */ + + +!File: noRoption.h +#undef NOROPTION 1 /* if NOT defined, R option is implemented */ + + +!File: nocross.h +#undef NOCROSS 1 /* if NOT defined, cross compiler */ + + +!File: regcount.h +#undef REGCOUNT 1 /* count occurrences for register messages */ + + diff --git a/lang/cem/cemcom/Parameters b/lang/cem/cemcom/Parameters new file mode 100644 index 00000000..226c4471 --- /dev/null +++ b/lang/cem/cemcom/Parameters @@ -0,0 +1,139 @@ +!File: lint.h +#undef LINT 1 /* if defined, 'lint' is produced */ + + +!File: pathlength.h +#define PATHLENGTH 1024 /* max. length of path to file */ + + +!File: errout.h +#define ERROUT STDERR /* file pointer for writing messages */ +#define MAXERR_LINE 5 /* maximum number of error messages given + on the same input line. */ + + +!File: idfsize.h +#define IDFSIZE 64 /* maximum significant length of an identifier */ + + +!File: numsize.h +#define NUMSIZE 256 /* maximum length of a numeric constant */ + + +!File: nparams.h +#define NPARAMS 32 /* maximum number of parameters of macros */ + + +!File: ifdepth.h +#define IFDEPTH 256 /* maximum number of nested if-constructions */ + + +!File: density.h +#define DENSITY 2 /* see switch.[ch] for an explanation */ + + +!File: lapbuf.h +#define LAPBUF 4096 /* size of macro actual parameter buffer */ + + +!File: strsize.h +#define ISTRSIZE 32 /* minimum number of bytes allocated for + storing a string */ +#define RSTRSIZE 8 /* step size in enlarging the memory for + the storage of a string */ + + +!File: target_sizes.h +#define MAXSIZE 8 /* the maximum of the SZ_* constants */ + +/* target machine sizes */ +#define SZ_CHAR (arith)1 +#define SZ_SHORT (arith)2 +#define SZ_WORD (arith)4 +#define SZ_INT (arith)4 +#define SZ_LONG (arith)4 +#ifndef NOFLOAT +#define SZ_FLOAT (arith)4 +#define SZ_DOUBLE (arith)8 +#endif NOFLOAT +#define SZ_POINTER (arith)4 + +/* target machine alignment requirements */ +#define AL_CHAR 1 +#define AL_SHORT SZ_SHORT +#define AL_WORD SZ_WORD +#define AL_INT SZ_WORD +#define AL_LONG SZ_WORD +#ifndef NOFLOAT +#define AL_FLOAT SZ_WORD +#define AL_DOUBLE SZ_WORD +#endif NOFLOAT +#define AL_POINTER SZ_WORD +#define AL_STRUCT 1 +#define AL_UNION 1 + + +!File: botch_free.h +#undef BOTCH_FREE 1 /* when defined, botch freed memory, as a check */ + + +!File: dataflow.h +#define DATAFLOW 1 /* produce some compile-time xref */ + + +!File: debug.h +#undef DEBUG 1 /* perform various self-tests */ + + +!File: use_tmp.h +#define USE_TMP 1 /* collect exa, exp, ina and inp commands + and let them precede the rest of + the generated compact code */ + + +!File: parbufsize.h +#define PARBUFSIZE 1024 + + +!File: textsize.h +#define ITEXTSIZE 8 /* 1st piece of memory for repl. text */ +#define RTEXTSIZE 8 /* stepsize for enlarging repl.text */ + + +!File: inputtype.h +#define INP_READ_IN_ONE 1 /* read input file in one */ + + +!File: nopp.h +#undef NOPP 1 /* if NOT defined, use built-int preprocessor */ + + +!File: nobitfield.h +#undef NOBITFIELD 1 /* if NOT defined, implement bitfields */ + + +!File: spec_arith.h +/* describes internal compiler arithmetics */ +#undef SPECIAL_ARITHMETICS /* something different from native long */ + + +!File: static.h +#define GSTATIC /* for large global "static" arrays */ + + +!File: nofloat.h +#undef NOFLOAT 1 /* if NOT defined, floats are implemented */ + + +!File: noRoption.h +#undef NOROPTION 1 /* if NOT defined, R option is implemented */ + + +!File: nocross.h +#undef NOCROSS 1 /* if NOT defined, cross compiler */ + + +!File: regcount.h +#undef REGCOUNT 1 /* count occurrences for register messages */ + + diff --git a/lang/cem/cemcom/Resolve b/lang/cem/cemcom/Resolve new file mode 100755 index 00000000..acb50f49 --- /dev/null +++ b/lang/cem/cemcom/Resolve @@ -0,0 +1,67 @@ +: create a directory Xsrc with name clashes resolved +: and run make in that directory +: '$Header$' + +case $# in +1) + ;; +*) echo "$0: one argument expected" 1>&2 + exit 1 + ;; +esac +PW=`pwd` +options= +case $1 in +main|emain|lnt) + target=$PW/$1 + ;; +omain) + target=$PW/$1 + options=-DPEEPHOLE + ;; +cemain) + target=$PW/$1 + options=-DCODE_EXPANDER + ;; +Xlint) + target=$1 + ;; +*) echo "$0: $1: Illegal argument" 1>&2 + exit 1 + ;; +esac +if test -d ../Xsrc +then + : +else mkdir ../Xsrc +fi +make EMHOME=$EMHOME longnames +: remove code generating routines from the clashes list as they are defines. +: code generating routine names start with C_ +sed '/^C_/d' < longnames > tmp$$ +cclash -c -l7 tmp$$ > ../Xsrc/Xclashes +rm -f tmp$$ +cd ../Xsrc +if cmp -s Xclashes clashes +then + : +else + mv Xclashes clashes +fi +rm -f Makefile +for i in `cat $PW/Cfiles` +do + cat >> Makefile < $i +EOF +done +make EMHOME=$EMHOME `cat $PW/Cfiles` +rm -f Makefile +ed - $PW/Makefile <<'EOF' +/^#EXCLEXCL/,/^#INCLINCL/d +w Makefile +q +EOF +make EMHOME=$EMHOME COPTIONS=$options MACH=$mach CURRDIR=$PW/ $target diff --git a/lang/cem/cemcom/Version.c b/lang/cem/cemcom/Version.c new file mode 100644 index 00000000..838ce26e --- /dev/null +++ b/lang/cem/cemcom/Version.c @@ -0,0 +1,8 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef lint +static char Version[] = "ACK CEM compiler Version 3.2"; +#endif lint diff --git a/lang/cem/cemcom/alloc.c b/lang/cem/cemcom/alloc.c new file mode 100644 index 00000000..cb431a4b --- /dev/null +++ b/lang/cem/cemcom/alloc.c @@ -0,0 +1,159 @@ +/* $Header$ */ +/* M E M O R Y A L L O C A T I O N R O U T I N E S */ + +/* The allocation of memory in this program, which plays an important + role in reading files, replacing macros and building expression + trees, is not performed by malloc etc. The reason for having own + memory allocation routines (malloc(), realloc() and free()) is + plain: the garbage collection performed by the library functions + malloc(), realloc() and free() costs a lot of time, while in most + cases (on a VAX) the freeing and reallocation of memory is not + necessary. The only reallocation done in this program is at + building strings in memory. This means that the last + (re-)allocated piece of memory can be extended. + + The (basic) memory allocating routines offered by this memory + handling package are: + + char *malloc(n) : allocate n bytes + char *realloc(ptr, n) : reallocate buffer to n bytes + (works only if ptr was last allocated) + free(ptr) : if ptr points to last allocated + memory, this memory is re-allocatable + Salloc(str, sz) : save string in malloc storage +*/ + +#include +#include "myalloc.h" /* UF */ +#include "debug.h" /* UF */ + +#include "alloc.h" +#include "assert.h" + +#ifdef OWNALLOC +char *sys_break(); +/* the following variables are used for book-keeping */ +static int nfreebytes = 0; /* # free bytes in sys_break space */ +static char *freeb; /* pointer to first free byte */ +static char *lastalloc; /* pointer to last malloced sp */ +static int lastnbytes; /* nr of bytes in last allocated */ + /* space */ +static char *firstfreeb = 0; + +#endif OWNALLOC + +char * +Salloc(str, sz) + register char str[]; + register int sz; +{ + /* Salloc() is not a primitive function: it just allocates a + piece of storage and copies a given string into it. + */ + char *res = Malloc(sz); + register char *m = res; + + while (sz--) + *m++ = *str++; + return res; +} + +#ifdef OWNALLOC + +#define ALIGN(m) (ALIGNSIZE * (((m) - 1) / ALIGNSIZE + 1)) + +char * +malloc(n) + unsigned n; +{ + /* malloc() is a very simple malloc(). + */ + n = ALIGN(n); + if (nfreebytes < n) { + register nbts = (n <= ALLOCSIZ) ? ALLOCSIZ : n; + + if (!nfreebytes) { + if ((freeb = sys_break(nbts)) == ILL_BREAK) + fatal("out of memory"); + } + else { + if (sys_break(nbts) == ILL_BREAK) + fatal("out of memory"); + } + nfreebytes += nbts; + } + lastalloc = freeb; + freeb = lastalloc + n; + lastnbytes = n; + nfreebytes -= n; + return lastalloc; +} + +/*ARGSUSED*/ +char * +realloc(ptr, n) + char *ptr; + unsigned n; +{ + /* realloc() is designed to append more bytes to the latest + allocated piece of memory. However reallocation should be + performed, even if the mentioned memory is not the latest + allocated one, this situation will not occur. To do so, + realloc should know how many bytes are allocated the last + time for that piece of memory. ???? + */ + register int nbytes = n; + + ASSERT(ptr == lastalloc); /* security */ + nbytes -= lastnbytes; /* # bytes required */ + if (nbytes == 0) /* no extra bytes */ + return lastalloc; + + /* if nbytes < 0: free last allocated bytes; + if nbytes > 0: allocate more bytes + */ + if (nbytes > 0) + nbytes = ALIGN(nbytes); + if (nfreebytes < nbytes) { + register int nbts = (nbytes < ALLOCSIZ) ? ALLOCSIZ : nbytes; + if (sys_break(nbts) == ILL_BREAK) + fatal("out of memory"); + nfreebytes += nbts; + } + freeb += nbytes; /* less bytes */ + lastnbytes += nbytes; /* change nr of last all. bytes */ + nfreebytes -= nbytes; /* less or more free bytes */ + return lastalloc; +} + +/* to ensure that the alloc library package will not be loaded: */ +/*ARGSUSED*/ +free(p) + char *p; +{} + +init_mem() +{ + firstfreeb = sys_break(0); + /* align the first memory unit to ALIGNSIZE ??? */ + if ((long) firstfreeb % ALIGNSIZE != 0) { + register char *fb = firstfreeb; + + fb = (char *)ALIGN((long)fb); + firstfreeb = sys_break(fb - firstfreeb); + firstfreeb = fb; + ASSERT((long)firstfreeb % ALIGNSIZE == 0); + } +} + +#ifdef DEBUG +mem_stat() +{ + extern char options[]; + + if (options['m']) + print("Total nr of bytes allocated: %d\n", + sys_break(0) - firstfreeb); +} +#endif DEBUG +#endif OWNALLOC diff --git a/lang/cem/cemcom/alloc.h b/lang/cem/cemcom/alloc.h new file mode 100644 index 00000000..a6bafae4 --- /dev/null +++ b/lang/cem/cemcom/alloc.h @@ -0,0 +1,16 @@ +/* $Header$ */ +/* PROGRAM'S INTERFACE TO MEMORY ALLOCATION ROUTINES */ + +/* This file serves as the interface between the program and the + memory allocating routines. + There are 3 memory allocation routines: + char *Malloc(n) to allocate n bytes + char *Salloc(str, n) to allocate n bytes + and fill them with string str + char *Realloc(str, n) reallocate the string at str to n bytes +*/ + +extern char *Salloc(), *malloc(), *realloc(); + +#define Malloc(n) malloc((unsigned)(n)) +#define Srealloc(ptr,n) realloc(ptr, (unsigned)(n)) diff --git a/lang/cem/cemcom/code.h b/lang/cem/cemcom/code.h new file mode 100644 index 00000000..3399b3e0 --- /dev/null +++ b/lang/cem/cemcom/code.h @@ -0,0 +1,23 @@ +/* $Header$ */ +/* C O D E - G E N E R A T O R D E F I N I T I O N S */ + +struct stat_block { + struct stat_block *next; + label st_break; + label st_continue; +}; + + +/* allocation definitions of struct stat_block */ +/* ALLOCDEF "stat_block" */ +extern char *st_alloc(); +extern struct stat_block *h_stat_block; +#define new_stat_block() ((struct stat_block *) \ + st_alloc((char **)&h_stat_block, sizeof(struct stat_block))) +#define free_stat_block(p) st_free(p, h_stat_block, sizeof(struct stat_block)) + + +#define LVAL 0 +#define RVAL 1 +#define FALSE 0 +#define TRUE 1 diff --git a/lang/cem/cemcom/declarator.h b/lang/cem/cemcom/declarator.h new file mode 100644 index 00000000..5ecbb70c --- /dev/null +++ b/lang/cem/cemcom/declarator.h @@ -0,0 +1,45 @@ +/* $Header$ */ +/* DEFINITION OF DECLARATOR DESCRIPTORS */ + +/* A 'declarator' consists of an idf and a linked list of + language-defined unary operations: *, [] and (), called + decl_unary's. +*/ + +struct declarator { + struct declarator *next; + struct idf *dc_idf; + struct decl_unary *dc_decl_unary; + struct idstack_item *dc_fparams; /* params for function */ +}; + + +/* allocation definitions of struct declarator */ +/* ALLOCDEF "declarator" */ +extern char *st_alloc(); +extern struct declarator *h_declarator; +#define new_declarator() ((struct declarator *) \ + st_alloc((char **)&h_declarator, sizeof(struct declarator))) +#define free_declarator(p) st_free(p, h_declarator, sizeof(struct declarator)) + + +#define NO_PARAMS ((struct idstack_item *) 0) + +struct decl_unary { + struct decl_unary *next; + int du_fund; /* POINTER, ARRAY or FUNCTION */ + arith du_count; /* for ARRAYs only */ +}; + + +/* allocation definitions of struct decl_unary */ +/* ALLOCDEF "decl_unary" */ +extern char *st_alloc(); +extern struct decl_unary *h_decl_unary; +#define new_decl_unary() ((struct decl_unary *) \ + st_alloc((char **)&h_decl_unary, sizeof(struct decl_unary))) +#define free_decl_unary(p) st_free(p, h_decl_unary, sizeof(struct decl_unary)) + + +extern struct type *declare_type(); +extern struct declarator null_declarator; diff --git a/lang/cem/cemcom/decspecs.h b/lang/cem/cemcom/decspecs.h new file mode 100644 index 00000000..0b1598c0 --- /dev/null +++ b/lang/cem/cemcom/decspecs.h @@ -0,0 +1,23 @@ +/* $Header$ */ +/* DECLARATION SPECIFIER DEFINITION */ + +struct decspecs { + struct decspecs *next; + struct type *ds_type; /* single type */ + int ds_sc_given; /* 1 if the st. class is explicitly given */ + int ds_sc; /* storage class, given or implied */ + int ds_size; /* LONG, SHORT or 0 */ + int ds_unsigned; /* 0 or 1 */ +}; + + +/* allocation definitions of struct decspecs */ +/* ALLOCDEF "decspecs" */ +extern char *st_alloc(); +extern struct decspecs *h_decspecs; +#define new_decspecs() ((struct decspecs *) \ + st_alloc((char **)&h_decspecs, sizeof(struct decspecs))) +#define free_decspecs(p) st_free(p, h_decspecs, sizeof(struct decspecs)) + + +extern struct decspecs null_decspecs; diff --git a/lang/cem/cemcom/def.h b/lang/cem/cemcom/def.h new file mode 100644 index 00000000..abb28155 --- /dev/null +++ b/lang/cem/cemcom/def.h @@ -0,0 +1,37 @@ +/* $Header$ */ +/* IDENTIFIER DEFINITION DESCRIPTOR */ + +struct def { /* for ordinary tags */ + struct def *next; + int df_level; + struct type *df_type; + int df_sc; /* may be: + GLOBAL, STATIC, EXTERN, IMPLICIT, + TYPEDEF, + FORMAL, AUTO, + ENUM, LABEL + */ + int df_register; /* REG_NONE, REG_DEFAULT or REG_BONUS */ + char df_initialized; /* an initialization has been generated */ + char df_alloc; /* 0, ALLOC_SEEN or ALLOC_DONE */ + char df_used; /* set if idf is used */ + char df_formal_array; /* to warn if sizeof is taken */ + arith df_address; +}; + +#define ALLOC_SEEN 1 /* an allocating declaration has been seen */ +#define ALLOC_DONE 2 /* the allocating declaration has been done */ + +#define REG_NONE 0 /* no register candidate */ +#define REG_DEFAULT 1 /* register candidate, not declared as such */ +#define REG_BONUS 10 /* register candidate, declared as such */ + + +/* allocation definitions of struct def */ +/* ALLOCDEF "def" */ +extern char *st_alloc(); +extern struct def *h_def; +#define new_def() ((struct def *) \ + st_alloc((char **)&h_def, sizeof(struct def))) +#define free_def(p) st_free(p, h_def, sizeof(struct def)) + diff --git a/lang/cem/cemcom/doprnt.c b/lang/cem/cemcom/doprnt.c new file mode 100644 index 00000000..9cdc126f --- /dev/null +++ b/lang/cem/cemcom/doprnt.c @@ -0,0 +1,144 @@ +/* $Header$ */ +/* STRING MANIPULATION AND PRINT ROUTINES */ + +#include +#include "ssize.h" + +char *long2str(); + +static +integral(c) +{ + switch (c) { + case 'b': + return -2; + case 'd': + return 10; + case 'o': + return -8; + case 'u': + return -10; + case 'x': + return -16; + } + return 0; +} + +static int +format(buf, fmt, argp) + char *buf, *fmt; + char *argp; +{ + register char *pf = fmt, *pa = argp; + register char *pb = buf; + + while (*pf) { + if (*pf == '%') { + register width, base, pad, npad; + char *arg; + char cbuf[2]; + char *badformat = ""; + + /* get padder */ + if (*++pf == '0') { + pad = '0'; + ++pf; + } + else + pad = ' '; + + /* get width */ + width = 0; + while (*pf >= '0' && *pf <= '9') + width = 10 * width + *pf++ - '0'; + + /* get text and move pa */ + if (*pf == 's') { + arg = *(char **)pa; + pa += sizeof(char *); + } + else + if (*pf == 'c') { + cbuf[0] = * (char *) pa; + cbuf[1] = '\0'; + pa += sizeof(int); + arg = &cbuf[0]; + } + else + if (*pf == 'l') { + /* alignment ??? */ + if (base = integral(*++pf)) { + arg = long2str(*(long *)pa, base); + pa += sizeof(long); + } + else { + pf--; + arg = badformat; + } + } + else + if (base = integral(*pf)) { + arg = long2str((long)*(int *)pa, base); + pa += sizeof(int); + } + else + if (*pf == '%') + arg = "%"; + else + arg = badformat; + + npad = width - strlen(arg); + + while (npad-- > 0) + *pb++ = pad; + + while (*pb++ = *arg++); + pb--; + pf++; + } + else + *pb++ = *pf++; + } + return pb - buf; +} + +doprnt(fp, fmt, argp) + File *fp; + char *fmt; + int argp[]; +{ + char buf[SSIZE]; + + sys_write(fp, buf, format(buf, fmt, (char *)argp)); +} + +/*VARARGS1*/ +printf(fmt, args) + char *fmt; + char args; +{ + char buf[SSIZE]; + + sys_write(STDOUT, buf, format(buf, fmt, &args)); +} + +/*VARARGS1*/ +fprintf(fp, fmt, args) + File *fp; + char *fmt; + char args; +{ + char buf[SSIZE]; + + sys_write(fp, buf, format(buf, fmt, &args)); +} + +/*VARARGS1*/ +char * +sprintf(buf, fmt, args) + char *buf, *fmt; + char args; +{ + buf[format(buf, fmt, &args)] = '\0'; + return buf; +} diff --git a/lang/cem/cemcom/em.c b/lang/cem/cemcom/em.c new file mode 100644 index 00000000..7bd0bd10 --- /dev/null +++ b/lang/cem/cemcom/em.c @@ -0,0 +1,201 @@ +/* $Header$ */ +/* EM CODE OUTPUT ROUTINES */ + +#define CMODE 0644 +#define MAX_ARG_CNT 32 + +#include "em.h" +#include +#include "arith.h" +#include "label.h" + +/* + putbyte(), C_open() and C_close() are the basic routines for + respectively write on, open and close the output file. + The put_*() functions serve as formatting functions of the + various EM language constructs. + See "Description of a Machine Architecture for use with + Block Structured Languages" par. 11.2 for the meaning of these + names. +*/ + +/* supply a kind of buffered output */ +#define flush(x) sys_write(ofp, &obuf[0], x) + +static char obuf[BUFSIZ]; +static char *opp = &obuf[0]; +File *ofp = 0; + +putbyte(b) /* shouldn't putbyte() be a macro ??? (EB) */ + int b; +{ + if (opp >= &obuf[BUFSIZ]) { /* flush if buffer overflows */ + if (flush(BUFSIZ) == 0) + sys_stop(S_ABORT); + opp = &obuf[0]; + } + *opp++ = (char) b; +} + +C_init(wsize, psize) + arith wsize, psize; +{} + +C_open(nm) /* open file for compact code output */ + char *nm; +{ + if (nm == 0) + ofp = STDOUT; /* standard output */ + else + if (sys_open(nm, OP_WRITE, &ofp) == 0) + return 0; + return 1; +} + +C_close() +{ + if (flush(opp - &obuf[0]) == 0) + sys_stop(S_ABORT); + opp = obuf; /* reset opp */ + if (ofp != STDOUT) + sys_close(ofp); + ofp = 0; +} + +C_busy() +{ + return ofp != 0; /* true if code is being generated */ +} + +/*** the compact code generating routines ***/ +#define fit16i(x) ((x) >= (long)0xFFFF8000 && (x) <= (long)0x00007FFF) +#define fit8u(x) ((x) <= 0xFF) /* x is already unsigned */ + +put_ilb(l) + label l; +{ + if (fit8u(l)) { + put8(sp_ilb1); + put8((int)l); + } + else { + put8(sp_ilb2); + put16(l); + } +} + +put_dlb(l) + label l; +{ + if (fit8u(l)) { + put8(sp_dlb1); + put8((int)l); + } + else { + put8(sp_dlb2); + put16(l); + } +} + +put_cst(l) + arith l; +{ + if (l >= (arith) -sp_zcst0 && l < (arith) (sp_ncst0 - sp_zcst0)) { + /* we can convert 'l' to an int because its value + can be stored in a byte. + */ + put8((int) l + (sp_zcst0 + sp_fcst0)); + } + else + if (fit16i(l)) { /* the cast from long to int causes no trouble here */ + put8(sp_cst2); + put16((int) l); + } + else { + put8(sp_cst4); + put32(l); + } +} + +put_doff(l, v) + label l; + arith v; +{ + if (v == 0) + put_dlb(l); + else { + put8(sp_doff); + put_dlb(l); + put_cst(v); + } +} + +put_noff(s, v) + char *s; + arith v; +{ + if (v == 0) + put_dnam(s); + else { + put8(sp_doff); + put_dnam(s); + put_cst(v); + } +} + +put_dnam(s) + char *s; +{ + put8(sp_dnam); + put_str(s); +} + +put_pnam(s) + char *s; +{ + put8(sp_pnam); + put_str(s); +} + +#ifdef ____ +put_fcon(s, sz) + char *s; + arith sz; +{ + put8(sp_fcon); + put_cst(sz); + put_str(s); +} +#endif ____ + +put_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */ + int sp; + char *v; + arith sz; +{ + /* how 'bout signextension int --> long ??? */ + put8(sp); + put_cst(sz); + put_str(v); +} + +put_str(s) + char *s; +{ + register int len; + + put_cst((arith) (len = strlen(s))); + while (--len >= 0) + put8(*s++); +} + +put_cstr(s) + char *s; +{ + register int len = prepare_string(s); + + put8(sp_scon); + put_cst((arith) len); + while (--len >= 0) + put8(*s++); +} diff --git a/lang/cem/cemcom/em.h b/lang/cem/cemcom/em.h new file mode 100644 index 00000000..7d9de789 --- /dev/null +++ b/lang/cem/cemcom/em.h @@ -0,0 +1,42 @@ +/* $Header$ */ +/* DESCRIPTION OF INTERFACE TO EM CODE GENERATING ROUTINES */ + +#include "proc_intf.h" /* use macros or functions */ + +/* include the EM description files */ +#include +#include +#include +#include +#include + +/* macros used in the definitions of the interface functions C_* */ +#define OP(x) put_op(x) +#define CST(x) put_cst(x) +#define DCST(x) put_cst(x) +#define CSTR(x) put_cstr(x) +#define PS(x) put_ps(x) +#define DLB(x) put_dlb(x) +#define ILB(x) put_ilb(x) +#define NOFF(x,y) put_noff((x), (y)) +#define DOFF(x,y) put_doff((x), (y)) +#define PNAM(x) put_pnam(x) +#define DNAM(x) put_dnam(x) +#define CEND() put_cend() +#define WCON(x,y,z) put_wcon((x), (y), (z)) +#define FCON(x,y) put_fcon((x), (y)) + +/* variants of primitive "putbyte" */ +#define put8(x) putbyte(x) /* defined in "em.c" */ +#define put16(x) (put8((int) x), put8((int) (x >> 8))) +#define put32(x) (put16((int) x), put16((int) (x >> 16))) +#define put_cend() put8(sp_cend) +#define put_op(x) put8(x) +#define put_ps(x) put8(x) + +/* user interface */ +#define C_magic() put16(sp_magic) /* EM magic word */ + +#ifndef PROC_INTF +#include "writeem.h" +#endif PROC_INTF diff --git a/lang/cem/cemcom/em_lint.h b/lang/cem/cemcom/em_lint.h new file mode 100644 index 00000000..470c5922 --- /dev/null +++ b/lang/cem/cemcom/em_lint.h @@ -0,0 +1,71 @@ +/* + * (c) copyright 1990 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +/* + * This file can be considered the em_code.h file of lint. + * Those code generating functions that are used by cem and that have not + * been defined away by #ifdef LINT, are defined away here. Note that this a + * fairly random collection. E.g. it does not include C_open(), since the + * standard C-open() C_close() sequence is protected by #ifdef LINT, but it + * does include C_close() since the latter is also called in other places, + * to terminate the compilation process. + */ + +#define C_asp(c) +#define C_bra(b) +#define C_cal(p) +#define C_csa(w) +#define C_csb(w) +#define C_fil_dlb(g,o) +#define C_lae_dlb(g,o) +#define C_lal(c) +#define C_lin(c) +#define C_loi(c) +#define C_lol(c) +#define C_sdl(c) +#define C_sti(c) +#define C_stl(c) + +#define C_busy() 0 +#define C_close() + +#define C_df_dlb(l) +#define C_df_dnam(s) +#define C_df_ilb(l) + +#define C_pro_narg(s) +#define C_end(l) + +#define C_exa_dnam(s) +#define C_ina_dnam(s) +#define C_ina_dlb(l) +#define C_exp(s) +#define C_inp(s) + +#define C_bss_cst(n,w,i) + +#define C_con_cst(v) +#define C_con_icon(v,s) +#define C_con_ucon(v,s) +#define C_con_fcon(v,s) +#define C_con_scon(v,s) +#define C_con_dnam(v,s) +#define C_con_dlb(v,s) +#define C_con_pnam(v) + +#define C_rom_cst(v) +#define C_rom_scon(v,s) +#define C_rom_ilb(v) + +#define C_ldl(l) + +#define C_mes_begin(ms) +#define C_mes_end() + +#define C_ms_gto() +#define C_ms_par(b) +#define C_ms_reg(o,s,t,c) + diff --git a/lang/cem/cemcom/emcode.def b/lang/cem/cemcom/emcode.def new file mode 100644 index 00000000..0e27dcc5 --- /dev/null +++ b/lang/cem/cemcom/emcode.def @@ -0,0 +1,136 @@ +% emcode definitions for the CEM compiler -- intermediate code +C_adf(p) | arith p; | OP(op_adf), CST(p) +C_adi(p) | arith p; | OP(op_adi), CST(p) +C_adp(p) | arith p; | OP(op_adp), CST(p) +C_ads(p) | arith p; | OP(op_ads), CST(p) +C_adu(p) | arith p; | OP(op_adu), CST(p) +C_and(p) | arith p; | OP(op_and), CST(p) +C_asp(p) | arith p; | OP(op_asp), CST(p) +C_bra(l) | label l; | OP(op_bra), CST((arith)l) +C_cai() | | OP(op_cai) +C_cal(p) | char *p; | OP(op_cal), PNAM(p) +C_cff() | | OP(op_cff) +C_cfi() | | OP(op_cfi) +C_cfu() | | OP(op_cfu) +C_cif() | | OP(op_cif) +C_cii() | | OP(op_cii) +C_ciu() | | OP(op_ciu) +C_cmf(p) | arith p; | OP(op_cmf), CST(p) +C_cmi(p) | arith p; | OP(op_cmi), CST(p) +C_cmp() | | OP(op_cmp) +C_cmu(p) | arith p; | OP(op_cmu), CST(p) +C_com(p) | arith p; | OP(op_com), CST(p) +C_csa(p) | arith p; | OP(op_csa), CST(p) +C_csb(p) | arith p; | OP(op_csb), CST(p) +C_cuf() | | OP(op_cuf) +C_cui() | | OP(op_cui) +C_cuu() | | OP(op_cuu) +C_dup(p) | arith p; | OP(op_dup), CST(p) +C_dvf(p) | arith p; | OP(op_dvf), CST(p) +C_dvi(p) | arith p; | OP(op_dvi), CST(p) +C_dvu(p) | arith p; | OP(op_dvu), CST(p) +C_fil_dlb(l, o) | label l; arith o; | OP(op_fil), DOFF(l, o) +C_ior(p) | arith p; | OP(op_ior), CST(p) +C_lae_dnam(p, o) | char *p; arith o; | OP(op_lae), NOFF(p, o) +C_lae_dlb(l, o) | label l; arith o; | OP(op_lae), DOFF(l, o) +C_lal(p) | arith p; | OP(op_lal), CST(p) +C_ldc(p) | arith p; | OP(op_ldc), DCST(p) +C_lde_dnam(p, o) | char *p; arith o; | OP(op_lde), NOFF(p, o) +C_lde_dlb(l, o) | label l; arith o; | OP(op_lde), DOFF(l, o) +C_ldl(p) | arith p; | OP(op_ldl), CST(p) +C_lfr(p) | arith p; | OP(op_lfr), CST(p) +C_lin(p) | arith p; | OP(op_lin), CST(p) +C_loc(p) | arith p; | OP(op_loc), CST(p) +C_loe_dnam(p, o) | char *p; arith o; | OP(op_loe), NOFF(p, o) +C_loe_dlb(l, o) | label l; arith o; | OP(op_loe), DOFF(l, o) +C_loi(p) | arith p; | OP(op_loi), CST(p) +C_lol(p) | arith p; | OP(op_lol), CST(p) +C_lor(p) | arith p; | OP(op_lor), CST(p) +C_lpi(p) | char *p; | OP(op_lpi), PNAM(p) +C_mlf(p) | arith p; | OP(op_mlf), CST(p) +C_mli(p) | arith p; | OP(op_mli), CST(p) +C_mlu(p) | arith p; | OP(op_mlu), CST(p) +C_ngf(p) | arith p; | OP(op_ngf), CST(p) +C_ngi(p) | arith p; | OP(op_ngi), CST(p) +C_ret(p) | arith p; | OP(op_ret), CST(p) +C_rmi(p) | arith p; | OP(op_rmi), CST(p) +C_rmu(p) | arith p; | OP(op_rmu), CST(p) +C_sbf(p) | arith p; | OP(op_sbf), CST(p) +C_sbi(p) | arith p; | OP(op_sbi), CST(p) +C_sbs(p) | arith p; | OP(op_sbs), CST(p) +C_sbu(p) | arith p; | OP(op_sbu), CST(p) +C_sde_dnam(p, o) | char *p; arith o; | OP(op_sde), NOFF(p, o) +C_sde_dlb(l, o) | label l; arith o; | OP(op_sde), DOFF(l, o) +C_sdl(p) | arith p; | OP(op_sdl), CST(p) +C_sli(p) | arith p; | OP(op_sli), CST(p) +C_slu(p) | arith p; | OP(op_slu), CST(p) +C_sri(p) | arith p; | OP(op_sri), CST(p) +C_sru(p) | arith p; | OP(op_sru), CST(p) +C_ste_dnam(p, o) | char *p; arith o; | OP(op_ste), NOFF(p, o) +C_ste_dlb(l, o) | label l; arith o; | OP(op_ste), DOFF(l, o) +C_sti(p) | arith p; | OP(op_sti), CST(p) +C_stl(p) | arith p; | OP(op_stl), CST(p) +C_xor(p) | arith p; | OP(op_xor), CST(p) +C_zeq(l) | label l; | OP(op_zeq), CST((arith)l) +C_zge(l) | label l; | OP(op_zge), CST((arith)l) +C_zgt(l) | label l; | OP(op_zgt), CST((arith)l) +C_zle(l) | label l; | OP(op_zle), CST((arith)l) +C_zlt(l) | label l; | OP(op_zlt), CST((arith)l) +C_zne(l) | label l; | OP(op_zne), CST((arith)l) +% +C_df_dlb(l) | label l; | DLB(l) +C_df_dnam(s) | char *s; | DNAM(s) +C_df_ilb(l) | label l; | ILB(l) +% +C_bss_cst(n, w, i) | arith n, w; int i; | + PS(ps_bss), DCST(n), CST(w), CST((arith)i) +% +C_con_icon(val, siz) | char *val; arith siz; | + PS(ps_con), WCON(sp_icon, val, siz), CEND() +C_con_ucon(val, siz) | char *val; arith siz; | + PS(ps_con), WCON(sp_ucon, val, siz), CEND() +C_con_fcon(val, siz) | char *val; arith siz; | + PS(ps_con), WCON(sp_fcon, val, siz), CEND() +C_con_scon(str, siz) | char *str; arith siz; | PS(ps_con), CSTR(str), CEND() +C_con_dnam(str, val) | char *str; arith val; | + PS(ps_con), NOFF(str, val), CEND() +C_con_dlb(l, val) | label l; arith val; | + PS(ps_con), DOFF(l, val), CEND() +C_con_pnam(str) | char *str; | PS(ps_con), PNAM(str), CEND() +% +C_rom_cst(l) | arith l; | PS(ps_rom), CST(l), CEND() +C_rom_icon(val, siz) | char *val; arith siz; | + PS(ps_rom), WCON(sp_icon, val, siz), CEND() +C_rom_fcon(val, siz) | char *val; arith siz; | + PS(ps_rom), WCON(sp_fcon, val, siz), CEND() +C_rom_ilb(l) | label l; | PS(ps_rom), ILB(l), CEND() +% +C_cst(l) | arith l; | CST(l) +C_icon(val, siz) | char *val; arith siz; | WCON(sp_icon, val, siz) +C_ucon(val, siz) | char *val; arith siz; | WCON(sp_ucon, val, siz) +C_fcon(val, siz) | char *val; arith siz; | WCON(sp_fcon, val, siz) +C_scon(str, siz) | char *str; arith siz; | CSTR(str) +C_dnam(str, val) | char *str; arith val; | NOFF(str, val) +C_dlb(l, val) | label l; arith val; | DOFF(l, val) +C_pnam(str) | char *str; | PNAM(str) +C_ilb(l) | label l; | ILB(l) +% +C_pro_narg(p1) | char *p1; | PS(ps_pro), PNAM(p1), CEND() +C_end(l) | arith l; | PS(ps_end), CST(l) +% +C_exa(s) | char *s; | PS(ps_exa), DNAM(s) +C_exp(s) | char *s; | PS(ps_exp), PNAM(s) +C_ina_pt(l) | label l; | PS(ps_ina), DLB(l) +C_ina(s) | char *s; | PS(ps_ina), DNAM(s) +C_inp(s) | char *s; | PS(ps_inp), PNAM(s) +% +C_ms_err() | | PS(ps_mes), CST((arith)ms_err), CEND() +C_ms_emx(p1, p2) | arith p1, p2; | + PS(ps_mes), CST((arith)ms_emx), CST(p1), CST(p2), CEND() +C_ms_reg(a, b, c, d) | arith a, b; int c, d; | + PS(ps_mes), CST((arith)ms_reg), CST(a), CST(b), CST((arith)c), CST((arith)d), CEND() +C_ms_src(l, s) | arith l; char *s; | + PS(ps_mes), CST((arith)ms_src), CST(l), CSTR(s), CEND() +C_ms_flt() | | PS(ps_mes), CST((arith)ms_flt), CEND() +C_ms_par(l) | arith l; | PS(ps_mes), CST((arith)ms_par), CST(l), CEND() +C_ms_gto() | | PS(ps_mes), CST((arith)ms_gto), CEND() diff --git a/lang/cem/cemcom/expr.h b/lang/cem/cemcom/expr.h new file mode 100644 index 00000000..46e658a0 --- /dev/null +++ b/lang/cem/cemcom/expr.h @@ -0,0 +1,102 @@ +/* $Header$ */ +/* EXPRESSION DESCRIPTOR */ + +/* What we want to define is the struct expr, but since it contains + a union of various goodies, we define them first; so be patient. +*/ + +struct value { + struct idf *vl_idf; /* idf of an external name or 0 */ + arith vl_value; /* constant, or offset if idf != 0 */ +}; + +struct string { + char *sg_value; /* string of characters repr. the constant */ + label sg_datlab; /* global data-label */ +}; + +struct floating { + char *fl_value; /* pointer to string repr. the fp const. */ + label fl_datlab; /* global data_label */ +}; + +struct oper { + struct type *op_type; /* resulting type of the operation */ + struct expr *op_left; + int op_oper; /* the symbol of the operator */ + struct expr *op_right; +}; + +/* The following constants indicate the class of the expression: */ +#define Value 0 /* it is a value known at load time */ +#define String 1 /* it is a string constant */ +#define Float 2 /* it is a floating point constant */ +#define Oper 3 /* it is a run-time expression */ +#define Type 4 /* only its type is relevant */ + +struct expr { + struct expr *next; + char *ex_file; /* the file it (probably) comes from */ + unsigned int ex_line; /* the line it (probably) comes from */ + struct type *ex_type; + char ex_lvalue; + char ex_flags; + int ex_class; + int ex_depth; + union { + struct value ex_value; + struct string ex_string; + struct floating ex_float; + struct oper ex_oper; + } ex_object; +}; + +/* some abbreviated selections */ +#define VL_VALUE ex_object.ex_value.vl_value +#define VL_IDF ex_object.ex_value.vl_idf +#define SG_VALUE ex_object.ex_string.sg_value +#define SG_DATLAB ex_object.ex_string.sg_datlab +#define FL_VALUE ex_object.ex_float.fl_value +#define FL_DATLAB ex_object.ex_float.fl_datlab +#define OP_TYPE ex_object.ex_oper.op_type +#define OP_LEFT ex_object.ex_oper.op_left +#define OP_OPER ex_object.ex_oper.op_oper +#define OP_RIGHT ex_object.ex_oper.op_right + +#define EXPRTYPE(e) ((e)->ex_type->tp_fund) + +/* An expression is a `load-time constant' if it is of the form + +/- or ; + it is a `compile-time constant' if it is an . +*/ +#define is_ld_cst(e) ((e)->ex_lvalue == 0 && (e)->ex_class == Value) +#define is_cp_cst(e) (is_ld_cst(e) && (e)->VL_IDF == 0) + +/* a floating constant expression ? +*/ +#define is_fp_cst(e) ((e)->ex_class == Float) + +/* some bits for the ex_flag field, to keep track of various + interesting properties of an expression. +*/ +#define EX_SIZEOF 001 /* contains sizeof operator */ +#define EX_CAST 002 /* contains cast */ +#define EX_LOGICAL 004 /* contains logical operator */ +#define EX_COMMA 010 /* contains expression comma */ +#define EX_PARENS 020 /* the top level is parenthesized */ + +#define NILEXPR ((struct expr *)0) + +extern struct expr *intexpr(), *new_oper(); + + +/* allocation definitions of struct expr */ +/* ALLOCDEF "expr" */ +extern char *st_alloc(); +extern struct expr *h_expr; +#define new_expr() ((struct expr *) \ + st_alloc((char **)&h_expr, sizeof(struct expr))) +#define free_expr(p) st_free(p, h_expr, sizeof(struct expr)) + + +#define ISCOMMA(e) ((e)->ex_class == Oper && (e)->OP_OPER == INITCOMMA) diff --git a/lang/cem/cemcom/faulty.h b/lang/cem/cemcom/faulty.h new file mode 100644 index 00000000..9b3b13d7 --- /dev/null +++ b/lang/cem/cemcom/faulty.h @@ -0,0 +1,9 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ +/* FAULTY DEFINITIONS */ + +#define faulty(tp) ((tp)_faulty(__FILE__, __LINE__)) +#define fault() (_faulty(__FILE__, __LINE__)) diff --git a/lang/cem/cemcom/field.h b/lang/cem/cemcom/field.h new file mode 100644 index 00000000..794920b6 --- /dev/null +++ b/lang/cem/cemcom/field.h @@ -0,0 +1,20 @@ +/* $Header$ */ +/* FIELD DESCRIPTOR */ + +struct field { /* for field specifiers */ + struct field *next; + arith fd_mask; + int fd_shift; + int fd_width; + struct sdef *fd_sdef; /* upward pointer */ +}; + + +/* allocation definitions of struct field */ +/* ALLOCDEF "field" */ +extern char *st_alloc(); +extern struct field *h_field; +#define new_field() ((struct field *) \ + st_alloc((char **)&h_field, sizeof(struct field))) +#define free_field(p) st_free(p, h_field, sizeof(struct field)) + diff --git a/lang/cem/cemcom/idf.h b/lang/cem/cemcom/idf.h new file mode 100644 index 00000000..12496de1 --- /dev/null +++ b/lang/cem/cemcom/idf.h @@ -0,0 +1,68 @@ +/* $Header$ */ +/* IDENTIFIER DESCRIPTOR */ + +#include "nopp.h" + +/* Since the % operation in the calculation of the hash function + turns out to be expensive, it is replaced by the cheaper XOR (^). + Each character of the identifier is xored with an 8-bit mask which + depends on the position of the character; the sum of these results + is the hash value. The random masks are obtained from a + congruence generator in idf.c. +*/ + +#define HASHSIZE 256 /* must be a power of 2 */ +#define HASH_X 0253 /* Knuth's X */ +#define HASH_A 77 /* Knuth's a */ +#define HASH_C 153 /* Knuth's c */ + +extern char hmask[]; /* the random masks */ +#define HASHMASK (HASHSIZE-1) /* since it is a power of 2 */ +#define STARTHASH() (0) +#define ENHASH(hs,ch,ps) (hs + (ch ^ hmask[ps])) +#define STOPHASH(hs) (hs & HASHMASK) + +struct idstack_item { /* stack of identifiers */ + struct idstack_item *next; + struct idf *is_idf; +}; + + +/* allocation definitions of struct idstack_item */ +/* ALLOCDEF "idstack_item" */ +extern char *st_alloc(); +extern struct idstack_item *h_idstack_item; +#define new_idstack_item() ((struct idstack_item *) \ + st_alloc((char **)&h_idstack_item, sizeof(struct idstack_item))) +#define free_idstack_item(p) st_free(p, h_idstack_item, sizeof(struct idstack_item)) + + +struct idf { + struct idf *next; + char *id_text; +#ifndef NOPP + struct macro *id_macro; + int id_resmac; /* if nonzero: keyword of macroproc. */ +#endif NOPP + int id_reserved; /* non-zero for reserved words */ + struct def *id_def; /* variables, typedefs, enum-constants */ + struct sdef *id_sdef; /* selector tags */ + struct tag *id_struct; /* struct and union tags */ + struct tag *id_enum; /* enum tags */ + int id_special; /* special action needed at occurrence */ +}; + + +/* allocation definitions of struct idf */ +/* ALLOCDEF "idf" */ +extern char *st_alloc(); +extern struct idf *h_idf; +#define new_idf() ((struct idf *) \ + st_alloc((char **)&h_idf, sizeof(struct idf))) +#define free_idf(p) st_free(p, h_idf, sizeof(struct idf)) + + +extern struct idf *str2idf(), *idf_hashed(); + +extern int level; +extern struct idf *gen_idf(); diff --git a/lang/cem/cemcom/ival.c b/lang/cem/cemcom/ival.c new file mode 100644 index 00000000..b439afec --- /dev/null +++ b/lang/cem/cemcom/ival.c @@ -0,0 +1,624 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ +/* CODE FOR THE INITIALISATION OF GLOBAL VARIABLES */ + +#include "nofloat.h" +#include +#include "debug.h" +#include +#include "nobitfield.h" +#include "arith.h" +#include "align.h" +#include "label.h" +#include "expr.h" +#include "type.h" +#include "struct.h" +#include "field.h" +#include "assert.h" +#include "Lpars.h" +#include "class.h" +#include "sizes.h" +#include "idf.h" +#include "level.h" +#include "def.h" + +#define con_nullbyte() C_con_ucon("0", (arith)1) + +char *symbol2str(); +char *long2str(); +char *strncpy(); +struct expr *do_array(), *do_struct(), *IVAL(); +extern char options[]; + +/* do_ival() performs the initialisation of a global variable + of type tp with the initialisation expression expr by calling IVAL(). + Guided by type tp, the expression is evaluated. +*/ +do_ival(tpp, ex) + struct type **tpp; + struct expr *ex; +{ + if (IVAL(tpp, ex) != 0) + too_many_initialisers(ex); +} + +/* IVAL() recursively guides the initialisation expression through the + different routines for the different types of initialisation: + - array initialisation + - struct initialisation + - fundamental type initialisation + Upto now, the initialisation of a union is not allowed! + An initialisation expression tree consists of normal expressions + which can be joined together by ',' nodes, which operator acts + like the lisp function "cons" to build lists. + IVAL() returns a pointer to the remaining expression tree. +*/ +struct expr * +IVAL(tpp, ex) + struct type **tpp; /* type of global variable */ + register struct expr *ex; /* initialiser expression */ +{ + register struct type *tp = *tpp; + + switch (tp->tp_fund) { + case ARRAY: /* array initialisation */ + if (valid_type(tp->tp_up, "array element") == 0) + return 0; + if (ISCOMMA(ex)) /* list of initialisation expressions */ + return do_array(ex, tpp); + if (tp->tp_up->tp_fund == CHAR && ex->ex_class == String) + /* initialisation like char s[] = "I am a string" */ + ch_array(tpp, ex); + else /* " int i[24] = 12;" */ + check_and_pad(ex, tpp); + break; + case STRUCT: /* struct initialisation */ + if (valid_type(tp, "struct") == 0) + return 0; + if (ISCOMMA(ex)) /* list of initialisation expressions */ + return do_struct(ex, tp); + check_and_pad(ex, tpp); /* "struct foo f = 12;" */ + break; + case UNION: + error("union initialisation not allowed"); + break; + case ERRONEOUS: + break; + default: /* fundamental type */ + if (ISCOMMA(ex)) { /* " int i = {12};" */ + if (IVAL(tpp, ex->OP_LEFT) != 0) + too_many_initialisers(ex); + /* return remainings of the list for the + other members of the aggregate, if this + item belongs to an aggregate. + */ + return ex->OP_RIGHT; + } + check_ival(ex, tp); /* "int i = 12;" */ + break; + } + return 0; +} + +/* do_array() initialises the members of an array described + by type tp with the expressions in expr. + Two important cases: + - the number of members is known + - the number of members is not known + In the latter case, do_array() digests the whole expression + tree it is given. + In the former case, do_array() eats as many members from + the expression tree as are needed for the array. + If there are not sufficient members for the array, the remaining + members are padded with zeroes +*/ +struct expr * +do_array(ex, tpp) + register struct expr *ex; + struct type **tpp; +{ + register struct type *tp = *tpp; + register arith elem_count; + + ASSERT(tp->tp_fund == ARRAY && ISCOMMA(ex)); + /* the following test catches initialisations like + char c[] = {"just a string"}; + or + char d[] = {{"just another string"}}; + The use of the brackets causes this problem. + Note: although the implementation of such initialisations + is completely foolish, we did it!! (no applause, thank you) + */ + if (tp->tp_up->tp_fund == CHAR) { + register struct expr *f = ex->OP_LEFT, *g = NILEXPR; + + while (ISCOMMA(f)) { /* eat the brackets!!! */ + g = f; + f = f->OP_LEFT; + } + if (f->ex_class == String) { /* hallelujah, it's a string! */ + ch_array(tpp, f); + return g ? g->OP_RIGHT : ex->OP_RIGHT; + } + /* else: just go on with the next part of this function */ + if (g != 0) + ex = g; + } + if (tp->tp_size == (arith)-1) { + /* declared with unknown size: [] */ + for (elem_count = 0; ex; elem_count++) { + /* eat whole initialisation expression */ + if (ISCOMMA(ex->OP_LEFT)) { /* embraced member */ + if (IVAL(&(tp->tp_up), ex->OP_LEFT) != 0) + too_many_initialisers(ex); + ex = ex->OP_RIGHT; + } + else { + if (aggregate_type(tp->tp_up)) + ex = IVAL(&(tp->tp_up), ex); + else { + check_ival(ex->OP_LEFT, tp->tp_up); + ex = ex->OP_RIGHT; + } + } + } + /* set the proper size */ + *tpp = construct_type(ARRAY, tp->tp_up, elem_count); + } + else { /* the number of members is already known */ + arith dim = tp->tp_size / tp->tp_up->tp_size; + + for (elem_count = 0; elem_count < dim && ex; elem_count++) { + if (ISCOMMA(ex->OP_LEFT)) { /* embraced member */ + if (IVAL(&(tp->tp_up), ex->OP_LEFT) != 0) + too_many_initialisers(ex); + ex = ex->OP_RIGHT; + } + else { + if (aggregate_type(tp->tp_up)) + ex = IVAL(&(tp->tp_up), ex); + else { + check_ival(ex->OP_LEFT, tp->tp_up); + ex = ex->OP_RIGHT; + } + } + } + if (ex && elem_count == dim) + /* all the members are initialised but there + remains a part of the expression tree which + is returned + */ + return ex; + if ((ex == 0) && elem_count < dim) + /* the expression tree is completely absorbed + but there are still members which must be + initialised with zeroes + */ + do + pad(tp->tp_up); + while (++elem_count < dim); + } + return 0; +} + + +/* do_struct() initialises a struct of type tp with the expression expr. + The main loop is just controlled by the definition of the selectors + during which alignment is taken care of. +*/ +struct expr * +do_struct(ex, tp) + register struct expr *ex; + register struct type *tp; +{ + register struct sdef *sd = tp->tp_sdef; + arith bytes_upto_here = (arith)0; + arith last_offset = (arith)-1; + + ASSERT(tp->tp_fund == STRUCT && ISCOMMA(ex)); + /* as long as there are selectors and there is an initialiser.. */ + while (sd && ex) { + if (ISCOMMA(ex->OP_LEFT)) { /* embraced expression */ + if (IVAL(&(sd->sd_type), ex->OP_LEFT) != 0) + too_many_initialisers(ex); + ex = ex->OP_RIGHT; + } + else { + if (aggregate_type(sd->sd_type)) + /* selector is an aggregate itself */ + ex = IVAL(&(sd->sd_type), ex); + else { +#ifdef NOBITFIELD + /* fundamental type, not embraced */ + check_ival(ex->OP_LEFT, sd->sd_type); + ex = ex->OP_RIGHT; +#else + if (is_anon_idf(sd->sd_idf)) + /* a hole in the struct due to + the use of ";:n;" in a struct + definition. + */ + put_bf(sd->sd_type, (arith)0); + else { /* fundamental type, not embraced */ + check_ival(ex->OP_LEFT, sd->sd_type); + ex = ex->OP_RIGHT; + } +#endif NOBITFIELD + } + } + if (sd->sd_sdef) /* align upto the next selector boundary */ + bytes_upto_here += zero_bytes(sd); + if (last_offset != sd->sd_offset) { + /* don't take the field-width more than once */ + bytes_upto_here += + size_of_type(sd->sd_type, "selector"); + last_offset = sd->sd_offset; + } + sd = sd->sd_sdef; + } + /* perfect fit if (ex && (sd == 0)) holds */ + if ((ex == 0) && (sd != 0)) { + /* there are selectors left which must be padded with zeroes */ + do { + pad(sd->sd_type); + /* take care of the alignment restrictions */ + if (sd->sd_sdef) + bytes_upto_here += zero_bytes(sd); + /* no field thrown-outs here */ + bytes_upto_here += + size_of_type(sd->sd_type, "selector"); + } while (sd = sd->sd_sdef); + } + /* keep on aligning... */ + while (bytes_upto_here++ < tp->tp_size) + con_nullbyte(); + return ex; +} + +/* check_and_pad() is given a simple initialisation expression + where the type can be either a simple or an aggregate type. + In the latter case, only the first member is initialised and + the rest is zeroed. +*/ +check_and_pad(ex, tpp) + register struct expr *ex; + struct type **tpp; +{ + /* ex is of a fundamental type */ + register struct type *tp = *tpp; + + if (tp->tp_fund == ARRAY) { + if (valid_type(tp->tp_up, "array element") == 0) + return; + check_and_pad(ex, &(tp->tp_up)); /* first member */ + if (tp->tp_size == (arith)-1) + /* no size specified upto here: just + set it to the size of one member. + */ + tp = *tpp = construct_type(ARRAY, tp->tp_up, (arith)1); + else { + register int dim = tp->tp_size / tp->tp_up->tp_size; + /* pad remaining members with zeroes */ + while (--dim > 0) + pad(tp->tp_up); + } + } + else + if (tp->tp_fund == STRUCT) { + register struct sdef *sd = tp->tp_sdef; + + if (valid_type(tp, "struct") == 0) + return; + check_and_pad(ex, &(sd->sd_type)); + /* next selector is aligned by adding extra zeroes */ + if (sd->sd_sdef) + zero_bytes(sd); + while (sd = sd->sd_sdef) { /* pad remaining selectors */ + pad(sd->sd_type); + if (sd->sd_sdef) + zero_bytes(sd); + } + } + else /* simple type */ + check_ival(ex, tp); +} + +/* pad() fills an element of type tp with zeroes. + If the element is an aggregate, pad() is called recursively. +*/ +pad(tp) + register struct type *tp; +{ + register arith sz = tp->tp_size; + + switch (tp->tp_fund) { + case ARRAY: + if (valid_type(tp->tp_up, "array element") == 0) + return; + break; + case STRUCT: + if (valid_type(tp, "struct") == 0) + return; + break; + case UNION: + if (valid_type(tp, "union") == 0) + return; + if (options['R']) { + warning("initialisation of unions not allowed"); + } + break; +#ifndef NOBITFIELD + case FIELD: + put_bf(tp, (arith)0); + return; +#endif NOBITFIELD + case ERRONEOUS: + return; + } + + while (sz >= word_size) { + C_con_cst((arith) 0); + sz -= word_size; + } + while (sz) { + C_con_icon("0", (arith) 1); + sz--; + } +} + +/* check_ival() checks whether the initialisation of an element + of a fundamental type is legal and, if so, performs the initialisation + by directly generating the necessary code. + No further comment is needed to explain the internal structure + of this straightforward function. +*/ +check_ival(expr, tp) + register struct expr *expr; + register struct type *tp; +{ + /* The philosophy here is that ch7cast puts an explicit + conversion node in front of the expression if the types + are not compatible. In this case, the initialisation + expression is no longer a constant. + */ + struct expr *ex = expr; + + switch (tp->tp_fund) { + case CHAR: + case SHORT: + case INT: + case LONG: + case ENUM: + case POINTER: + ch7cast(&ex, '=', tp); + expr = ex; +#ifdef DEBUG + print_expr("init-expr after cast", expr); +#endif DEBUG + if (!is_ld_cst(expr)) + illegal_init_cst(expr); + else + if (expr->VL_CLASS == Const) + con_int(expr); + else + if (expr->VL_CLASS == Name) { + register struct idf *idf = expr->VL_IDF; + + if (idf->id_def->df_level >= L_LOCAL) + illegal_init_cst(expr); + else /* e.g., int f(); int p = f; */ + if (idf->id_def->df_type->tp_fund == FUNCTION) + C_con_pnam(idf->id_text); + else /* e.g., int a; int *p = &a; */ + C_con_dnam(idf->id_text, expr->VL_VALUE); + } + else { + ASSERT(expr->VL_CLASS == Label); + C_con_dlb(expr->VL_LBL, expr->VL_VALUE); + } + break; +#ifndef NOFLOAT + case FLOAT: + case DOUBLE: + ch7cast(&ex, '=', tp); + expr = ex; +#ifdef DEBUG + print_expr("init-expr after cast", expr); +#endif DEBUG + if (expr->ex_class == Float) + C_con_fcon(expr->FL_VALUE, expr->ex_type->tp_size); + else + if (expr->ex_class == Oper && expr->OP_OPER == INT2FLOAT) { + /* float f = 1; */ + expr = expr->OP_RIGHT; + if (is_cp_cst(expr)) + C_con_fcon(long2str((long)expr->VL_VALUE, 10), + tp->tp_size); + else + illegal_init_cst(expr); + } + else + illegal_init_cst(expr); + break; +#endif NOFLOAT + +#ifndef NOBITFIELD + case FIELD: + ch7cast(&ex, '=', tp->tp_up); + expr = ex; +#ifdef DEBUG + print_expr("init-expr after cast", expr); +#endif DEBUG + if (is_cp_cst(expr)) + put_bf(tp, expr->VL_VALUE); + else + illegal_init_cst(expr); + break; +#endif NOBITFIELD + + case ERRONEOUS: + break; + default: + crash("check_ival"); + } +} + +/* ch_array() initialises an array of characters when given + a string constant. + Alignment is taken care of. +*/ +ch_array(tpp, ex) + struct type **tpp; /* type tp = array of characters */ + struct expr *ex; +{ + register struct type *tp = *tpp; + register arith length = ex->SG_LEN; + char *s; + arith ntopad; + + ASSERT(ex->ex_class == String); + if (tp->tp_size == (arith)-1) { + /* set the dimension */ + tp = *tpp = construct_type(ARRAY, tp->tp_up, length); + ntopad = align(tp->tp_size, word_size) - tp->tp_size; + } + else { + arith dim = tp->tp_size / tp->tp_up->tp_size; + extern char options[]; + + if (length > dim) { + if (options['R']) + too_many_initialisers(ex); + else { /* don't take the null byte into account */ + if (length > dim + 1) + expr_warning(ex, + "too many initialisers"); + length = dim; + } + } + ntopad = align(dim, word_size) - length; + } + /* throw out the characters of the already prepared string */ + s = Malloc((unsigned) (length + ntopad)); + clear(s, (int) (length + ntopad)); + strncpy(s, ex->SG_VALUE, (int) length); + free(ex->SG_VALUE); + str_cst(s, (int) (length + ntopad)); + free(s); +} + +/* As long as some parts of the pipeline cannot handle very long string + constants, string constants are written out in chunks +*/ +str_cst(str, len) + register char *str; + register int len; +{ + arith chunksize = ((127 + word_size) / word_size) * word_size; + + while (len > chunksize) { + C_con_scon(str, chunksize); + len -= chunksize; + str += chunksize; + } + C_con_scon(str, (arith) len); +} + +#ifndef NOBITFIELD +/* put_bf() takes care of the initialisation of (bit-)field + selectors of a struct: each time such an initialisation takes place, + put_bf() is called instead of the normal code generating routines. + Put_bf() stores the given integral value into "field" and + "throws" the result of "field" out if the current selector + is the last of this number of fields stored at the same address. +*/ +put_bf(tp, val) + struct type *tp; + arith val; +{ + static long field = (arith)0; + static arith offset = (arith)-1; + register struct field *fd = tp->tp_field; + register struct sdef *sd = fd->fd_sdef; + static struct expr exp; + + ASSERT(sd); + if (offset == (arith)-1) { + /* first bitfield in this field */ + offset = sd->sd_offset; + exp.ex_type = tp->tp_up; + exp.ex_class = Value; + exp.VL_CLASS = Const; + } + if (val != 0) /* insert the value into "field" */ + field |= (val & fd->fd_mask) << fd->fd_shift; + if (sd->sd_sdef == 0 || sd->sd_sdef->sd_offset != offset) { + /* the selector was the last stored at this address */ + exp.VL_VALUE = field; + con_int(&exp); + field = (arith)0; + offset = (arith)-1; + } +} +#endif NOBITFIELD + +int +zero_bytes(sd) + register struct sdef *sd; +{ + /* fills the space between a selector of a struct + and the next selector of that struct with zero-bytes. + */ + register int n = sd->sd_sdef->sd_offset - sd->sd_offset - + size_of_type(sd->sd_type, "struct member"); + register int count = n; + + while (n-- > 0) + con_nullbyte(); + return count; +} + +int +valid_type(tp, str) + struct type *tp; + char *str; +{ + if (tp->tp_size < 0) { + error("size of %s unknown", str); + return 0; + } + return 1; +} + +con_int(ex) + register struct expr *ex; +{ + register struct type *tp = ex->ex_type; + + ASSERT(is_cp_cst(ex)); + if (tp->tp_unsigned) + C_con_ucon(long2str((long)ex->VL_VALUE, -10), tp->tp_size); + else + C_con_icon(long2str((long)ex->VL_VALUE, 10), tp->tp_size); +} + +illegal_init_cst(ex) + struct expr *ex; +{ + expr_error(ex, "illegal initialisation constant"); +} + +too_many_initialisers(ex) + struct expr *ex; +{ + expr_error(ex, "too many initialisers"); +} + +aggregate_type(tp) + register struct type *tp; +{ + return tp->tp_fund == ARRAY || tp->tp_fund == STRUCT; +} diff --git a/lang/cem/cemcom/l_dummy.c b/lang/cem/cemcom/l_dummy.c new file mode 100644 index 00000000..9e524ee8 --- /dev/null +++ b/lang/cem/cemcom/l_dummy.c @@ -0,0 +1,70 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +/* + *The following functions are hacked to null-functions (i.e. they + * do nothing). This needs another solution in the future. !!???!! + */ +#include "lint.h" + +#ifdef LINT + +#include "arith.h" +#include "label.h" + +C_close(){} +int C_busy(){return 0;} + + +/* More routines */ +/* ARGSUSED */ +CC_bhcst(ps_xxx,n,w,i) arith n,w; {} +/* ARGSUSED */ +CC_crcst(ps_xxx,v) arith v; {} +/* ARGSUSED */ +CC_crdlb(ps_xxx,v,s) label v; arith s; {} +/* ARGSUSED */ +CC_crdnam(ps_xxx,v,s) char *v; arith s; {} +/* ARGSUSED */ +CC_crxcon(op,ps_xxx,v,s) char *v; arith s; {} +/* ARGSUSED */ +CC_crilb(ps_xxx,v) label v; {} +/* ARGSUSED */ +CC_crpnam(ps_xxx,v) char *v; {} +/* ARGSUSED */ +CC_crscon(ps_xxx,v,s) char *v; arith s; {} +/* ARGSUSED */ +CC_cst(l) {} +/* ARGSUSED */ +CC_dfdlb(l) label l; {} +/* ARGSUSED */ +CC_dfdnam(s) char *s; {} +/* ARGSUSED */ +CC_dfilb(l) label l; {} +/* ARGSUSED */ +CC_end(l) arith l; {} +CC_msend() {} +/* ARGSUSED */ +CC_msstart(ms) {} +/* ARGSUSED */ +CC_opcst(op_xxx,c) arith c; {} +/* ARGSUSED */ +CC_opdlb(op_xxx,g,o) label g; arith o; {} +/* ARGSUSED */ +CC_opilb(op_xxx,b) label b; {} +/* ARGSUSED */ +CC_oppnam(op_xxx,p) char *p; {} +/* ARGSUSED */ +CC_pronarg(s) char *s; {} +/* ARGSUSED */ +CC_psdlb(ps_xxx,l) label l; {} +/* ARGSUSED */ +CC_psdnam(ps_xxx,s) char *s; {} +/* ARGSUSED */ +CC_pspnam(ps_xxx,s) char *s; {} +/* ARGSUSED */ +CC_scon(v,s) char *s; {} +#endif LINT diff --git a/lang/cem/cemcom/macro.h b/lang/cem/cemcom/macro.h new file mode 100644 index 00000000..cdd023f8 --- /dev/null +++ b/lang/cem/cemcom/macro.h @@ -0,0 +1,52 @@ +/* $Header$ */ +/* PREPROCESSOR: DEFINITION OF MACRO DESCRIPTOR */ + +#include "nopp.h" + +#ifndef NOPP +/* The flags of the mc_flag field of the macro structure. Note that + these flags can be set simultaneously. +*/ +#define NOFLAG 0 /* no special flags */ +#define FUNC 01 /* function attached */ +#define PREDEF 02 /* predefined macro */ + +#define FORMALP 0200 /* mask for creating macro formal parameter */ + +/* The macro descriptor is very simple, except the fact that the + mc_text, which points to the replacement text, contains the + non-ascii characters \201, \202, etc, indicating the position of a + formal parameter in this text. +*/ +struct macro { + struct macro *next; + char * mc_text; /* the replacement text */ + int mc_nps; /* number of formal parameters */ + int mc_length; /* length of replacement text */ + char mc_flag; /* marking this macro */ +}; + + +/* allocation definitions of struct macro */ +/* ALLOCDEF "macro" */ +extern char *st_alloc(); +extern struct macro *h_macro; +#define new_macro() ((struct macro *) \ + st_alloc((char **)&h_macro, sizeof(struct macro))) +#define free_macro(p) st_free(p, h_macro, sizeof(struct macro)) + + +/* `token' numbers of keywords of command-line processor +*/ +#define K_UNKNOWN 0 +#define K_DEFINE 1 +#define K_ELIF 2 +#define K_ELSE 3 +#define K_ENDIF 4 +#define K_IF 5 +#define K_IFDEF 6 +#define K_IFNDEF 7 +#define K_INCLUDE 8 +#define K_LINE 9 +#define K_UNDEF 10 +#endif NOPP diff --git a/lang/cem/cemcom/make.emfun b/lang/cem/cemcom/make.emfun new file mode 100755 index 00000000..d3fe92f6 --- /dev/null +++ b/lang/cem/cemcom/make.emfun @@ -0,0 +1,19 @@ +ed - $1 <<'--EOI--' +g/^%/d +g/^ /.-1,.j +1,$s/^\([^|]*\)|\([^|]*\)|\(.*\)$/\ +\1 \2 {\ +\3;\ +}/ +1i +/* EM COMPACT CODE -- PROCEDURAL INTERFACE (generated from emcode.def) */ +#include "em.h" +#ifdef PROC_INTF +#include "label.h" +#include "arith.h" +. +$a +#endif PROC_INTF +. +1,$p +--EOI-- diff --git a/lang/cem/cemcom/make.emmac b/lang/cem/cemcom/make.emmac new file mode 100755 index 00000000..5337f40f --- /dev/null +++ b/lang/cem/cemcom/make.emmac @@ -0,0 +1,10 @@ +ed - $1 <<'--EOI--' +g/^%/d +g/^ /.-1,.j +1,$s/^\([^|]*\)|[^|]*|\(.*\)$/\ +#define \1 (\2)/ +1i +/* EM COMPACT CODE -- MACRO DEFINITIONS (generated from emcode.def) */ +. +1,$p +--EOI-- diff --git a/lang/cem/cemcom/nmclash.c b/lang/cem/cemcom/nmclash.c new file mode 100644 index 00000000..e820442d --- /dev/null +++ b/lang/cem/cemcom/nmclash.c @@ -0,0 +1,9 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* Accepted if many characters of long names are significant */ +/* $Header$ */ +abcdefghijklmnopr() { } +abcdefghijklmnopq() { } +main() { } diff --git a/lang/cem/cemcom/stack.h b/lang/cem/cemcom/stack.h new file mode 100644 index 00000000..27a7f312 --- /dev/null +++ b/lang/cem/cemcom/stack.h @@ -0,0 +1,46 @@ +/* $Header$ */ +/* IDENTIFIER STACK DEFINITIONS */ + +/* The identifier stack is implemented as a stack of sets. + The stack is implemented by a doubly linked list, + the sets by singly linked lists. +*/ + +struct stack_level { + struct stack_level *next; + struct stack_level *sl_next; /* upward link */ + struct stack_level *sl_previous; /* downward link */ + struct stack_entry *sl_entry; /* sideward link */ + arith sl_local_offset; /* @ for first coming object */ + arith sl_max_block; /* maximum size of sub-block */ + int sl_level; +}; + + +/* allocation definitions of struct stack_level */ +/* ALLOCDEF "stack_level" */ +extern char *st_alloc(); +extern struct stack_level *h_stack_level; +#define new_stack_level() ((struct stack_level *) \ + st_alloc((char **)&h_stack_level, sizeof(struct stack_level))) +#define free_stack_level(p) st_free(p, h_stack_level, sizeof(struct stack_level)) + + +struct stack_entry { + struct stack_entry *next; + struct idf *se_idf; +}; + + +/* allocation definitions of struct stack_entry */ +/* ALLOCDEF "stack_entry" */ +extern char *st_alloc(); +extern struct stack_entry *h_stack_entry; +#define new_stack_entry() ((struct stack_entry *) \ + st_alloc((char **)&h_stack_entry, sizeof(struct stack_entry))) +#define free_stack_entry(p) st_free(p, h_stack_entry, sizeof(struct stack_entry)) + + +extern struct stack_level *local_level; +extern struct stack_level *stack_level_of(); +extern int level; diff --git a/lang/cem/cemcom/storage.c b/lang/cem/cemcom/storage.c new file mode 100644 index 00000000..1477f712 --- /dev/null +++ b/lang/cem/cemcom/storage.c @@ -0,0 +1,67 @@ +/* $Header$ */ +/* S T R U C T U R E - S T O R A G E M A N A G E M E N T */ + +/* Assume that each structure contains a field "next", of pointer + type, as first tagfield. + struct xxx serves as a general structure: it just declares the + tagfield "next" as first field of a structure. + Please don't worry about any warnings when compiling this file + because some dirty tricks are performed to obtain the necessary + actions. +*/ + +#include "debug.h" /* UF */ +#include "botch_free.h" /* UF */ +#include "assert.h" +#include "alloc.h" +#include "storage.h" + +struct xxx { + char *next; +}; + +char * +head_alloc(phead, size) + char **phead; + int size; +{ + struct xxx *tmp; + + if (*phead == 0) { + return Malloc(size); + } + tmp = (struct xxx *) (*phead); + *phead = (char *) tmp->next; + return (char *) tmp; +} + +/* instead of Calloc: */ +clear(ptr, n) + char *ptr; + int n; +{ + ASSERT((long)ptr % sizeof (long) == 0); + while (n >= sizeof (long)) { /* high-speed clear loop */ + *(long *)ptr = 0L; + ptr += sizeof (long), n -= sizeof (long); + } + while (n--) + *ptr++ = '\0'; +} + +#ifdef BOTCH_FREE +botch(ptr, n) + char *ptr; + int n; +{ /* Writes garbage over n chars starting from ptr. + Used to check if freed memory is used inappropriately. + */ + ASSERT((long)ptr % sizeof (long) == 0); + while (n >= sizeof (long)) { /* high-speed botch loop */ + *(long *)ptr = 025252525252L; + ptr += sizeof (long), n -= sizeof (long); + } + while (n--) + *ptr++ = '\252'; +} +#endif BOTCH_FREE diff --git a/lang/cem/cemcom/storage.h b/lang/cem/cemcom/storage.h new file mode 100644 index 00000000..8eec8214 --- /dev/null +++ b/lang/cem/cemcom/storage.h @@ -0,0 +1,23 @@ +/* $Header$ */ +/* S T R U C T U R E - S T O R A G E D E F I N I T I O N S */ + +/* Storage allocation is one of the most expensive operations in + the compiler and consequently much thought and experimentation + has gone into it. To simplify the hooking in of new super-fancy + algorithms, all allocating and freeing of storage for structs + goes through the macros + st_alloc(&head, size) + st_free(ptr, head, size) + which, hopefully, convey enough information. +*/ + +extern char *head_alloc(); + +#define st_alloc(headp, size) head_alloc((char **)headp, size) + +#ifndef BOTCH_FREE +#define st_free(ptr, head, size) (ptr->next = head, head = ptr) +#else def BOTCH_FREE +#define st_free(ptr, head, size) (botch((char *)(ptr), size), \ + ptr->next = head, head = ptr) +#endif BOTCH_FREE diff --git a/lang/cem/cemcom/string.c b/lang/cem/cemcom/string.c new file mode 100644 index 00000000..5a61cc30 --- /dev/null +++ b/lang/cem/cemcom/string.c @@ -0,0 +1,277 @@ +/* $Header$ */ +/* STRING MANIPULATION AND PRINT ROUTINES */ + +#include +#include "string.h" +#include "nopp.h" +#include "str_params.h" +#include "arith.h" + +doprnt(fp, fmt, argp) + File *fp; + char *fmt; + int argp[]; +{ + char buf[SSIZE]; + + sys_write(fp, buf, format(buf, fmt, (char *)argp)); +} + +/*VARARGS1*/ +printf(fmt, args) + char *fmt; + char args; +{ + char buf[SSIZE]; + + sys_write(STDOUT, buf, format(buf, fmt, &args)); +} + +/*VARARGS1*/ +fprintf(fp, fmt, args) + File *fp; + char *fmt; + char args; +{ + char buf[SSIZE]; + + sys_write(fp, buf, format(buf, fmt, &args)); +} + +/*VARARGS1*/ +char * +sprintf(buf, fmt, args) + char *buf, *fmt; + char args; +{ + buf[format(buf, fmt, &args)] = '\0'; + return buf; +} + +int +format(buf, fmt, argp) + char *buf, *fmt; + char *argp; +{ + register char *pf = fmt, *pa = argp; + register char *pb = buf; + + while (*pf) { + if (*pf == '%') { + register width, base, pad, npad; + char *arg; + char cbuf[2]; + char *badformat = ""; + + /* get padder */ + if (*++pf == '0') { + pad = '0'; + ++pf; + } + else + pad = ' '; + + /* get width */ + width = 0; + while (*pf >= '0' && *pf <= '9') + width = 10 * width + *pf++ - '0'; + + /* get text and move pa */ + if (*pf == 's') { + arg = *(char **)pa; + pa += sizeof(char *); + } + else + if (*pf == 'c') { + cbuf[0] = * (char *) pa; + cbuf[1] = '\0'; + pa += sizeof(int); + arg = &cbuf[0]; + } + else + if (*pf == 'l') { + /* alignment ??? */ + if (base = integral(*++pf)) { + arg = int_str(*(long *)pa, base); + pa += sizeof(long); + } + else { + pf--; + arg = badformat; + } + } + else + if (base = integral(*pf)) { + arg = int_str((long)*(int *)pa, base); + pa += sizeof(int); + } + else + if (*pf == '%') + arg = "%"; + else + arg = badformat; + + npad = width - strlen(arg); + + while (npad-- > 0) + *pb++ = pad; + + while (*pb++ = *arg++); + pb--; + pf++; + } + else + *pb++ = *pf++; + } + return pb - buf; +} + +integral(c) +{ + switch (c) { + case 'b': + return -2; + case 'd': + return 10; + case 'o': + return -8; + case 'u': + return -10; + case 'x': + return -16; + } + return 0; +} + +/* Integer to String translator +*/ +char * +int_str(val, base) + register long val; + register base; +{ + /* int_str() is a very simple integer to string converter. + base < 0 : unsigned. + base must be an element of [-16,-2] V [2,16]. + */ + static char numbuf[MAXWIDTH]; + static char vec[] = "0123456789ABCDEF"; + register char *p = &numbuf[MAXWIDTH]; + int sign = (base > 0); + + *--p = '\0'; /* null-terminate string */ + if (val) { + if (base > 0) { + if (val < (arith)0) { + if ((val = -val) < (arith)0) + goto overflow; + } + else + sign = 0; + } + else + if (base < 0) { /* unsigned */ + base = -base; + if (val < (arith)0) { + register mod, i; + + overflow: + /* this takes a rainy Sunday afternoon to explain */ + /* ??? */ + mod = 0; + for (i = 0; i < 8 * sizeof val; i++) { + mod <<= 1; + if (val < 0) + mod++; + val <<= 1; + if (mod >= base) { + mod -= base; + val++; + } + } + *--p = vec[mod]; + } + } + + do { + *--p = vec[(int) (val % base)]; + val /= base; + } while (val != (arith)0); + + if (sign) + *--p = '-'; /* don't forget it !! */ + } + else + *--p = '0'; /* just a simple 0 */ + + return p; +} + +/* return negative, zero or positive value if + resp. s < t, s == t or s > t +*/ +int +strcmp(s, t) + register char *s, *t; +{ + while (*s == *t++) + if (*s++ == '\0') + return 0; + return *s - *--t; +} + +/* return length of s +*/ +int +strlen(s) + char *s; +{ + register char *b = s; + + while (*b++) + ; + return b - s - 1; +} + +#ifndef NOPP +/* append t to s +*/ +char * +strcat(s, t) + register char *s, *t; +{ + register char *b = s; + + while (*s++) + ; + s--; + while (*s++ = *t++) + ; + return b; +} + +/* Copy t into s +*/ +char * +strcpy(s, t) + register char *s, *t; +{ + register char *b = s; + + while (*s++ = *t++) + ; + return b; +} + +char * +rindex(str, chr) + register char *str, chr; +{ + register char *retptr = 0; + + while (*str) + if (*str++ == chr) + retptr = &str[-1]; + return retptr; +} +#endif NOPP diff --git a/lang/cem/cemcom/string.h b/lang/cem/cemcom/string.h new file mode 100644 index 00000000..ffeeb6bb --- /dev/null +++ b/lang/cem/cemcom/string.h @@ -0,0 +1,13 @@ +/* $Header$ */ +/* STRING-ROUTINE DEFINITIONS */ + +#define stdin 0 +#define stdout 1 +#define stderr 2 + +#define itos(n) int_str((long)(n), 10) + +char *sprintf(); /* string.h */ +char *int_str(); /* string.h */ + +char *strcpy(), *strcat(), *rindex(); diff --git a/lang/cem/cemcom/struct.h b/lang/cem/cemcom/struct.h new file mode 100644 index 00000000..8caab678 --- /dev/null +++ b/lang/cem/cemcom/struct.h @@ -0,0 +1,44 @@ +/* $Header$ */ +/* SELECTOR DESCRIPTOR */ + +struct sdef { /* for selectors */ + struct sdef *next; + int sd_level; + struct idf *sd_idf; /* its name */ + struct sdef *sd_sdef; /* the next selector */ + struct type *sd_stype; /* the struct it belongs to */ + struct type *sd_type; /* its type */ + arith sd_offset; +}; + +extern char *st_alloc(); + + +/* allocation definitions of struct sdef */ +/* ALLOCDEF "sdef" */ +extern char *st_alloc(); +extern struct sdef *h_sdef; +#define new_sdef() ((struct sdef *) \ + st_alloc((char **)&h_sdef, sizeof(struct sdef))) +#define free_sdef(p) st_free(p, h_sdef, sizeof(struct sdef)) + + +struct tag { /* for struct-, union- and enum tags */ + struct tag *next; + int tg_level; + int tg_busy; /* non-zero during declaration of struct/union pack */ + struct type *tg_type; +}; + + + +/* allocation definitions of struct tag */ +/* ALLOCDEF "tag" */ +extern char *st_alloc(); +extern struct tag *h_tag; +#define new_tag() ((struct tag *) \ + st_alloc((char **)&h_tag, sizeof(struct tag))) +#define free_tag(p) st_free(p, h_tag, sizeof(struct tag)) + + +struct sdef *idf2sdef(); diff --git a/lang/cem/cemcom/switch.h b/lang/cem/cemcom/switch.h new file mode 100644 index 00000000..07998b9e --- /dev/null +++ b/lang/cem/cemcom/switch.h @@ -0,0 +1,40 @@ +/* $Header$ */ +/* S W I T C H - T A B L E - S T R U C T U R E */ + +struct switch_hdr { + struct switch_hdr *next; + label sh_break; + label sh_default; + label sh_table; + int sh_nrofentries; + struct type *sh_type; + arith sh_lowerbd; + arith sh_upperbd; + struct case_entry *sh_entries; +}; + + +/* allocation definitions of struct switch_hdr */ +/* ALLOCDEF "switch_hdr" */ +extern char *st_alloc(); +extern struct switch_hdr *h_switch_hdr; +#define new_switch_hdr() ((struct switch_hdr *) \ + st_alloc((char **)&h_switch_hdr, sizeof(struct switch_hdr))) +#define free_switch_hdr(p) st_free(p, h_switch_hdr, sizeof(struct switch_hdr)) + + +struct case_entry { + struct case_entry *next; + label ce_label; + arith ce_value; +}; + + +/* allocation definitions of struct case_entry */ +/* ALLOCDEF "case_entry" */ +extern char *st_alloc(); +extern struct case_entry *h_case_entry; +#define new_case_entry() ((struct case_entry *) \ + st_alloc((char **)&h_case_entry, sizeof(struct case_entry))) +#define free_case_entry(p) st_free(p, h_case_entry, sizeof(struct case_entry)) + diff --git a/lang/cem/cemcom/system.c b/lang/cem/cemcom/system.c new file mode 100644 index 00000000..dd80863b --- /dev/null +++ b/lang/cem/cemcom/system.c @@ -0,0 +1,72 @@ +/* $Header$ */ +/* SYSTEM DEPENDENT ROUTINES */ + +#include "system.h" +#include "inputtype.h" +#include + +extern long lseek(); + +int +xopen(name, flag, mode) + char *name; +{ + if (name[0] == '-' && name[1] == '\0') + return (flag == OP_RDONLY) ? 0 : 1; + + switch (flag) { + + case OP_RDONLY: + return open(name, 0); + case OP_WRONLY: + return open(name, 1); + case OP_CREAT: + return creat(name, mode); + case OP_APPEND: + { + register fd; + + if ((fd = open(name, 1)) < 0) + return -1; + lseek(fd, 0L, 2); + return fd; + } + } + /*NOTREACHED*/ +} + +int +xclose(fildes) +{ + if (fildes != 0 && fildes != 1) + return close(fildes); + return -1; +} + +#ifdef READ_IN_ONE +long +xfsize(fildes) +{ + struct stat stbuf; + + if (fstat(fildes, &stbuf) != 0) + return -1; + return stbuf.st_size; +} +#endif READ_IN_ONE + +exit(n) +{ + _exit(n); +} + +xstop(how, stat) +{ + switch (how) { + case S_ABORT: + abort(); + case S_EXIT: + exit(stat); + } + /*NOTREACHED*/ +} diff --git a/lang/cem/cemcom/system.h b/lang/cem/cemcom/system.h new file mode 100644 index 00000000..ae69ff8c --- /dev/null +++ b/lang/cem/cemcom/system.h @@ -0,0 +1,34 @@ +/* $Header$ */ +/* SYSTEM DEPENDANT DEFINITIONS */ + +#include +#include + +#define OP_RDONLY 0 /* open for read */ +#define OP_WRONLY 1 /* open for write */ +#define OP_CREAT 2 /* create and open for write */ +#define OP_APPEND 3 /* open for write at end */ + +#define sys_open(name, flag) xopen(name, flag, 0) +#define sys_close(fildes) xclose(fildes) +#define sys_read(fildes, buffer, nbytes) read(fildes, buffer, nbytes) +#define sys_write(fildes, buffer, nbytes) write(fildes, buffer, nbytes) +#define sys_creat(name, mode) xopen(name, OP_CREAT, mode) +#define sys_remove(name) unlink(name) +#define sys_fsize(fd) xfsize(fd) +#define sys_sbrk(incr) sbrk(incr) +#define sys_stop(how, stat) xstop(how, stat) + +#define S_ABORT 1 +#define S_EXIT 2 + +char *sbrk(); +long xfsize(); + +extern int errno; + +#define sys_errno errno + +#define time_type time_t +#define sys_time(tloc) time(tloc) +time_type time(); diff --git a/lang/cem/cemcom/tab.c b/lang/cem/cemcom/tab.c new file mode 100644 index 00000000..1881d087 --- /dev/null +++ b/lang/cem/cemcom/tab.c @@ -0,0 +1,300 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ +/* @cc tab.c -o $INSTALLDIR/tab@ + tab - table generator + + Author: Erik Baalbergen (..tjalk!erikb) +*/ + +#include + +#define MAXTAB 10000 +#define MAXBUF 10000 +#define COMCOM '-' +#define FILECOM '%' + +int InputForm = 'c'; +char OutputForm[MAXBUF] = "%s,\n"; +int TabSize = 257; +char *Table[MAXTAB]; +char *ProgCall; + +main(argc, argv) + char *argv[]; +{ + ProgCall = *argv++; + argc--; + while (argc-- > 0) { + if (**argv == COMCOM) { + option(*argv++); + } + else { + process(*argv++, InputForm); + } + } + exit(0); +} + +char * +Salloc(s) + char *s; +{ + extern char *malloc(), *strcpy(); + char *ns = malloc((unsigned int)strlen(s) + 1); + + if (ns) { + strcpy(ns, s); + } + return ns; +} + +option(str) + char *str; +{ + /* note that *str indicates the source of the option: + either COMCOM (from command line) or FILECOM (from a file). + */ + extern char *sprintf(); + + switch (*++str) { + + case ' ': /* command */ + case '\t': + case '\0': + break; + case 'I': + InputForm = *++str; + break; + case 'f': + if (*++str == '\0') { + fprintf(stderr, "%s: -f: name expected\n", ProgCall); + exit(1); + } + DoFile(str); + break; + case 'F': + sprintf(OutputForm, "%s\n", ++str); + break; + case 'T': + printf("%s\n", ++str); + break; + case 'p': + PrintTable(); + break; + case 'C': + ClearTable(); + break; + case 'S': + { + register i = stoi(++str); + + if (i <= 0 || i > MAXTAB) { + fprintf(stderr, "%s: size would exceed maximum\n", + ProgCall); + } + else { + TabSize = i; + } + break; + } + default: + fprintf(stderr, "%s: bad option -%s\n", ProgCall, str); + } +} + +ClearTable() +{ + register i; + + for (i = 0; i < MAXTAB; i++) { + Table[i] = 0; + } +} + +PrintTable() +{ + register i; + + for (i = 0; i < TabSize; i++) { + if (Table[i]) { + printf(OutputForm, Table[i]); + } + else { + printf(OutputForm, "0"); + } + } +} + +process(str, format) + char *str; +{ + char *cstr = str; + char *Name = cstr; /* overwrite original string! */ + + /* strip of the entry name + */ + while (*str && *str != ':') { + if (*str == '\\') { + ++str; + } + *cstr++ = *str++; + } + + if (*str != ':') { + fprintf(stderr, "%s: bad specification: \"%s\", ignored\n", + ProgCall, Name); + return 0; + } + *cstr = '\0'; + str++; + + switch (format) { + + case 'c': + return c_proc(str, Name); + default: + fprintf(stderr, "%s: bad input format\n", ProgCall); + } + return 0; +} + +c_proc(str, Name) + char *str; + char *Name; +{ + int ch, ch2; + int quoted(); + + while (*str) { + if (*str == '\\') { + ch = quoted(&str); + } + else { + ch = *str++; + } + if (*str == '-') { + if (*++str == '\\') { + ch2 = quoted(&str); + } + else { + if (ch2 = *str++); + else str--; + } + if (ch > ch2) { + fprintf(stderr, "%s: bad range\n", ProgCall); + return 0; + } + if (ch >= 0 && ch2 <= 255) + while (ch <= ch2) + Table[ch++] = Salloc(Name); + } + else { + if (ch >= 0 && ch <= 255) + Table[ch] = Salloc(Name); + } + } + return 1; +} + +int +quoted(pstr) + char **pstr; +{ + register int ch; + register int i; + register char *str = *pstr; + + if ((*++str >= '0') && (*str <= '9')) { + ch = 0; + for (i = 0; i < 3; i++) { + ch = 8 * ch + *str - '0'; + if (*++str < '0' || *str > '9') + break; + } + } + else { + switch (*str++) { + + case 'n': + ch = '\n'; + break; + case 't': + ch = '\t'; + break; + case 'b': + ch = '\b'; + break; + case 'r': + ch = '\r'; + break; + case 'f': + ch = '\f'; + break; + default : + ch = *str; + } + } + *pstr = str; + return ch & 0377; +} + +int +stoi(str) + char *str; +{ + register i = 0; + + while (*str >= '0' && *str <= '9') { + i = i * 10 + *str++ - '0'; + } + return i; +} + +char * +getline(s, n, fp) + char *s; + FILE *fp; +{ + register c = getc(fp); + char *str = s; + + while (n--) { + if (c == EOF) { + return NULL; + } + else + if (c == '\n') { + *str++ = '\0'; + return s; + } + *str++ = c; + c = getc(fp); + } + s[n - 1] = '\0'; + return s; +} + +#define BUFSIZE 1024 + +DoFile(name) + char *name; +{ + char text[BUFSIZE]; + FILE *fp; + + if ((fp = fopen(name, "r")) == NULL) { + fprintf(stderr, "%s: cannot read file %s\n", ProgCall, name); + exit(1); + } + while (getline(text, BUFSIZE, fp) != NULL) { + if (text[0] == FILECOM) { + option(text); + } + else { + process(text, InputForm); + } + } +} diff --git a/lang/cem/cemcom/type.h b/lang/cem/cemcom/type.h new file mode 100644 index 00000000..1937a569 --- /dev/null +++ b/lang/cem/cemcom/type.h @@ -0,0 +1,52 @@ +/* $Header$ */ +/* TYPE DESCRIPTOR */ + +#include "nobitfield.h" + +struct type { + struct type *next; /* used only with ARRAY */ + short tp_fund; /* fundamental type */ + char tp_unsigned; + int tp_align; + arith tp_size; /* -1 if declared but not defined */ + struct idf *tp_idf; /* name of STRUCT, UNION or ENUM */ + struct sdef *tp_sdef; /* to first selector */ + struct type *tp_up; /* from FIELD, POINTER, ARRAY + or FUNCTION to fund. */ + struct field *tp_field; /* field descriptor if fund == FIELD */ + struct type *tp_pointer;/* to POINTER */ + struct type *tp_array; /* to ARRAY */ + struct type *tp_function;/* to FUNCTION */ +}; + +extern struct type + *create_type(), *standard_type(), *construct_type(), *pointer_to(), + *array_of(), *function_of(); + +#ifndef NOBITFIELD +extern struct type *field_of(); +#endif NOBITFIELD + +extern struct type + *char_type, *uchar_type, + *short_type, *ushort_type, + *word_type, *uword_type, + *int_type, *uint_type, + *long_type, *ulong_type, + *float_type, *double_type, + *void_type, *label_type, + *string_type, *funint_type, *error_type; + +extern struct type *pa_type; /* type.c */ + +extern arith size_of_type(), align(); + + +/* allocation definitions of struct type */ +/* ALLOCDEF "type" */ +extern char *st_alloc(); +extern struct type *h_type; +#define new_type() ((struct type *) \ + st_alloc((char **)&h_type, sizeof(struct type))) +#define free_type(p) st_free(p, h_type, sizeof(struct type)) + diff --git a/lang/cem/cpp.ansi/Makefile b/lang/cem/cpp.ansi/Makefile new file mode 100644 index 00000000..4431323d --- /dev/null +++ b/lang/cem/cpp.ansi/Makefile @@ -0,0 +1,266 @@ +# MAKEFILE FOR (STAND_ALONE) CEM PREPROCESSOR + +EMHOME=../../.. +MODULES=$(EMHOME)/modules +MODULESLIB=$(MODULES)/lib +BIN=$(EMHOME)/lib +MANDIR=$(EMHOME)/man + +# Some paths + +# Libraries +SYSLIB = $(MODULESLIB)/libsystem.a +STRLIB = $(MODULESLIB)/libstring.a +PRTLIB = $(MODULESLIB)/libprint.a +ALLOCLIB = $(MODULESLIB)/liballoc.a +ASSERTLIB = $(MODULESLIB)/libassert.a +MALLOC = $(MODULESLIB)/malloc.o +LIBS = $(PRTLIB) $(STRLIB) $(ALLOCLIB) $(MALLOC) $(ASSERTLIB) $(SYSLIB) +LIB_INCLUDES = -I$(MODULES)/h -I$(MODULES)/pkg + +# Where to install the preprocessor +CEMPP = $(BIN)/cpp.ansi + +TABGEN = $(EMHOME)/bin/tabgen + +# What C compiler to use and how +CC = cc +COPTIONS = -O +LDFLAGS = + +# What parser generator to use and how +GEN = $(EMHOME)/bin/LLgen +GENOPTIONS = + +# Special #defines during compilation +CDEFS = $(LIB_INCLUDES) +CFLAGS = $(CDEFS) $(COPTIONS)# # we cannot pass the COPTIONS to lint! + +# Grammar files and their objects +LSRC = tokenfile.g expression.g +LCSRC = tokenfile.c expression.c Lpars.c +LOBJ = tokenfile.o expression.o Lpars.o + +# Objects of hand-written C files +CSRC = LLlex.c LLmessage.c ch3bin.c ch3mon.c domacro.c \ + error.c idf.c init.c input.c main.c options.c \ + preprocess.c replace.c skip.c tokenname.c expr.c +COBJ = LLlex.o LLmessage.o ch3bin.o ch3mon.o domacro.o \ + error.o idf.o init.o input.o main.o options.o \ + preprocess.o replace.o skip.o tokenname.o next.o expr.o + +PRFILES = Makefile Parameters \ + make.hfiles make.tokcase make.tokfile LLlex.h bits.h file_info.h \ + idf.h input.h interface.h macro.str replace.str \ + class.h char.tab expression.g $(CSRC) + +# Objects of other generated C files +GOBJ = char.o symbol2str.o + +# generated source files +GSRC = char.c symbol2str.c next.c + +# .h files generated by `make.allod' +STRSRC = macro.str replace.str +GSTRSRC = macro.h replace.h + +# .h files generated by `make hfiles'; PLEASE KEEP THIS UP-TO-DATE! +GHSRC = errout.h idfsize.h ifdepth.h macbuf.h \ + nparams.h numsize.h obufsize.h \ + parbufsize.h pathlength.h strsize.h textsize.h \ + botch_free.h debug.h inputtype.h dobits.h ln_prefix.h + +# Other generated files, for 'make clean' only +GENERATED = tokenfile.g Lpars.h LLfiles LL.output lint.out \ + Xref hfiles cfiles tags Makefile.old + +all: cc + +cc: cfiles + make "EMHOME="$(EMHOME) "CC=$(CC)" ncpp + +hfiles: Parameters char.c + ./make.hfiles Parameters + @touch hfiles + +.SUFFIXES: .str .h +.str.h: + ./make.allocd <$*.str >$*.h + +char.c: char.tab + $(TABGEN) -fchar.tab > char.c + +next.c: make.next $(STRSRC) + ./make.next $(STRSRC) >next.c + +macro.h: make.allocd +replace.h: make.allocd + +LLfiles: $(LSRC) + $(GEN) $(GENOPTIONS) $(LSRC) + @touch LLfiles + +tokenfile.g: tokenname.c make.tokfile + tokenfile.g + +symbol2str.c: tokenname.c make.tokcase + symbol2str.c + +# Objects needed for 'ncpp' +OBJ = $(COBJ) $(LOBJ) $(GOBJ) +SRC = $(CSRC) $(LCSRC) $(GSRC) + +ncpp: $(OBJ) Makefile + $(CC) $(COPTIONS) $(LDFLAGS) $(OBJ) $(LIBS) -o ncpp + -size ncpp + +cfiles: hfiles LLfiles $(GSRC) $(GSTRSRC) + @touch cfiles + +install: all + rm -f $(CEMPP) + cp ncpp $(CEMPP) + rm -f $(MANDIR)/cpp.ansi.6 + cp ncpp.6 $(MANDIR)/cpp.ansi.6 + +cmp: all + -cmp ncpp $(CEMPP) + -cmp ncpp.6 $(MANDIR)/cpp.ansi.6 + +pr: + @pr $(PRFILES) + +opr: + make pr | opr + +tags: cfiles + ctags $(SRC) + +depend: cfiles + sed '/^#AUTOAUTO/,$$d' Makefile >Makefile.new + echo '#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO' >>Makefile.new + $(EMHOME)/bin/mkdep $(SRC) | \ + sed 's/\.c:/.o:/' >>Makefile.new + mv Makefile Makefile.old + mv Makefile.new Makefile + +xref: + ctags -x `grep "\.[ch]" Files`|sed "s/).*/)/">Xref + +lint: cfiles + lint -bx $(CDEFS) $(SRC) >lint.out + +clean: + rm -f $(LCSRC) $(OBJ) $(GENERATED) $(GSRC) $(GHSRC) $(GSTRSRC) ncpp Out + +#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO +LLlex.o: LLlex.h +LLlex.o: Lpars.h +LLlex.o: arith.h +LLlex.o: bits.h +LLlex.o: class.h +LLlex.o: dobits.h +LLlex.o: file_info.h +LLlex.o: idf.h +LLlex.o: idfsize.h +LLlex.o: input.h +LLlex.o: inputtype.h +LLlex.o: macro.h +LLlex.o: numsize.h +LLlex.o: strsize.h +LLmessage.o: LLlex.h +LLmessage.o: Lpars.h +LLmessage.o: arith.h +LLmessage.o: file_info.h +ch3bin.o: Lpars.h +ch3bin.o: arith.h +ch3mon.o: Lpars.h +ch3mon.o: arith.h +domacro.o: LLlex.h +domacro.o: Lpars.h +domacro.o: arith.h +domacro.o: bits.h +domacro.o: botch_free.h +domacro.o: class.h +domacro.o: dobits.h +domacro.o: file_info.h +domacro.o: idf.h +domacro.o: idfsize.h +domacro.o: ifdepth.h +domacro.o: input.h +domacro.o: inputtype.h +domacro.o: macbuf.h +domacro.o: macro.h +domacro.o: nparams.h +domacro.o: parbufsize.h +domacro.o: replace.h +domacro.o: textsize.h +error.o: LLlex.h +error.o: arith.h +error.o: errout.h +error.o: file_info.h +idf.o: idf.h +init.o: class.h +init.o: idf.h +init.o: macro.h +input.o: file_info.h +input.o: input.h +input.o: inputtype.h +main.o: arith.h +main.o: file_info.h +main.o: idf.h +main.o: idfsize.h +main.o: macro.h +options.o: class.h +options.o: idf.h +options.o: idfsize.h +options.o: macro.h +preprocess.o: LLlex.h +preprocess.o: arith.h +preprocess.o: bits.h +preprocess.o: class.h +preprocess.o: dobits.h +preprocess.o: file_info.h +preprocess.o: idf.h +preprocess.o: idfsize.h +preprocess.o: input.h +preprocess.o: inputtype.h +preprocess.o: ln_prefix.h +preprocess.o: macro.h +preprocess.o: obufsize.h +preprocess.o: textsize.h +replace.o: LLlex.h +replace.o: arith.h +replace.o: class.h +replace.o: file_info.h +replace.o: idf.h +replace.o: idfsize.h +replace.o: input.h +replace.o: inputtype.h +replace.o: macbuf.h +replace.o: macro.h +replace.o: nparams.h +replace.o: numsize.h +replace.o: pathlength.h +replace.o: replace.h +replace.o: strsize.h +skip.o: LLlex.h +skip.o: arith.h +skip.o: class.h +skip.o: file_info.h +skip.o: input.h +skip.o: inputtype.h +tokenname.o: LLlex.h +tokenname.o: Lpars.h +tokenname.o: arith.h +tokenname.o: file_info.h +tokenname.o: idf.h +expr.o: Lpars.h +tokenfile.o: Lpars.h +expression.o: LLlex.h +expression.o: Lpars.h +expression.o: arith.h +expression.o: file_info.h +Lpars.o: Lpars.h +char.o: class.h +symbol2str.o: Lpars.h diff --git a/lang/cem/cpp.ansi/nccp.6 b/lang/cem/cpp.ansi/nccp.6 new file mode 100644 index 00000000..d72f7269 --- /dev/null +++ b/lang/cem/cpp.ansi/nccp.6 @@ -0,0 +1,74 @@ +.TH NCPP 6ACK +.ad +.SH NAME +ncpp \- New C Pre-Processor +.SH SYNOPSIS +ncpp [\-options] [ file ] +.SH DESCRIPTION +.I Ncpp +reads a file, expands macros and include +files, and writes an input file for the C compiler. +All output is to standard output. +.br +The following options are supported. +.IP -\fBI\fIdirectory\fR +.br +add this directory to the list of +directories searched for #include "..." and #include <...> +commands. Note that there is no space between the +"-I" and the directory string. More than one -I command +is permitted. +.IP -\fBI\fR +end the list of directories to be searched, and also do not look in +default places. +.IP -\fBD\fIname\fR=\fItext\fR +.br +define +.I name +as a macro with +.I text +as its replacement text. +.IP -\fBD\fIname\fR +the same as -\fBD\fIname\fR=1. +.IP +.IP -\fBU\fIname\fR +.br +undefine the macro name +.IR name . +.IP -\fBC\fR +leave comments in. By default, C-comments are deleted. +.IP -\fBP\fR +do not generate line directives +.IP -\fBM\fIn\fR +set maximum identifier length to +.IR n . +.PP +The following names are always available unless undefined: +.RS +.IP __STDC__ +A decimal constant 1, indicating that this is an ANSI C conforming +implementation. +.IP __FILE__ +The input (or #include) file being compiled +(as a quoted string). +.IP __LINE__ +The line number being compiled. +.IP __DATE__ +The date of translation of the source file. This is a string +literal of the form "\fBMmm dd yyyy\fP". +.IP __TIME__ +The time of translation of the source file. This is a string +literal of the form "\fBhh:mm:ss\fP". +.RE +.SH BUGS +The output may contain extra spaces, this prevents unintended +pasting of tokens. +.SH "SEE ALSO" +L. Rosler, +.I +Draft Proposed Standard - Programming Language C, +.R +ANSI X3J11 Language Subcommittee +.SH AUTHOR +Leendert van Doorn + diff --git a/lang/cem/ctest/ctstruct/str.pcc.r b/lang/cem/ctest/ctstruct/str.pcc.r new file mode 100644 index 00000000..a6b5ad35 --- /dev/null +++ b/lang/cem/ctest/ctstruct/str.pcc.r @@ -0,0 +1,152 @@ +w1 + st2.w1_i 506 + (*st3).w1_i 506 + st1.w1_i 711 + st2.w1_i 711 + es2[2].w1_i 711 + st2.w1_i 577 + st2.w1_i -577 + st1.w1_i 577 +w2 + s2t2: .w2_i 18000 .w2_d 3.141500 + s2t3->w2_d 3.141500 +w3 +s3t2.w3_a[ 0] a +s3t2.w3_a[ 1] b +s3t2.w3_a[ 2] c +s3t2.w3_a[ 3] d +s3t2.w3_a[ 4] e +s3t2.w3_a[ 5] f +s3t2.w3_a[ 6] g +s3t2.w3_a[ 7] h +s3t2.w3_a[ 8] i +s3t2.w3_a[ 9] j +s3t2.w3_a[10] k +s3t2.w3_a[11] l +s3t2.w3_a[12] m +s3t2.w3_a[13] n +s3t2.w3_a[14] o +s3t2.w3_a[15] p +s3t2.w3_a[16] q +s3t2.w3_a[17] r +s3t2.w3_a[18] s +s3t2.w3_a[19] t +s3t2.w3_a[20] u +s3t2.w3_a[21] v +s3t2.w3_a[22] w +s3t2.w3_a[23] x +s3t2.w3_a[24] y +s3t2.w3_a[25] z +s3t2.w3_x 1.000000 +s3t1.w3_a[ 0] A +s3t1.w3_a[ 1] B +s3t1.w3_a[ 2] C +s3t1.w3_a[ 3] D +s3t1.w3_a[ 4] E +s3t1.w3_a[ 5] F +s3t1.w3_a[ 6] G +s3t1.w3_a[ 7] H +s3t1.w3_a[ 8] I +s3t1.w3_a[ 9] J +s3t1.w3_a[10] K +s3t1.w3_a[11] L +s3t1.w3_a[12] M +s3t1.w3_a[13] N +s3t1.w3_a[14] O +s3t1.w3_a[15] P +s3t1.w3_a[16] Q +s3t1.w3_a[17] R +s3t1.w3_a[18] S +s3t1.w3_a[19] T +s3t1.w3_a[20] U +s3t1.w3_a[21] V +s3t1.w3_a[22] W +s3t1.w3_a[23] X +s3t1.w3_a[24] Y +s3t1.w3_a[25] Z +s3t1.w3_x 0.318319 +structure parameters +before -1 +str.w3_a[ 0] 1 +str.w3_a[ 1] 2 +str.w3_a[ 2] 3 +str.w3_a[ 3] 4 +str.w3_a[ 4] 5 +str.w3_a[ 5] 6 +str.w3_a[ 6] 7 +str.w3_a[ 7] 8 +str.w3_a[ 8] 9 +str.w3_a[ 9] 10 +str.w3_a[10] 11 +str.w3_a[11] 12 +str.w3_a[12] 13 +str.w3_a[13] 14 +str.w3_a[14] 15 +str.w3_a[15] 16 +str.w3_a[16] 17 +str.w3_a[17] 18 +str.w3_a[18] 19 +str.w3_a[19] 20 +str.w3_a[20] 21 +str.w3_a[21] 22 +str.w3_a[22] 23 +str.w3_a[23] 24 +str.w3_a[24] 25 +str.w3_a[25] 26 +str.w3_x 2.810000 +after 1000 + +Stucture valued functions +myp.w3_a: + 0 97 + 1 96 + 2 95 + 3 94 + 4 93 + 5 92 + 6 91 + 7 90 + 8 89 + 9 88 + 10 87 + 11 86 + 12 85 + 13 84 + 14 83 + 15 82 + 16 81 + 17 80 + 18 79 + 19 78 + 20 77 + 21 76 + 22 75 + 23 74 + 24 73 + 25 72 + 0 99 + 1 100 + 2 101 + 3 102 + 4 103 + 5 104 + 6 105 + 7 106 + 8 107 + 9 108 + 10 109 + 11 110 + 12 111 + 13 112 + 14 113 + 15 114 + 16 115 + 17 116 + 18 117 + 19 118 + 20 119 + 21 120 + 22 121 + 23 122 + 24 123 + 25 124 diff --git a/lang/cem/ctest/makefile b/lang/cem/ctest/makefile new file mode 100644 index 00000000..89b1ad6a --- /dev/null +++ b/lang/cem/ctest/makefile @@ -0,0 +1,53 @@ +.SILENT: +CEM=acc +head: + echo use run + +diffs: $P.cc.r $P.cem.r + echo two compiler diff + -diff $P.*.r + +diffs3: $P.pcc.r $P.cc.r $P.cem.r + echo three compiler diff + -diff3 $P.*.r | tee diffs +egen: $P.e + echo comparing $P.e + -if test -f $P.e.g ; then diff -h $P.e $P.e.g ; else echo creating $P.e.g ; cp $P.e $P.e.g ; fi + rm -f $P.e +$P.e: $P.c + $(CEM) -c.e $P.c +$P.pcc.r: $P.pcc + echo running $P.pcc + -$P.pcc >$P.pcc.r + rm -f $P.pcc +$P.cc.r: $P.cc + echo running $P.cc + -$P.cc >$P.cc.r + rm -f $P.cc +$P.cem.r: $P.cem + echo running $P.cem + -$P.cem >$P.cem.r + rm -f $P.cem +$P.pcc: /tmp + echo pcc $P.c + pcc -o $P.pcc $P.c +$P.cc: /tmp + echo cc $P.c + cc -o $P.cc $P.c +$P.cem: /tmp + echo $(CEM) $P.c + $(CEM) -o $P.cem $P.c +gen: $P.cem.r + echo comparing $P + -if test -f $P.cem.g ; then diff -h $P.cem.r $P.cem.g ; else echo creating $P.cem.g ; cp $P.cem.r $P.cem.g ; fi + +install cmp: + +pr: + @pr `pwd`/$P.c `pwd`/$P.cem.g + +opr: + make pr | opr + +clean: + -rm -f $P.[kmsoe] $P.*.r core a.out *.old em_last em_runinf e.out diff --git a/lang/cem/ctest/makefile.i86 b/lang/cem/ctest/makefile.i86 new file mode 100644 index 00000000..5fec701b --- /dev/null +++ b/lang/cem/ctest/makefile.i86 @@ -0,0 +1,54 @@ +.SILENT: +CEM=i86 -DNOFLOAT +head: + echo use run + +diffs: $P.cc.r $P.cem.r + echo two compiler diff + -diff $P.*.r + +diffs3: $P.pcc.r $P.cc.r $P.cem.r + echo three compiler diff + -diff3 $P.*.r | tee diffs +egen: $P.e + echo comparing $P.e + -if test -f $P.e.g ; then diff -h $P.e $P.e.g ; else echo creating $P.e.g ; cp $P.e $P.e.g ; fi + rm -f $P.e +$P.e: $P.c $(CEM) + $(CEM) -c.e $P.c +$P.pcc.r: $P.pcc + echo running $P.pcc + -$P.pcc >$P.pcc.r + rm -f $P.pcc +$P.cc.r: $P.cc + echo running $P.cc + -$P.cc >$P.cc.r + rm -f $P.cc +$P.cem.r: $P.cem + echo running $P.cem + idl I7 $P.cem + -talk I7 >$P.cem.r + rm -f $P.cem +$P.pcc: $P.c /usr/lib/ccom + echo pcc $P.c + pcc -o $P.pcc $P.c +$P.cc: $P.c /lib/c0 /lib/c1 + echo cc $P.c + cc -o $P.cc $P.c +$P.cem: $P.c + echo $(CEM) $P.c + $(CEM) -o $P.cem $P.c +gen: $P.cem.r + echo comparing $P + -if test -f $P.cem.g ; then diff -h $P.cem.r $P.cem.g ; else echo creating $P.cem.g ; cp $P.cem.r $P.cem.g ; fi + +install cmp: + +pr: + @pr `pwd`/$P.c `pwd`/$P.cem.g + +opr: + make pr | opr + +clean: + -rm -f $P.[kmsoe] $P.*.r core a.out *.old diff --git a/lang/cem/ctest/makefile.int b/lang/cem/ctest/makefile.int new file mode 100644 index 00000000..82c77f0b --- /dev/null +++ b/lang/cem/ctest/makefile.int @@ -0,0 +1,53 @@ +.SILENT: +CEM=int -O +head: + echo use run + +diffs: $P.cc.r $P.cem.r + echo two compiler diff + -diff $P.*.r + +diffs3: $P.pcc.r $P.cc.r $P.cem.r + echo three compiler diff + -diff3 $P.*.r | tee diffs +egen: $P.e + echo comparing $P.e + -if test -f $P.e.g ; then diff -h $P.e $P.e.g ; else echo creating $P.e.g ; cp $P.e $P.e.g ; fi + rm -f $P.e +$P.e: $P.c $(CEM) + $(CEM) -c.e $P.c +$P.pcc.r: $P.pcc + echo running $P.pcc + -$P.pcc >$P.pcc.r + rm -f $P.pcc +$P.cc.r: $P.cc + echo running $P.cc + -$P.cc >$P.cc.r + rm -f $P.cc +$P.cem.r: $P.cem + echo running $P.cem + -/usr/evert/compile/a.out $P.cem >$P.cem.r + rm -f $P.cem +$P.pcc: $P.c /usr/lib/ccom + echo pcc $P.c + pcc -o $P.pcc $P.c +$P.cc: $P.c /lib/c0 /lib/c1 + echo cc $P.c + cc -o $P.cc $P.c +$P.cem: $P.c + echo $(CEM) $P.c + $(CEM) -o $P.cem $P.c +gen: $P.cem.r + echo comparing $P + -if test -f $P.cem.g ; then diff -h $P.cem.r $P.cem.g ; else echo creating $P.cem.g ; cp $P.cem.r $P.cem.g ; fi + +install cmp: + +pr: + @pr `pwd`/$P.c `pwd`/$P.cem.g + +opr: + make pr | opr + +clean: + -rm -f $P.[kmsoe] $P.*.r core a.out *.old diff --git a/lang/cem/ctest/out.std b/lang/cem/ctest/out.std new file mode 100644 index 00000000..ee1b594a --- /dev/null +++ b/lang/cem/ctest/out.std @@ -0,0 +1,174 @@ +Tue May 22 15:12:22 MDT 1984 +***** ctconv +acc conv.c +conv.c +"conv.c", line 41: warning: Overflow in constant expression +running conv.cem +comparing conv +***** ctdecl +acc decl.c +decl.c +running decl.cem +comparing decl +***** ctdivers +acc ops.c +ops.c +running ops.cem +comparing ops +***** cterr +acc bugs.c +bugs.c +"bugs.c", line 92: warning: Overflow in constant expression +running bugs.cem +comparing bugs +9,$c9,$ +< compl_ind +< END +--- +> END +***** ctest1 +acc test.c +test.c +running test.cem +comparing test +***** ctest2 +acc t7.c +t7.c +"t7.c", line 161: warning: statement not reached +"t7.c", line 178: warning: statement not reached +"t7.c", line 182: warning: statement not reached +"t7.c", line 186: warning: statement not reached +"t7.c", line 190: warning: statement not reached +"t7.c", line 194: warning: statement not reached +"t7.c", line 198: warning: statement not reached +"t7.c", line 205: warning: statement not reached +"t7.c", line 207: warning: statement not reached +"t7.c", line 211: warning: statement not reached +"t7.c", line 213: warning: statement not reached +"t7.c", line 287: warning: statement not reached +"t7.c", line 294: warning: statement not reached +"t7.c", line 300: warning: statement not reached +"t7.c", line 307: warning: statement not reached +"t7.c", line 343: warning: statement not reached +"t7.c", line 344: warning: statement not reached +"t7.c", line 345: warning: statement not reached +"t7.c", line 346: warning: statement not reached +"t7.c", line 348: warning: statement not reached +"t7.c", line 452: warning: statement not reached +"t7.c", line 561: warning: statement not reached +"t7.c", line 589: warning: statement not reached +running t7.cem +comparing t7 +***** ctest3 +acc test2.c +test2.c +running test2.cem +comparing test2 +***** ctest5 +acc test1.c +test1.c +"test1.c", line 101: warning: Illegal shift count in constant expression +"test1.c", line 370: warning: illegal pointer combination +"test1.c", line 371: warning: illegal pointer combination +"test1.c", line 372: warning: illegal pointer combination +"test1.c", line 384: warning: illegal pointer combination +"test1.c", line 407: warning: illegal pointer combination +"test1.c", line 408: warning: illegal pointer combination +"test1.c", line 409: warning: illegal pointer combination +"test1.c", line 421: warning: illegal pointer combination +running test1.cem +comparing test1 +***** ctgen +`bf.c' is up to date. +acc bf.c +bf.c +running bf.cem +comparing bf +`cel.c' is up to date. +acc cel.c +cel.c +running cel.cem +comparing cel +`clu.c' is up to date. +acc clu.c +clu.c +"clu.c", line 60: warning: Overflow in constant expression +"clu.c", line 66: warning: Overflow in constant expression +running clu.cem +comparing clu +28c28 +< x *= 40000 0 +--- +> x *= 40000 6784 +65c65 +< y = ( x *= 40000 ) 0 0 +--- +> y = ( x *= 40000 ) 6784 6784 +102c102 +< no if ( x *= 40000 ) yes() ; else no() 0 +--- +> yes if ( x *= 40000 ) yes() ; else no() 6784 +`ec.c' is up to date. +acc ec.c +ec.c +"ec.c", line 58: warning: Overflow in constant expression +"ec.c", line 64: warning: Overflow in constant expression +running ec.cem +comparing ec +`ef.c' is up to date. +acc ef.c +ef.c +running ef.cem +comparing ef +`ei.c' is up to date. +acc ei.c +ei.c +"ei.c", line 22: warning: Overflow in constant expression +"ei.c", line 65: warning: Overflow in constant expression +"ei.c", line 108: warning: Overflow in constant expression +running ei.cem +comparing ei +`el.c' is up to date. +acc el.c +el.c +running el.cem +comparing el +`eu.c' is up to date. +acc eu.c +eu.c +"eu.c", line 58: warning: Overflow in constant expression +"eu.c", line 64: warning: Overflow in constant expression +running eu.cem +comparing eu +28c28 +< x *= 40000 0 +--- +> x *= 40000 6784 +65c65 +< y = ( x *= 40000 ) 0 0 +--- +> y = ( x *= 40000 ) 6784 6784 +102c102 +< no if ( x *= 40000 ) yes() ; else no() 0 +--- +> yes if ( x *= 40000 ) yes() ; else no() 6784 +`id.c' is up to date. +acc id.c +id.c +running id.cem +comparing id +`lc.c' is up to date. +acc lc.c +lc.c +"lc.c", line 60: warning: Overflow in constant expression +"lc.c", line 66: warning: Overflow in constant expression +running lc.cem +comparing lc +`ld.c' is up to date. +acc ld.c +ld.c +running ld.cem +comparing ld +`lf.c' is up to date. +acc lf.c +lf.c diff --git a/lang/cem/libcc.ansi/MakeArch b/lang/cem/libcc.ansi/MakeArch new file mode 100755 index 00000000..389363b0 --- /dev/null +++ b/lang/cem/libcc.ansi/MakeArch @@ -0,0 +1,66 @@ +: $Header$ +: This script makes an archive. The only option it knows is -o, which +: creates a library. + +rm -f OLIST + +case $# in + 0) + AR=tar + OLIB=libsrc + echo 'cf libsrc' > OLIST + ;; + 1) + if [ "X$1" != "X-o" ] + then + echo $0: unrecognised option, I only know -o >&2 + exit 1 + fi + AR=$ASAR + echo "rv $OLIB" > OLIST + ;; + *) + echo $0: too many arguments >&2 + exit 1 + ;; +esac + +if [ "X$AR" = "X" ] +then +echo EEK -- internal error, no archiver >&2 +exit 1 +fi + +if [ $AR = tar ] +then + echo LIST >> OLIST + echo MakeArch >> OLIST + echo Makefile >> OLIST + echo make.proto >> OLIST + echo head_ac.e >> OLIST +fi + +DIRS=`cat LIST` + +for i in $DIRS +do + cd $i + if make "MACH=$MACH" "MACHFL=$MACHFL" "SUF=$SUF" $AR -f ../Makefile + then + cd .. + if [ $AR = tar ] + then + echo $i/Makefile >> OLIST + echo $i/LIST >> OLIST + fi + for j in `cat $i/OLIST` + do + echo $i/$j >> OLIST + done + else + exit 1 + fi +done + +$AR `cat OLIST` +${RANLIB-:} $OLIB diff --git a/lang/cem/libcc.ansi/Makefile b/lang/cem/libcc.ansi/Makefile new file mode 100644 index 00000000..c891159d --- /dev/null +++ b/lang/cem/libcc.ansi/Makefile @@ -0,0 +1,50 @@ +# $Header$ +# This Makefile is used for building the source archive as well as the +# actual library. + +EMHOME=../../.. +MACH=acc +MACHFL=-O -L -Rcem=$(EMHOME)/lib/em_cemcom.ansi -I../headers $(DEFS) +PREF=ac +SUB= +ASAR=arch +HEADSRC=$(HOME) +OLIB=tail_$(PREF)$(SUB) + +install: + MakeArch + -mkdir $(EMHOME)/include/tail_ac + ( cd headers; tar cf - `cat LIST` ) | ( cd $(EMHOME)/include/tail_ac ; tar xf - ) + +clean: + rm -f OLIST */OLIST + (cd ctype; make clean) + (cd stdlib; make clean) + +headcp: head + ../../install head_$(PREF).$(SUF) head_$(PREF) + rm -f head_$(PREF).$(SUF) + +head: head_$(PREF).e + make -r -f make.proto "CC=$(MACH)" "CFLAGS=-I$(EMHOME)/h $(MACHFL)" head_$(PREF).$(SUF) + +tail: lib + +tailcp: tail + ../../install $(OLIB) + rm -f $(OLIB) + +lib: + MACH=$(MACH) MACHFL="$(MACHFL) -LIB" ASAR=$(ASAR) SUF=$(SUF) \ + OLIB=$(OLIB) MakeArch -o + +ar aal arch: + @rm -f OLIST + @sed 's/\.[ce]/.$(SUF)/' < LIST | sed '/\.h/D' > OLIST + make -r -f ../make.proto "CC=$(MACH)" "CFLAGS=$(MACHFL)" `cat OLIST` + +# arch doesn't work recursively, tar does, which is what we actually want +tar: + @rm -f OLIST + make `cat LIST` + cp LIST OLIST diff --git a/lang/cem/libcc.ansi/ctype/ctype.c b/lang/cem/libcc.ansi/ctype/ctype.c new file mode 100644 index 00000000..f298d403 --- /dev/null +++ b/lang/cem/libcc.ansi/ctype/ctype.c @@ -0,0 +1,76 @@ +/* + * ctype.c - character handling + */ +/* $Header$ */ + +int isalnum(int c); /* Alpha numeric character */ +int isalpha(int c); /* Alpha character */ +int iscntrl(int c); /* Control character */ +int isdigit(int c); /* Digit character */ +int isgraph(int c); /* Graphical character */ +int islower(int c); /* Lower case character */ +int isprint(int c); /* Printable character */ +int ispunct(int c); /* Punctuaction character */ +int isspace(int c); /* Space character */ +int isupper(int c); /* Upper case character */ +int isxdigit(int c); /* Hexdecimal digit character */ + +int tolower(int c); /* Convert to lower case character */ +int toupper(int c); /* Convert to upper case character */ + +int isalnum(int c) { /* Alpha numeric character */ + return isdigit(c) || isalpha(c); +} + +int isalpha(int c) { /* Alpha character */ + return isupper(c) || islower(c); +} + +int iscntrl(int c) { /* Control character */ + return (c >= 0 && c <= 0x1f) || c == 0x7f; +} + +int isdigit(int c) { /* Digit character */ + return (unsigned)(c - '0') < 10; +} + +int isgraph(int c) { /* Graphical character */ + return isprint(c) && c != ' '; +} + +int islower(int c) { /* Lower case character */ + return (unsigned)(c - 'a') < 26; +} + +int isprint(int c) { /* Printable character */ + return c > ' ' && c < 0x7f; +} + +int ispunct(int c) { /* Punctuation character */ + return isprint(c) && !(c == ' ' || isalnum(c)); +} + +int isspace(int c) { /* Space character */ + return c == ' ' || c == '\f' || c == '\n' || + c == '\r' || c == '\t' || c == '\v'; +} + +int isupper(int c) { /* Upper case character */ + return (unsigned)(c - 'A') < 26; +} + +int isxdigit(int c) { /* Hexdecimal digit character */ + return isdigit(c) || + (c >= 'A' && c <= 'F') || + (c >= 'a' && c <= 'f'); +} + +int tolower(int c) { /* Convert to lower case character */ + if (!isupper(c)) return c; + else return c - 'A' + 'a'; +} + +int toupper(int c) { /* Convert to upper case character */ + if (!islower(c)) return c; + else return c - 'a' + 'A'; +} diff --git a/lang/cem/libcc.ansi/ctype/genfiles.c b/lang/cem/libcc.ansi/ctype/genfiles.c new file mode 100644 index 00000000..06fa7faa --- /dev/null +++ b/lang/cem/libcc.ansi/ctype/genfiles.c @@ -0,0 +1,51 @@ +#include +#if __STDC__ == 1 +#include +#include +#else +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE 1 +#endif + +#define UCHAR_MAX 256 + +char *functab[] = { + "isalnum", + "isalpha", + "iscntrl", + "isdigit", + "isgraph", + "islower", + "isprint", + "ispunct", + "isspace", + "isupper", + "isxdigit", + "isascii", + "toupper", + "tolower", + NULL, +}; + +char buf[100]; + +int +main() +{ + register char **name; + register int i; + FILE *file; + + name = functab; + while (*name) { + strcpy(buf, *name); + strcat(buf, ".c"); + if (!(file = fopen(buf,"w"))) exit(EXIT_FAILURE); + fprintf(file,"int (%s)(int c) {\n", *name); + fprintf(file,"\treturn %s(c);\n", *name); + fprintf(file,"}\n"); + fclose(file); + name++; + } + exit(EXIT_SUCCESS); +} diff --git a/lang/cem/libcc.ansi/errno/errno.c b/lang/cem/libcc.ansi/errno/errno.c new file mode 100644 index 00000000..afe0a50e --- /dev/null +++ b/lang/cem/libcc.ansi/errno/errno.c @@ -0,0 +1,11 @@ +/* + * errno.h - error codes + * + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header */ + +#include + +int errno = 0; diff --git a/lang/cem/libcc.ansi/headers/sgtty.h b/lang/cem/libcc.ansi/headers/sgtty.h new file mode 100644 index 00000000..6e2295f5 --- /dev/null +++ b/lang/cem/libcc.ansi/headers/sgtty.h @@ -0,0 +1,72 @@ +/* $Header$ */ + +#if !defined(_SGTTY_H) +#define _SGTTY_H +/* Data structures for IOCTL. */ + +struct sgttyb { + char sg_ispeed; /* input speed */ + char sg_ospeed; /* output speed */ + char sg_erase; /* erase character */ + char sg_kill; /* kill character */ +#if defined(__USG) && !defined(_XENIX) + int sg_flags; /* mode flags */ +#else + short sg_flags; /* mode flags */ +#endif +}; + +struct tchars { + char t_intrc; /* SIGINT char */ + char t_quitc; /* SIGQUIT char */ + char t_startc; /* start output (initially CTRL-Q) */ + char t_stopc; /* stop output (initially CTRL-S) */ + char t_eofc; /* EOF (initially CTRL-D) */ + char t_brkc; /* input delimiter (like nl) */ +}; + +/* Field names */ +#if defined(__USG) && !defined(_XENIX) +#define XTABS 0000002 /* do tab expansion */ +#else +#define XTABS 0006000 /* do tab expansion */ +#endif +#define EVENP 0000200 /* even parity */ +#define ODDP 0000100 /* odd parity */ +#define RAW 0000040 /* enable raw mode */ +#define CRMOD 0000020 /* map lf to cr + lf */ +#define ECHO 0000010 /* echo input */ +#define LCASE 0000004 /* map upper case to lower on input */ +#define CBREAK 0000002 /* enable cbreak mode */ +#if defined(__BSD4_2) || defined(_XENIX) +#define TANDEM 0000001 /* automatic flow control */ +#else +#define HUPCL 0000001 /* unused ??? */ +#endif +#define COOKED 0000000 /* neither CBREAK nor RAW */ + +#define B0 0 +#define B50 1 +#define B75 2 +#define B110 3 +#define B134 4 +#define B150 5 +#define B200 6 +#define B300 7 +#define B600 8 +#define B1200 9 +#define B1800 10 +#define B2400 11 +#define B4800 12 +#define B9600 13 +#define B19200 14 +#define B38400 15 +#define EXTA 14 +#define EXTB 15 + +#define TIOCGETP (('t'<<8) | 8) +#define TIOCSETP (('t'<<8) | 9) +#define TIOCGETC (('t'<<8) | 18) +#define TIOCSETC (('t'<<8) | 17) + +#endif /* _SGTTY_H */ diff --git a/lang/cem/libcc.ansi/headers/sys/stat.h b/lang/cem/libcc.ansi/headers/sys/stat.h new file mode 100644 index 00000000..802f2a31 --- /dev/null +++ b/lang/cem/libcc.ansi/headers/sys/stat.h @@ -0,0 +1,85 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#if !defined(_SYS_STAT_H) +#define _SYS_STAT_H + +struct stat { + dev_t st_dev; + ino_t st_ino; + u_short st_mode; + short st_nlink; + short st_uid; + short st_gid; + dev_t st_rdev; + off_t st_size; + time_t st_atime; +#if defined(__BSD4_2) + long st_spare1; +#endif + time_t st_mtime; +#if defined(__BSD4_2) + long st_spare2; +#endif + time_t st_ctime; +#if defined(__BSD4_2) + long st_spare3; + long st_blksize; + long st_blocks; + long st_spare4[2]; +#endif +}; + +#define S_IFMT 0170000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFBLK 0060000 +#define S_IFREG 0100000 +#if !defined(__BSD4_2) +#if !defined(__USG) && !defined(_POSIX_SOURCE) +#define S_IFMPC 0030000 +#define S_IFMPB 0070000 +#else +#define S_IFIFO 0010000 +#endif +#else +#define S_IFLNK 0120000 +#define S_IFSOCK 0140000 +#endif +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 +#define S_IREAD 0000400 +#define S_IWRITE 0000200 +#define S_IEXEC 0000100 + +#if defined(__BSD4_2) || defined(_POSIX_SOURCE) +#define S_IRWXU 00700 /* owner: rwx------ */ +#define S_IRUSR 00400 /* owner: r-------- */ +#define S_IWUSR 00200 /* owner: -w------- */ +#define S_IXUSR 00100 /* owner: --x------ */ + +#define S_IRWXG 00070 /* group: ---rwx--- */ +#define S_IRGRP 00040 /* group: ---r----- */ +#define S_IWGRP 00020 /* group: ----w---- */ +#define S_IXGRP 00010 /* group: -----x--- */ + +#define S_IRWXO 00007 /* others: ------rwx */ +#define S_IROTH 00004 /* others: ------r-- */ +#define S_IWOTH 00002 /* others: -------w- */ +#define S_IXOTH 00001 /* others: --------x */ + +#if defined(_POSIX_SOURCE) +/* The following macros test st_mode (from POSIX Sec. 5.6.1.1.) */ +#define S_ISREG(m) ((m & S_IFMT) == S_IFREG) /* is a reg file */ +#define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) /* is a directory */ +#define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR) /* is a char spec */ +#define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK) /* is a block spec */ +#define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO) /* is a pipe/FIFO */ +#endif /* _POSIX_SOURCE */ +#endif /* BSD4_2 || _POSIX_SOURCE */ + +#endif /* _SYS_STAT_H */ diff --git a/lang/cem/libcc.ansi/headers/sys/types.h b/lang/cem/libcc.ansi/headers/sys/types.h new file mode 100644 index 00000000..9004c093 --- /dev/null +++ b/lang/cem/libcc.ansi/headers/sys/types.h @@ -0,0 +1,77 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* + * Basic system types and major/minor device constructing/busting macros. + */ +/* $Header$ */ + +#if !defined(_SYS_TYPES_H) +#define _SYS_TYPES_H + +#if !defined(_SIZE_T) +#define _SIZE_T +typedef unsigned int size_t; /* type returned by sizeof */ +#endif /* _SIZE_T */ + +#if !defined(_TIME_T) +#define _TIME_T +typedef unsigned long time_t; +#endif /* TIME_T */ + +#if !defined(_POSIX_SOURCE) + +/* major part of a device */ +#define major(x) ((int)(((unsigned)(x)>>8)&0377)) + +/* minor part of a device */ +#define minor(x) ((int)((x)&0377)) + +/* make a device number */ +#define makedev(x,y) ((dev_t)(((x)<<8) | (y))) + +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; + +typedef struct _physadr { int r[1]; } *physadr; +typedef long daddr_t; +typedef char * caddr_t; +#if defined(__BSD4_2) +typedef u_long ino_t; +#else +typedef u_short ino_t; +#endif +typedef long swblk_t; + +typedef long label_t[14]; +typedef short dev_t; +#if defined(__BSD4_2) +typedef int off_t; /* see lseek(2) */ +#else +typedef long off_t; +#endif + +/* system V compatibility: */ +typedef unsigned int uint; +typedef unsigned short ushort; +typedef unsigned char uchar_t; +typedef short cnt_t; +typedef long paddr_t; +typedef long key_t; +#else /* _POSIX_SOURCE */ +#if defined(_MINIX) +typedef unsigned short dev_t; /* hold (major|minor) device pair */ +typedef unsigned char gid_t; /* group id */ +typedef unsigned short ino_t; /* i-node number */ +typedef unsigned short mode_t; /* mode number within an i-node */ +typedef unsigned char nlink_t; /* number-of-links field within an i-node */ +typedef long off_t; /* offsets within a file */ +typedef int pid_t; /* type for pids (must be signed) */ +typedef unsigned short uid_t; /* user id */ +#endif /* _MINIX */ +#endif /* _POSIX_SOURCE */ + +#endif /* _SYS_TYPES_H */ diff --git a/lang/cem/libcc.ansi/make.proto b/lang/cem/libcc.ansi/make.proto new file mode 100644 index 00000000..f15130c2 --- /dev/null +++ b/lang/cem/libcc.ansi/make.proto @@ -0,0 +1,6 @@ +.SUFFIXES: .o .e .c .m .s + +.c.o .e.o .c.m .e.m .c.s .e.s: + $(CC) $(CFLAGS) -c $< + +fake: diff --git a/lang/cem/libcc.ansi/math/cosh.c b/lang/cem/libcc.ansi/math/cosh.c new file mode 100644 index 00000000..89456e76 --- /dev/null +++ b/lang/cem/libcc.ansi/math/cosh.c @@ -0,0 +1,33 @@ +/* + * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Ceriel J.H. Jacobs + */ +/* $Header$ */ + +#include +#include +#include "localmath.h" + +double +cosh(double x) +{ + if (x < 0) { + x = -x; + } + if (x > M_LN_MAX_D) { + /* exp(x) would overflow */ + if (x >= M_LN_MAX_D + M_LN2) { + /* not representable */ + x = HUGE_VAL; + errno = ERANGE; + } + else x = exp (x - M_LN2); + } + else { + double expx = exp(x); + x = 0.5 * (expx + 1.0/expx); + } + return x; +} diff --git a/lang/cem/libcc.ansi/stdio/gcvt.c b/lang/cem/libcc.ansi/stdio/gcvt.c new file mode 100644 index 00000000..5cfa750d --- /dev/null +++ b/lang/cem/libcc.ansi/stdio/gcvt.c @@ -0,0 +1,77 @@ +/* + * gcvt.c - conversion for printing a floating point number + */ +/* $Header$ */ + +#ifndef NOFLOAT +#include "loc_incl.h" + +#define NDIGINEXP(exp) (((exp) >= 100 || (exp) <= -100) ? 3 : 2) +#define LOW_EXP -4 +#define USE_EXP(exp, ndigits) (((exp) < LOW_EXP + 1) || (exp >= ndigits + 1)) + +char * +_gcvt(long double value, int ndigit, char *s, int flags) +{ + int sign, dp; + register char *s1, *s2; + register int i; + register int nndigit = ndigit; + + s1 = _ecvt(value, ndigit, &dp, &sign); + s2 = s; + if (sign) *s2++ = '-'; + else if (flags & FL_SIGN) + *s2++ = '+'; + else if (flags & FL_SPACE) + *s2++ = ' '; + + if (!(flags & FL_ALT)) + for (i = nndigit - 1; i > 0 && s1[i] == '0'; i--) + nndigit--; + + if (USE_EXP(dp,ndigit)) { + /* Use E format */ + dp--; + *s2++ = *s1++; + if ((nndigit > 1) || (flags & FL_ALT)) *s2++ = '.'; + while (--nndigit > 0) *s2++ = *s1++; + *s2++ = 'e'; + if (dp < 0) { + *s2++ = '-'; + dp = -dp; + } + else *s2++ = '+'; + s2 += NDIGINEXP(dp); + *s2 = 0; + for (i = NDIGINEXP(dp); i > 0; i--) { + *--s2 = dp % 10 + '0'; + dp /= 10; + } + return s; + } + /* Use f format */ + if (dp <= 0) { + if (*s1 != '0') { + /* otherwise the whole number is 0 */ + *s2++ = '0'; + *s2++ = '.'; + } + while (dp < 0) { + dp++; + *s2++ = '0'; + } + } + for (i = 1; i <= nndigit; i++) { + *s2++ = *s1++; + if (i == dp) *s2++ = '.'; + } + if (i <= dp) { + while (i++ <= dp) *s2++ = '0'; + *s2++ = '.'; + } + if ((s2[-1]=='.') && !(flags & FL_ALT)) s2--; + *s2 = '\0'; + return s; +} +#endif /* NOFLOAT */ diff --git a/lang/cem/libcc.ansi/stdlib/calloc.c b/lang/cem/libcc.ansi/stdlib/calloc.c new file mode 100644 index 00000000..90c664ce --- /dev/null +++ b/lang/cem/libcc.ansi/stdlib/calloc.c @@ -0,0 +1,24 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +#define ALIGN(sz) (((sz)+(sizeof(long)-1)/sizeof(long))*sizeof(long)) + +void * +calloc(size_t nelem, size_t elsize) +{ + register void *p; + register long *q; + unsigned int size = ALIGN(nelem * elsize); + + if ((p = malloc(size)) == (void *)NULL) + return (void *)NULL; + /* "The space is intialized to all bits zero" */ + q = (long *) (p + size); + while ((void *) q > p) *--q = 0; + return p; +} diff --git a/lang/cem/libcc.ansi/stdlib/malloc.c b/lang/cem/libcc.ansi/stdlib/malloc.c new file mode 100644 index 00000000..0015f510 --- /dev/null +++ b/lang/cem/libcc.ansi/stdlib/malloc.c @@ -0,0 +1,127 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +#define CLICK_SIZE 4096 + +#if EM_WSIZE == EM_PSIZE +typedef unsigned int vir_bytes; +#else +typedef long vir_bytes; +#endif + + +#define ALIGN(x, a) (((x) + (a - 1)) & ~(a - 1)) +#define BUSY 1 +#define NEXT(p) (* (void **) (p)) + +#ifdef pdp +#define BUGFIX 64 /* cannot set break in top 64 bytes */ +#else +#define BUGFIX 0 +#endif + +extern void bcopy(void *, void *, size_t); +extern void *sbrk(unsigned int); +extern void *brk(unsigned int); +static void *bottom, *top; + +static int +grow(size_t len) +{ + register void *p; + register int click = CLICK_SIZE; + + p = sbrk(0); + len += (void *) ALIGN((vir_bytes) p, sizeof(void *)) - p; + while (click >= 4) { + size_t len1 = ALIGN((vir_bytes)p+len+sizeof(char *),click)-(vir_bytes)p; + void *p1 = p; + + if (p + len1 + BUGFIX < p || (p1 = sbrk(len1)) == (void *) -1) { + click >>= 1; + continue; + } + p = p1; + if (top + sizeof(void *) != p) { + /* someone else has done an sbrk */ + NEXT(top) = (void *) ((vir_bytes) p | BUSY); + } else { + for (p = bottom; NEXT(p) != NULL; p = (void *) (* (vir_bytes *) p & ~BUSY)) + ; + } + top = p + len1 - sizeof(void *); + NEXT(p) = top; + NEXT(top) = NULL; + return 1; + } + return 0; +} + +void * +malloc(size_t size) +{ + register void *p, *next, *new; + register size_t len = ALIGN(size, sizeof(void *)) + sizeof(void *); + + if ((p = bottom) == NULL) { + p = sbrk(sizeof(void *)); + sbrk((void *) ALIGN((vir_bytes) p, sizeof(void *)) - p); + p = (void *) ALIGN((vir_bytes) p, sizeof(void *)); + top = bottom = p; + NEXT(p) = NULL; + } + while ((next = NEXT(p)) != NULL) + if ((vir_bytes) next & BUSY) /* already in use */ + p = (void *) ((vir_bytes) next & ~BUSY); + else { + while ((new = NEXT(next)) != NULL + && !((vir_bytes) new & BUSY)) + next = new; + if (next - p >= len) { /* fits */ + if ((new = p + len) < next) /* too big */ + NEXT(new) = next; + NEXT(p) = (void *) ((vir_bytes) new | BUSY); + return(p + sizeof(void *)); + } + p = next; + } + return grow(len) ? malloc(size) : (void *)NULL; +} + +void * +realloc(void *old, size_t size) +{ + register void *p = old - sizeof(void *), *next, *new; + register size_t len = ALIGN(size, sizeof(void *)) + sizeof(void *), n; + + next = (void *) (* (vir_bytes *) p & ~BUSY); + n = next - old; /* old size */ + while ((new = NEXT(next)) != NULL && !((vir_bytes) new & BUSY)) + next = new; + if (next - p >= len) { /* does it still fit */ + if ((new = p + len) < next) { /* even too big */ + NEXT(new) = next; + NEXT(p) = (void *) ((vir_bytes) new | BUSY); + } + else + NEXT(p) = (void *) ((vir_bytes) next | BUSY); + return(old); + } + if ((new = malloc(size)) == NULL) /* it didn't fit */ + return((void *)NULL); + bcopy(old, new, n); /* n < size */ + * (vir_bytes *) p &= ~BUSY; + return(new); +} + +void +free(void *p) +{ + if (p != (void *)NULL) + *(vir_bytes *) (p - sizeof(void *)) &= ~BUSY; +} diff --git a/lang/cem/libcc.ansi/time/loc_incl.h b/lang/cem/libcc.ansi/time/loc_incl.h new file mode 100644 index 00000000..5ccbb4c5 --- /dev/null +++ b/lang/cem/libcc.ansi/time/loc_incl.h @@ -0,0 +1,26 @@ +/* + * loc_incl.h - some local definitions + */ +/* $Header$ */ + +#define YEAR0 1900 /* the first year */ +#define EPOCH_YR 1970 /* EPOCH = Jan 1 1970 00:00:00 */ +#define SECS_DAY (24L * 60L * 60L) +#define LEAPYEAR(year) (!((year) % 4) && (((year) % 100) || !((year) % 400))) +#define YEARSIZE(year) (LEAPYEAR(year) ? 366 : 365) +#define FIRSTSUNDAY(timp) (((timp)->tm_yday - (timp)->tm_wday + 420) % 7) +#define FIRSTDAYOF(timp) (((timp)->tm_wday - (timp)->tm_yday + 420) % 7) +#define TIME_MAX ULONG_MAX +#define ABB_LEN 3 + +extern const int _ytab[2][12]; +extern const char *_days[]; +extern const char *_months[]; + +void _tzset(void); +unsigned _dstget(struct tm *timep); + +extern long _timezone; +extern long _dst_off; +extern int _daylight; +extern char *_tzname[2]; diff --git a/lang/cem/libcc/gen/getopt.c b/lang/cem/libcc/gen/getopt.c new file mode 100644 index 00000000..7e4b0d3d --- /dev/null +++ b/lang/cem/libcc/gen/getopt.c @@ -0,0 +1,58 @@ +/* $Header$ */ +#include +#define ERR(s, c) if(opterr){\ + fputs(argv[0], stderr);\ + fputs(s, stderr);\ + fputc(c, stderr);\ + fputc('\n', stderr);} + +int opterr = 1; +int optind = 1; +int optopt; +char *optarg; +char *index(); + +int +getopt (argc, argv, opts) +char **argv, *opts; +{ + static int sp = 1; + register c; + register char *cp; + + if (sp == 1) + if (optind >= argc || + argv[optind][0] != '-' || argv[optind][1] == '\0') + return EOF; + else if (strcmp(argv[optind], "--") == NULL) { + optind++; + return EOF; + } + optopt = c = argv[optind][sp]; + if (c == ':' || (cp=index(opts, c)) == NULL) { + ERR (": illegal option -- ", c); + if (argv[optind][++sp] == '\0') { + optind++; + sp = 1; + } + return '?'; + } + if (*++cp == ':') { + if (argv[optind][sp+1] != '\0') + optarg = &argv[optind++][sp+1]; + else if (++optind >= argc) { + ERR (": option requires an argument -- ", c); + sp = 1; + return '?'; + } else + optarg = argv[optind++]; + sp = 1; + } else { + if (argv[optind][++sp] == '\0') { + sp = 1; + optind++; + } + optarg = NULL; + } + return c; +} diff --git a/lang/cem/libcc/math/cosh.c b/lang/cem/libcc/math/cosh.c new file mode 100644 index 00000000..4cecd4e5 --- /dev/null +++ b/lang/cem/libcc/math/cosh.c @@ -0,0 +1,38 @@ +/* + * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Ceriel J.H. Jacobs + */ + +/* $Header$ */ + +#include +#include + +extern int errno; + +double +cosh(x) + double x; +{ + extern double exp(); + + if (x < 0) { + x = -x; + } + if (x > M_LN_MAX_D) { + /* exp(x) would overflow */ + if (x >= M_LN_MAX_D + M_LN2) { + /* not representable */ + x = HUGE; + errno = ERANGE; + } + else x = exp (x - M_LN2); + } + else { + double expx = exp(x); + x = 0.5 * (expx + 1.0/expx); + } + return x; +} diff --git a/lang/m2/comp/Parameters b/lang/m2/comp/Parameters new file mode 100644 index 00000000..a05f79a4 --- /dev/null +++ b/lang/m2/comp/Parameters @@ -0,0 +1,78 @@ +!File: errout.h +#define ERROUT STDERR /* file pointer for writing messages */ +#define MAXERR_LINE 100 /* maximum number of error messages given + on the same input line. */ + + +!File: idfsize.h +#define IDFSIZE 128 /* maximum significant length of an identifier */ + + +!File: numsize.h +#define NUMSIZE 256 /* maximum length of a numeric constant */ + + +!File: strsize.h +#define ISTRSIZE 32 /* minimum number of bytes allocated for + storing a string */ +#define RSTRSIZE 8 /* step size in enlarging the memory for + the storage of a string */ + + +!File: target_sizes.h +#define MAXSIZE 8 /* the maximum of the SZ_* constants */ + +/* target machine sizes */ +#define SZ_CHAR ((arith)1) +#define SZ_SHORT ((arith)2) +#define SZ_WORD ((arith)4) +#define SZ_INT ((arith)4) +#define SZ_LONG ((arith)4) +#define SZ_FLOAT ((arith)4) +#define SZ_DOUBLE ((arith)8) +#define SZ_POINTER ((arith)4) + +/* target machine alignment requirements */ +#define AL_CHAR 1 +#define AL_SHORT ((int)SZ_SHORT) +#define AL_WORD ((int)SZ_WORD) +#define AL_INT ((int)SZ_WORD) +#define AL_LONG ((int)SZ_WORD) +#define AL_FLOAT ((int)SZ_WORD) +#define AL_DOUBLE ((int)SZ_WORD) +#define AL_POINTER ((int)SZ_WORD) +#define AL_STRUCT ((int)SZ_WORD) + + +!File: debugcst.h +#define DEBUG 1 /* perform various self-tests */ + +!File: inputtype.h +#define INP_READ_IN_ONE 1 /* read input file in one */ + + +!File: density.h +#define DENSITY 3 /* see casestat.C for an explanation */ + + +!File: squeeze.h +#undef SQUEEZE 1 /* define on "small" machines */ + + +!File: strict3rd.h +#undef STRICT_3RD_ED 1 /* define on "small" machines, and if you want + a compiler that only implements "3rd edition" + Modula-2 + */ + + +!File: nocross.h +#undef NOCROSS 1 /* define when cross-compiler not needed */ + + +!File: nostrict.h +#undef NOSTRICT 1 /* define when STRICT warnings disabled + (yet another squeezing method) + */ + + diff --git a/lang/m2/comp/Resolve b/lang/m2/comp/Resolve new file mode 100755 index 00000000..e64381d5 --- /dev/null +++ b/lang/m2/comp/Resolve @@ -0,0 +1,60 @@ +: create a directory Xsrc with name clashes resolved +: and run make in that directory +: '$Header$' + +case $# in +1) + ;; +*) echo "$0: one argument expected" 1>&2 + exit 1 + ;; +esac +PW=`pwd` +case $1 in +main) target=$PW/$1 + ;; +omain) target=$PW/$1 + options=-DPEEPHOLE + ;; +cemain) target=$PW/$1 + options=-DCODE_EXPANDER + ;; +Xlint) target=$1 + ;; +*) echo "$0: $1: Illegal argument" 1>&2 + exit 1 + ;; +esac +if test -d ../Xsrc +then + : +else mkdir ../Xsrc +fi +make EMHOME=$EMHOME longnames +: remove code generating routines from the clashes list as they are defines. +: code generating routine names start with C_ +sed '/^C_/d' < longnames > tmp$$ +cclash -c -l7 tmp$$ > ../Xsrc/Xclashes +rm -f tmp$$ +cd ../Xsrc +if cmp -s Xclashes clashes +then + : +else + mv Xclashes clashes +fi +rm -f Makefile +ed - $PW/Makefile <<'EOF' +/^#EXCLEXCL/,/^#INCLINCL/d +w Makefile +q +EOF +for i in `cat $PW/Cfiles` +do + cat >> Makefile < $i +EOF +done +make EMHOME=$EMHOME COPTIONS=$options MACH=$MACH CURRDIR=$PW/ $target diff --git a/lang/m2/comp/Version.c b/lang/m2/comp/Version.c new file mode 100644 index 00000000..55fe3ced --- /dev/null +++ b/lang/m2/comp/Version.c @@ -0,0 +1 @@ +static char Version[] = "ACK Modula-2 compiler Version 0.50"; diff --git a/lang/m2/comp/const.h b/lang/m2/comp/const.h new file mode 100644 index 00000000..4aa261a6 --- /dev/null +++ b/lang/m2/comp/const.h @@ -0,0 +1,15 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Ceriel J.H. Jacobs + */ + +/* C O N S T A N T S F O R E X P R E S S I O N H A N D L I N G */ + +/* $Header$ */ + +#define arith_sign ((arith) (1L << (sizeof(arith) * 8 - 1))) + +extern unsigned int + wrd_bits; /* Number of bits in a word */ diff --git a/lang/m2/comp/def_sizes.h b/lang/m2/comp/def_sizes.h new file mode 100644 index 00000000..a8543f8b --- /dev/null +++ b/lang/m2/comp/def_sizes.h @@ -0,0 +1,22 @@ +/* D E F A U L T S I Z E S A N D A L I G N M E N T S */ + +/* $Header$ */ + +#define MAXSIZE 8 /* the maximum of the SZ_* constants */ +/* target machine sizes */ +#define SZ_CHAR (arith)1 +#define SZ_WORD (arith)4 +#define SZ_INT (arith)4 +#define SZ_LONG (arith)4 +#define SZ_FLOAT (arith)4 +#define SZ_DOUBLE (arith)8 +#define SZ_POINTER (arith)4 +/* target machine alignment requirements */ +#define AL_CHAR 1 +#define AL_WORD (int) SZ_WORD +#define AL_INT (int) SZ_WORD +#define AL_LONG (int) SZ_WORD +#define AL_FLOAT (int) SZ_WORD +#define AL_DOUBLE (int) SZ_WORD +#define AL_POINTER (int) SZ_WORD +#define AL_STRUCT 1 diff --git a/lang/m2/comp/desig.H b/lang/m2/comp/desig.H new file mode 100644 index 00000000..99456818 --- /dev/null +++ b/lang/m2/comp/desig.H @@ -0,0 +1,69 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Ceriel J.H. Jacobs + */ + +/* D E S I G N A T O R D E S C R I P T I O N S */ + +/* $Header$ */ + +/* Generating code for designators is not particularly easy, especially if + you don't know wether you want the address or the value. + The next structure is used to generate code for designators. + It contains information on how to find the designator, after generation + of the code that is common to both address and value computations. +*/ + +struct desig { + short dsg_kind; +#define DSG_INIT 0 /* don't know anything yet */ +#define DSG_LOADED 1 /* designator loaded on top of the stack */ +#define DSG_PLOADED 2 /* designator accessible through pointer on + stack, possibly with an offset + */ +#define DSG_FIXED 3 /* designator directly accessible */ +#define DSG_PFIXED 4 /* designator accessible through directly + accessible pointer + */ +#define DSG_INDEXED 5 /* designator accessible through array + operation. Address of array descriptor on + top of the stack, index beneath that, and + base address beneath that + */ + arith dsg_offset; /* contains an offset for PLOADED, + or for FIXED or PFIXED it contains an + offset from dsg_name, if it exists, + or from the current Local Base + */ + char *dsg_name; /* name of global variable, used for + FIXED and PFIXED + */ + struct def *dsg_def; /* def structure associated with this + designator, or 0 + */ +}; + +typedef struct desig t_desig; + +/* ALLOCDEF "desig" 5 */ + +/* The next structure describes the designator in a with-statement. + We have a linked list of them, as with-statements may be nested. +*/ + +struct withdesig { + struct withdesig *w_next; + int w_flags; /* D_USED|D_DEFINED */ + struct scope *w_scope; /* scope in which fields of this record + reside + */ + t_desig w_desig; /* a desig structure for this particular + designator + */ +}; + +extern struct withdesig *WithDesigs; + +#define NO_LABEL ((label) 0) diff --git a/lang/m2/comp/idlist.H b/lang/m2/comp/idlist.H new file mode 100644 index 00000000..9d320bb9 --- /dev/null +++ b/lang/m2/comp/idlist.H @@ -0,0 +1,12 @@ +/* $Header$ */ + +#include + +/* Structure to link idf structures together +*/ +struct id_list { + struct id_list *next; + struct idf *id_ptr; +}; + +/* ALLOCDEF "id_list" */ diff --git a/lang/m2/comp/idlist.c b/lang/m2/comp/idlist.c new file mode 100644 index 00000000..3b067af2 --- /dev/null +++ b/lang/m2/comp/idlist.c @@ -0,0 +1,20 @@ +static char *RcsId = "$Header$"; + +#include "idf.h" +#include "idlist.h" + +struct id_list *h_id_list; /* Header of free list */ + +/* FreeIdList: take a list of id_list structures and put them + on the free list of id_list structures +*/ +FreeIdList(p) + struct id_list *p; +{ + register struct id_list *q; + + while (q = p) { + p = p->next; + free_id_list(q); + } +} diff --git a/lang/m2/comp/misc.H b/lang/m2/comp/misc.H new file mode 100644 index 00000000..4f2ae65e --- /dev/null +++ b/lang/m2/comp/misc.H @@ -0,0 +1,10 @@ +/* M I S C E L L A N E O U S */ + +/* $Header$ */ + +/* ALLOCDEF "id_list" */ + +#define is_anon_idf(x) ((x)->id_text[0] == '#') + +extern struct idf + *gen_anon_idf(); diff --git a/lang/m2/comp/nmclash.c b/lang/m2/comp/nmclash.c new file mode 100644 index 00000000..ca2567a8 --- /dev/null +++ b/lang/m2/comp/nmclash.c @@ -0,0 +1,4 @@ +/* Accepted if many characters of long names are significant */ +abcdefghijklmnopr() { } +abcdefghijklmnopq() { } +main() { } diff --git a/lang/m2/comp/param.h b/lang/m2/comp/param.h new file mode 100644 index 00000000..cd4d2cba --- /dev/null +++ b/lang/m2/comp/param.h @@ -0,0 +1,4 @@ +/* $Header$ */ + +#define IDFSIZE 256 +#define NUMSIZE 256 diff --git a/lang/m2/comp/print.c b/lang/m2/comp/print.c new file mode 100644 index 00000000..ffb1a725 --- /dev/null +++ b/lang/m2/comp/print.c @@ -0,0 +1,144 @@ +/* P R I N T R O U T I N E S */ + +#include +#include + +#define SSIZE 1024 /* string-buffer size for print routines */ + +char *long2str(); + +doprnt(fp, fmt, argp) + File *fp; + char *fmt; + int argp[]; +{ + char buf[SSIZE]; + + sys_write(fp, buf, format(buf, fmt, (char *)argp)); +} + +/*VARARGS1*/ +printf(fmt, args) + char *fmt; + char args; +{ + char buf[SSIZE]; + + sys_write(STDOUT, buf, format(buf, fmt, &args)); +} + +/*VARARGS1*/ +fprintf(fp, fmt, args) + File *fp; + char *fmt; + char args; +{ + char buf[SSIZE]; + + sys_write(fp, buf, format(buf, fmt, &args)); +} + +/*VARARGS1*/ +char * +sprintf(buf, fmt, args) + char *buf, *fmt; + char args; +{ + buf[format(buf, fmt, &args)] = '\0'; + return buf; +} + +int +format(buf, fmt, argp) + char *buf, *fmt; + char *argp; +{ + register char *pf = fmt, *pa = argp; + register char *pb = buf; + + while (*pf) { + if (*pf == '%') { + register int width, base, pad, npad; + char *arg; + char cbuf[2]; + char *badformat = ""; + + /* get padder */ + if (*++pf == '0') { + pad = '0'; + ++pf; + } + else + pad = ' '; + + /* get width */ + width = 0; + while (*pf >= '0' && *pf <= '9') + width = 10 * width + *pf++ - '0'; + + /* get text and move pa */ + if (*pf == 's') { + arg = *(char **)pa; + pa += sizeof(char *); + } + else + if (*pf == 'c') { + cbuf[0] = * (char *) pa; + cbuf[1] = '\0'; + pa += sizeof(int); + arg = &cbuf[0]; + } + else + if (*pf == 'l') { + /* alignment ??? */ + if (base = integral(*++pf)) { + arg = long2str(*(long *)pa, base); + pa += sizeof(long); + } + else { + pf--; + arg = badformat; + } + } + else + if (base = integral(*pf)) { + arg = long2str((long)*(int *)pa, base); + pa += sizeof(int); + } + else + if (*pf == '%') + arg = "%"; + else + arg = badformat; + + npad = width - strlen(arg); + + while (npad-- > 0) + *pb++ = pad; + + while (*pb++ = *arg++); + pb--; + pf++; + } + else + *pb++ = *pf++; + } + return pb - buf; +} + +integral(c) +{ + switch (c) { + case 'b': + return -2; + case 'd': + return 10; + case 'o': + return -8; + case 'u': + return -10; + case 'x': + return -16; + } + return 0; +} diff --git a/lang/m2/comp/tab.c b/lang/m2/comp/tab.c new file mode 100644 index 00000000..17065cf9 --- /dev/null +++ b/lang/m2/comp/tab.c @@ -0,0 +1,295 @@ +/* @cc tab.c -o $INSTALLDIR/tab@ + tab - table generator + + Author: Erik Baalbergen (..tjalk!erikb) +*/ + +#include + +static char *RcsId = "$Header$"; + +#define MAXTAB 10000 +#define MAXBUF 10000 +#define COMCOM '-' +#define FILECOM '%' + +int InputForm = 'c'; +char OutputForm[MAXBUF] = "%s,\n"; +int TabSize = 257; +char *Table[MAXTAB]; +char *Name; +char *ProgCall; + +main(argc, argv) + char *argv[]; +{ + ProgCall = *argv++; + argc--; + while (argc-- > 0) { + if (**argv == COMCOM) { + option(*argv++); + } + else { + process(*argv++, InputForm); + } + } +} + +char * +Salloc(s) + char *s; +{ + char *malloc(); + char *ns = malloc(strlen(s) + 1); + + if (ns) { + strcpy(ns, s); + } + return ns; +} + +option(str) + char *str; +{ + /* note that *str indicates the source of the option: + either COMCOM (from command line) or FILECOM (from a file). + */ + switch (*++str) { + + case ' ': /* command */ + case '\t': + case '\0': + break; + case 'I': + InputForm = *++str; + break; + case 'f': + if (*++str == '\0') { + fprintf(stderr, "%s: -f: name expected\n", ProgCall); + exit(1); + } + DoFile(str); + break; + case 'F': + sprintf(OutputForm, "%s\n", ++str); + break; + case 'T': + printf("%s\n", ++str); + break; + case 'p': + PrintTable(); + break; + case 'C': + ClearTable(); + break; + case 'S': + { + register i = stoi(++str); + + if (i <= 0 || i > MAXTAB) { + fprintf(stderr, "%s: size would exceed maximum\n", + ProgCall); + } + else { + TabSize = i; + } + break; + } + default: + fprintf(stderr, "%s: bad option -%s\n", ProgCall, str); + } +} + +ClearTable() +{ + register i; + + for (i = 0; i < MAXTAB; i++) { + Table[i] = 0; + } +} + +PrintTable() +{ + register i; + + for (i = 0; i < TabSize; i++) { + if (Table[i]) { + printf(OutputForm, Table[i]); + } + else { + printf(OutputForm, "0"); + } + } +} + +process(str, format) + char *str; +{ + char *cstr = str; + char *Name = cstr; /* overwrite original string! */ + + /* strip of the entry name + */ + while (*str && *str != ':') { + if (*str == '\\') { + ++str; + } + *cstr++ = *str++; + } + + if (*str != ':') { + fprintf(stderr, "%s: bad specification: \"%s\", ignored\n", + ProgCall, Name); + return 0; + } + *cstr = '\0'; + str++; + + switch (format) { + + case 'c': + return c_proc(str, Name); + default: + fprintf(stderr, "%s: bad input format\n", ProgCall); + } + return 0; +} + +c_proc(str, Name) + char *str; + char *Name; +{ + int ch, ch2; + int quoted(); + + while (*str) { + if (*str == '\\') { + ch = quoted(&str); + } + else { + ch = *str++; + } + if (*str == '-') { + if (*++str == '\\') { + ch2 = quoted(&str); + } + else { + if (ch2 = *str++); + else str--; + } + if (ch > ch2) { + fprintf(stderr, "%s: bad range\n", ProgCall); + return 0; + } + if (ch >= 0 && ch2 <= 255) + while (ch <= ch2) + Table[ch++] = Salloc(Name); + } + else { + if (ch >= 0 && ch <= 255) + Table[ch] = Salloc(Name); + } + } + return 1; +} + +int +quoted(pstr) + char **pstr; +{ + register int ch; + register int i; + register char *str = *pstr; + + if ((*++str >= '0') && (*str <= '9')) { + ch = 0; + for (i = 0; i < 3; i++) { + ch = 8 * ch + *str - '0'; + if (*++str < '0' || *str > '9') + break; + } + } + else { + switch (*str++) { + + case 'n': + ch = '\n'; + break; + case 't': + ch = '\t'; + break; + case 'b': + ch = '\b'; + break; + case 'r': + ch = '\r'; + break; + case 'f': + ch = '\f'; + break; + default : + ch = *str; + } + } + *pstr = str; + return ch & 0377; +} + +int +stoi(str) + char *str; +{ + register i = 0; + + while (*str >= '0' && *str <= '9') { + i = i * 10 + *str++ - '0'; + } + return i; +} + +char * +getline(s, n, fp) + char *s; + FILE *fp; +{ + register c = getc(fp); + char *str = s; + + while (n--) { + if (c == EOF) { + return NULL; + } + else + if (c == '\n') { + *str++ = '\0'; + return s; + } + *str++ = c; + c = getc(fp); + } + s[n - 1] = '\0'; + return s; +} + +#define BUFSIZE 1024 + +DoFile(name) + char *name; +{ + char text[BUFSIZE]; + FILE *fp; + + if ((fp = fopen(name, "r")) == NULL) { + fprintf(stderr, "%s: cannot read file %s\n", ProgCall, name); + exit(1); + } + while (getline(text, BUFSIZE, fp) != NULL) { + if (text[0] == FILECOM) { + option(text); + } + else { + process(text, InputForm); + } + } +} diff --git a/lang/m2/libm2/ASCII.mod b/lang/m2/libm2/ASCII.mod new file mode 100644 index 00000000..77d93281 --- /dev/null +++ b/lang/m2/libm2/ASCII.mod @@ -0,0 +1,3 @@ +IMPLEMENTATION MODULE ASCII; +BEGIN +END ASCII. diff --git a/lang/m2/libm2/ChkCards.e b/lang/m2/libm2/ChkCards.e new file mode 100644 index 00000000..902e6b8e --- /dev/null +++ b/lang/m2/libm2/ChkCards.e @@ -0,0 +1,131 @@ +#include +; +; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. +; See the copyright notice in the ACK home directory, in the file "Copyright". +; +; +; Module: CARDINAL operations with overflow checking +; Author: Ceriel J.H. Jacobs +; Version: $Header$ +; + + mes 2,EM_WSIZE,EM_PSIZE + + exp $addu + exp $subu + exp $mulu +#if EM_WSIZE < EM_LSIZE + exp $addul + exp $subul + exp $mulul +#endif + + pro $addu,0 + loc -1 + lol 0 + sbu EM_WSIZE + lol EM_WSIZE + cmu EM_WSIZE + zge *1 + loc M2_UOVFL + trp +1 + lol 0 + lol EM_WSIZE + adu EM_WSIZE + stl EM_WSIZE + ret 0 + end 0 + +#if EM_WSIZE < EM_LSIZE + pro $addul,0 + ldc -1 + ldl 0 + sbu EM_LSIZE + ldl EM_LSIZE + cmu EM_LSIZE + zge *1 + loc M2_UOVFL + trp +1 + ldl 0 + ldl EM_LSIZE + adu EM_LSIZE + sdl EM_LSIZE + ret 0 + end 0 +#endif + + pro $mulu,0 + lol 0 + zeq *1 + loc -1 + lol 0 + dvu EM_WSIZE + lol EM_WSIZE + cmu EM_WSIZE + zge *1 + loc M2_UOVFL + trp +1 + lol 0 + lol EM_WSIZE + mlu EM_WSIZE + stl EM_WSIZE + ret 0 + end 0 + +#if EM_WSIZE < EM_LSIZE + pro $mulul,0 + ldl 0 + ldc 0 + cmu EM_LSIZE + zeq *1 + ldc -1 + ldl 0 + dvu EM_LSIZE + ldl EM_LSIZE + cmu EM_LSIZE + zge *1 + loc M2_UOVFL + trp +1 + ldl 0 + ldl EM_LSIZE + mlu EM_LSIZE + sdl EM_LSIZE + ret 0 + end 0 +#endif + + pro $subu,0 + lol EM_WSIZE + lol 0 + cmu EM_WSIZE + zge *1 + loc M2_UUVFL + trp +1 + lol EM_WSIZE + lol 0 + sbu EM_WSIZE + stl EM_WSIZE + ret 0 + end 0 + +#if EM_WSIZE < EM_LSIZE + pro $subul,0 + ldl EM_LSIZE + ldl 0 + cmu EM_LSIZE + zge *1 + loc M2_UUVFL + trp +1 + ldl EM_LSIZE + ldl 0 + sbu EM_LSIZE + sdl EM_LSIZE + ret 0 + end 0 +#endif diff --git a/lang/m2/libm2/FIFFEF.def b/lang/m2/libm2/FIFFEF.def new file mode 100644 index 00000000..ea49df35 --- /dev/null +++ b/lang/m2/libm2/FIFFEF.def @@ -0,0 +1,13 @@ +(*$Foreign*) +DEFINITION MODULE FIFFEF; + + PROCEDURE FIF(arg1, arg2: LONGREAL; VAR intres: LONGREAL) : LONGREAL; + (* multiplies arg1 and arg2, and returns the integer part of the + result in "intres" and the fraction part as the function result. + *) + + PROCEDURE FEF(arg: LONGREAL; VAR exp: INTEGER) : LONGREAL; + (* splits "arg" in mantissa and a base-2 exponent. + The mantissa is returned, and the exponent is left in "exp". + *) +END FIFFEF. diff --git a/lang/m2/libm2/FIFFEF.e b/lang/m2/libm2/FIFFEF.e new file mode 100644 index 00000000..849cfc2b --- /dev/null +++ b/lang/m2/libm2/FIFFEF.e @@ -0,0 +1,46 @@ +# + mes 2,EM_WSIZE,EM_PSIZE + +#define ARG1 0 +#define ARG2 EM_DSIZE +#define IRES 2*EM_DSIZE + +; FIF is called with three parameters: +; - address of integer part result (IRES) +; - float two (ARG2) +; - float one (ARG1) +; and returns an EM_DSIZE-byte floating point number +; Definition: +; PROCEDURE FIF(ARG1, ARG2: LONGREAL; VAR IRES: LONGREAL) : LONGREAL; + + exp $FIF + pro $FIF,0 + lal 0 + loi 2*EM_DSIZE + fif EM_DSIZE + lal IRES + loi EM_PSIZE + sti EM_DSIZE + ret EM_DSIZE + end ? + +#define FARG 0 +#define ERES EM_DSIZE + +; FEF is called with two parameters: +; - address of base 2 exponent result (ERES) +; - floating point number to be split (FARG) +; and returns an EM_DSIZE-byte floating point number (the mantissa) +; Definition: +; PROCEDURE FEF(FARG: LONGREAL; VAR ERES: integer): LONGREAL; + + exp $FEF + pro $FEF,0 + lal FARG + loi EM_DSIZE + fef EM_DSIZE + lal ERES + loi EM_PSIZE + sti EM_WSIZE + ret EM_DSIZE + end ? diff --git a/lang/m2/libm2/FORchk.c b/lang/m2/libm2/FORchk.c new file mode 100644 index 00000000..f911e295 --- /dev/null +++ b/lang/m2/libm2/FORchk.c @@ -0,0 +1,8 @@ +static char m[] = "Warning: FOR-loop control variable was changed in the body"; +_forloopchk(a,b) + unsigned a, b; +{ + if (a != b) { + Traps_Message(m , 0, sizeof(m) - 2, 1); + } +} diff --git a/lang/m2/libm2/Makefile b/lang/m2/libm2/Makefile new file mode 100644 index 00000000..ff3b279e --- /dev/null +++ b/lang/m2/libm2/Makefile @@ -0,0 +1,23 @@ +HOME = ../../.. +DEFDIR = $(HOME)/lib/m2 + +SOURCES = ASCII.def EM.def MathLib0.def Processes.def \ + RealInOut.def Storage.def Arguments.def Conversion.def \ + random.def Semaphores.def Unix.def RealConver.def \ + Strings.def InOut.def Terminal.def \ + Mathlib.def PascalIO.def Traps.def CSP.def \ + Epilogue.def Streams.def ArraySort.def StripUnix.def \ + Termcap.def XXTermcap.def + +all: +clean: +cmp: + +pr: + @pr Makefile $(SOURCES) +opr: + make pr | opr + +install: + -mkdir $(DEFDIR) + cp $(SOURCES) $(DEFDIR) diff --git a/lang/m2/libm2/TTY.def b/lang/m2/libm2/TTY.def new file mode 100644 index 00000000..db60c635 --- /dev/null +++ b/lang/m2/libm2/TTY.def @@ -0,0 +1,3 @@ +DEFINITION MODULE TTY; +PROCEDURE isatty(fd: INTEGER): BOOLEAN; +END TTY. diff --git a/lang/m2/libm2/TTY.mod b/lang/m2/libm2/TTY.mod new file mode 100644 index 00000000..f45e5e9f --- /dev/null +++ b/lang/m2/libm2/TTY.mod @@ -0,0 +1,19 @@ +# +(*$R-*) +IMPLEMENTATION MODULE TTY; +FROM Unix IMPORT ioctl; +FROM SYSTEM IMPORT ADR; +PROCEDURE isatty(fd: INTEGER): BOOLEAN; +VAR buf: ARRAY[1..100] OF CHAR; +BEGIN +#ifdef __USG + RETURN ioctl(fd, INTEGER(ORD('T') * 256 + 1), ADR(buf)) >= 0; +#else +#ifdef __BSD4_2 + RETURN ioctl(fd, INTEGER(ORD('t') * 256 + 8 + 6*65536 + 40000000H), ADR(buf)) >= 0; +#else + RETURN ioctl(fd, INTEGER(ORD('t') * 256 + 8), ADR(buf)) >= 0; +#endif +#endif +END isatty; +END TTY. diff --git a/lang/m2/libm2/hol0.e b/lang/m2/libm2/hol0.e new file mode 100644 index 00000000..8db66cf7 --- /dev/null +++ b/lang/m2/libm2/hol0.e @@ -0,0 +1,29 @@ +# + +; $Header$ +; +; (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. +; +; This product is part of the Amsterdam Compiler Kit. +; +; Permission to use, sell, duplicate or disclose this software must be +; obtained in writing. Requests for such permissions may be sent to +; +; Dr. Andrew S. Tanenbaum +; Wiskundig Seminarium +; Vrije Universiteit +; Postbox 7161 +; 1007 MC Amsterdam +; The Netherlands +; +; + + mes 2,EM_WSIZE,EM_PSIZE + +; _hol0 return the address of the ABS block (hol0) + + exp $_hol0 + pro $_hol0,0 + lae 0 + ret EM_PSIZE + end ? diff --git a/lang/m2/libm2/rcka.e b/lang/m2/libm2/rcka.e new file mode 100644 index 00000000..c3ef0b2a --- /dev/null +++ b/lang/m2/libm2/rcka.e @@ -0,0 +1,31 @@ +# +; +; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. +; See the copyright notice in the ACK home directory, in the file "Copyright". +; +; +; Module: range checks for INTEGER, now for array indexing +; Author: Ceriel J.H. Jacobs +; Version: $Header$ +; +#include + + mes 2,EM_WSIZE,EM_PSIZE + exp $rcka + pro $rcka, 0 + + lol EM_PSIZE + zlt *1 ; lower bound always 0 + lol EM_PSIZE + lal 0 + loi EM_PSIZE + adp EM_WSIZE + loi EM_WSIZE + cmi EM_WSIZE + zgt *1 + ret 0 +1 + loc EARRAY + trp + ret 0 + end 0 diff --git a/lang/m2/libm2/rcki.e b/lang/m2/libm2/rcki.e new file mode 100644 index 00000000..72df511f --- /dev/null +++ b/lang/m2/libm2/rcki.e @@ -0,0 +1,37 @@ +# +; +; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. +; See the copyright notice in the ACK home directory, in the file "Copyright". +; +; +; Module: range checks for INTEGER +; Author: Ceriel J.H. Jacobs +; Version: $Header$ +; +#include + + mes 2,EM_WSIZE,EM_PSIZE + exp $rcki + pro $rcki, 0 + + lal EM_PSIZE + loi EM_WSIZE + lal 0 + loi EM_PSIZE + loi EM_WSIZE + cmi EM_WSIZE + zlt *1 + lal EM_PSIZE + loi EM_WSIZE + lal 0 + loi EM_PSIZE + adp EM_WSIZE + loi EM_WSIZE + cmi EM_WSIZE + zgt *1 + ret 0 +1 + loc ERANGE + trp + ret 0 + end 0 diff --git a/lang/m2/libm2/rckil.e b/lang/m2/libm2/rckil.e new file mode 100644 index 00000000..88f461c9 --- /dev/null +++ b/lang/m2/libm2/rckil.e @@ -0,0 +1,37 @@ +# +; +; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. +; See the copyright notice in the ACK home directory, in the file "Copyright". +; +; +; Module: range checks for LONGINTS +; Author: Ceriel J.H. Jacobs +; Version: $Header$ +; +#include + + mes 2,EM_WSIZE,EM_PSIZE + exp $rckil + pro $rckil, 0 + + lal EM_PSIZE + loi EM_LSIZE + lal 0 + loi EM_PSIZE + loi EM_LSIZE + cmi EM_LSIZE + zlt *1 + lal EM_PSIZE + loi EM_LSIZE + lal 0 + loi EM_PSIZE + adp EM_LSIZE + loi EM_LSIZE + cmi EM_LSIZE + zgt *1 + ret 0 +1 + loc ERANGE + trp + ret 0 + end 0 diff --git a/lang/m2/libm2/rcku.e b/lang/m2/libm2/rcku.e new file mode 100644 index 00000000..687ea51d --- /dev/null +++ b/lang/m2/libm2/rcku.e @@ -0,0 +1,37 @@ +# +; +; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. +; See the copyright notice in the ACK home directory, in the file "Copyright". +; +; +; Module: range checks for CARDINAL +; Author: Ceriel J.H. Jacobs +; Version: $Header$ +; +#include + + mes 2,EM_WSIZE,EM_PSIZE + exp $rcku + pro $rcku, 0 + + lal EM_PSIZE + loi EM_WSIZE + lal 0 + loi EM_PSIZE + loi EM_WSIZE + cmu EM_WSIZE + zlt *1 + lal EM_PSIZE + loi EM_WSIZE + lal 0 + loi EM_PSIZE + adp EM_WSIZE + loi EM_WSIZE + cmu EM_WSIZE + zgt *1 + ret 0 +1 + loc ERANGE + trp + ret 0 + end 0 diff --git a/lang/m2/libm2/rckul.e b/lang/m2/libm2/rckul.e new file mode 100644 index 00000000..62fb78d1 --- /dev/null +++ b/lang/m2/libm2/rckul.e @@ -0,0 +1,37 @@ +# +; +; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. +; See the copyright notice in the ACK home directory, in the file "Copyright". +; +; +; Module: Range checks for LONGCARD +; Author: Ceriel J.H. Jacobs +; Version: $Header$ +; +#include + + mes 2,EM_WSIZE,EM_PSIZE + exp $rckul + pro $rckul, 0 + + lal EM_PSIZE + loi EM_LSIZE + lal 0 + loi EM_PSIZE + loi EM_LSIZE + cmu EM_LSIZE + zlt *1 + lal EM_PSIZE + loi EM_LSIZE + lal 0 + loi EM_PSIZE + adp EM_LSIZE + loi EM_LSIZE + cmu EM_LSIZE + zgt *1 + ret 0 +1 + loc ERANGE + trp + ret 0 + end 0 diff --git a/lang/m2/libm2/transfer.e b/lang/m2/libm2/transfer.e new file mode 100644 index 00000000..2bac4151 --- /dev/null +++ b/lang/m2/libm2/transfer.e @@ -0,0 +1,258 @@ +# +; +; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. +; See the copyright notice in the ACK home directory, in the file "Copyright". +; +; +; Module: implementation of coroutines +; Author: Ceriel J.H. Jacobs +; Version: $Header$ +; +; This version works for EM implementations that have a contiguous downwards +; growing stack, on which data below the stack-pointer is not destroyed. +; +#include +#include + + mes 2, EM_WSIZE, EM_PSIZE + + ; This file contains the implementation of the following routines from + ; the SYSTEM module: + ; TRANSFER, NEWPROCESS + ; The NEWPROCESS routine creates a new coroutine stack frame. + ; The TRANSFER routine implements transfers from one coroutine to another. + ; The memory organization for coroutines is rather complicated. + ; One problem is caused by the fact that the user must allocate the + ; stackspace. So, this stackspace can be located anywhere, including on + ; the heap. This means that we cannot use this space as a stack, because + ; in EM, the stack-pointer may never point below the heap-pointer. + ; So, this space is only used to save the stack when the coroutine isn't + ; running. + ; It also contains information about the size of the frame, the + ; address of the procedure that forms the coroutine body, the offset + ; of the LB from the start of the frame, and the offset of the SP from + ; the start of the frame. + ; So, is looks like this: + ; |-----------------------------| + ; | | + ; | | + ; | | + ; . + ; . + ; . + ; | | + ; | | + ; | | <--- coroutine ident + ; |-----------------------------| + ; | saved SP | + ; |-----------------------------| + ; | saved LB | + ; |-----------------------------| + ; | procedure address or 0 | + ; |-----------------------------| + ; | size | + ; |-----------------------------| + ; + ; Another problem is that the coroutines must always run at the same + ; place in the stack. Therefore, in the runtime startoff a piece of the + ; stack is allocated for coroutines. + + exp $_SYSTEM__NEWPROCESS + exp $_SYSTEM__TRANSFER + inp $ChkSize + + pro $_SYSTEM__NEWPROCESS, 0 + + ; This procedure only initializes the area used for saving the stack. + ; Its definition is: + ; PROCEDURE NEWPROCESS(P:PROC; A:ADDRESS; n:CARDINAL; VAR p1:ADDRESS); + + lol 2*EM_PSIZE ; size of frame (n) + cal $ChkSize + asp EM_WSIZE + lfr EM_WSIZE + sil EM_PSIZE ; store size in area (indicated by A) + lal EM_PSIZE + loi EM_PSIZE ; address of area (A) + lal 0 + loi EM_PSIZE ; address of coroutine body (P) + lal EM_PSIZE + loi EM_PSIZE + adp EM_WSIZE + sti EM_PSIZE ; store it in area + lal EM_PSIZE + loi EM_PSIZE + adp 3*EM_PSIZE + EM_WSIZE ; this becomes the coroutine identifier + lal 2*EM_PSIZE+EM_WSIZE + loi EM_PSIZE + sti EM_PSIZE + ret 0 + end 0 + +target + bss EM_PSIZE, 0, 0 + + pro $_SYSTEM__TRANSFER, 0 + + ; This procedure does all the hard work. + ; It must save the current environment, and restore the one to which the + ; transfer is done. It must also make it look like the return is done + ; from ITS invocation of transfer. + ; Definition is: + ; PROCEDURE TRANSFER(VAR p1, p2 : ADDRESS); + + mes ms_gto ; This is a dangerous procedure + + lal EM_PSIZE + loi EM_PSIZE + loi EM_PSIZE ; address of target coroutine + dup EM_PSIZE + lae CurrentProcess + loi EM_PSIZE + dup EM_PSIZE + lal 0 + loi EM_PSIZE ; address of place where to store address of current coroutine + sti EM_PSIZE ; store + cmp ; compare with current process + zne *1 + ; Here, no real transfer needs to be done + asp EM_PSIZE + ret 0 ; just return +1 + lae target + sti EM_PSIZE ; store it in target + + ; Now, we save the current stack + ; Use local base from main program + + lor 0 ; load LB + lae CurrentProcess + loi EM_PSIZE + adp -2*EM_PSIZE + sti EM_PSIZE ; save it + lor 1 ; load SP + lae CurrentProcess + loi EM_PSIZE + adp -EM_PSIZE + sti EM_PSIZE ; save it + ; Now, we must find a stack we can temporarily use. + ; Just take the one from the main program. + lae MainProcess + loi EM_PSIZE + adp -EM_PSIZE + loi EM_PSIZE + str 1 ; temporary stackpointer + + lae MainLB + loi EM_PSIZE + str 0 + + lae CurrentProcess + loi EM_PSIZE + lae MainProcess + loi EM_PSIZE + cmp + zeq *2 + + lae StackBase + loi EM_PSIZE + lae CurrentProcess + loi EM_PSIZE + adp -3*EM_PSIZE-EM_WSIZE + loi EM_WSIZE ; get size + ngi EM_WSIZE + ads EM_WSIZE ; gives source address + lae CurrentProcess + loi EM_PSIZE ; destination address + lae CurrentProcess + loi EM_PSIZE + adp -3*EM_PSIZE-EM_WSIZE + loi EM_WSIZE + bls EM_WSIZE ; copy + +2 + lae target + loi EM_PSIZE + dup EM_PSIZE + lae CurrentProcess + sti EM_PSIZE ; store target process descriptor in _CurrentProcess + lae MainProcess + loi EM_PSIZE + cmp + zeq *4 + ; Now check if the coroutine was called before + lae target + loi EM_PSIZE + adp -3*EM_PSIZE + loi EM_PSIZE + zer EM_PSIZE + cmp + zeq *5 + ; No, it was'nt + lae StackBase + loi EM_PSIZE + str 1 ; new stack pointer + lae target + loi EM_PSIZE + adp -3*EM_PSIZE + loi EM_PSIZE + zer EM_PSIZE + lae target + loi EM_PSIZE + adp -3*EM_PSIZE + sti EM_PSIZE + cai + loc 0 + cal $exit + ret 0 +5 + lae target + loi EM_PSIZE ; push source address + lae StackBase + loi EM_PSIZE ; subtract size from this and we have the destination address + lae target + loi EM_PSIZE + adp -3*EM_PSIZE-EM_WSIZE + loi EM_WSIZE + ngi EM_WSIZE + ads EM_WSIZE ; got it + lae target + loi EM_PSIZE + adp -3*EM_PSIZE-EM_WSIZE + loi EM_WSIZE + bls EM_WSIZE +4 + lae target + loi EM_PSIZE + adp -2*EM_PSIZE + loi EM_PSIZE + str 0 ; restore LB + lae target + loi EM_PSIZE + adp -EM_PSIZE + loi EM_PSIZE + str 1 ; restore SP + ret 0 + end 0 + + pro $ChkSize, 0 + lol 0 + loc 3*EM_PSIZE+EM_WSIZE + sbi EM_WSIZE + dup EM_WSIZE + stl 0 + loe StackSize + cmu EM_WSIZE + zle *1 + loc M2_TOOLARGE ; trap number for "stack size too large" + trp +1 + lol 0 + loc EM_WSIZE-1 + adi EM_WSIZE + loc EM_WSIZE + dvi EM_WSIZE + loc EM_WSIZE + mli EM_WSIZE + ret EM_WSIZE + end 0 diff --git a/lang/m2/m2mm/Version.c b/lang/m2/m2mm/Version.c new file mode 100644 index 00000000..164526a9 --- /dev/null +++ b/lang/m2/m2mm/Version.c @@ -0,0 +1 @@ +static char Version[] = "ACK Modula-2 Makefile Generator Version 0.3"; diff --git a/lang/m2/m2mm/tab.c b/lang/m2/m2mm/tab.c new file mode 100644 index 00000000..17065cf9 --- /dev/null +++ b/lang/m2/m2mm/tab.c @@ -0,0 +1,295 @@ +/* @cc tab.c -o $INSTALLDIR/tab@ + tab - table generator + + Author: Erik Baalbergen (..tjalk!erikb) +*/ + +#include + +static char *RcsId = "$Header$"; + +#define MAXTAB 10000 +#define MAXBUF 10000 +#define COMCOM '-' +#define FILECOM '%' + +int InputForm = 'c'; +char OutputForm[MAXBUF] = "%s,\n"; +int TabSize = 257; +char *Table[MAXTAB]; +char *Name; +char *ProgCall; + +main(argc, argv) + char *argv[]; +{ + ProgCall = *argv++; + argc--; + while (argc-- > 0) { + if (**argv == COMCOM) { + option(*argv++); + } + else { + process(*argv++, InputForm); + } + } +} + +char * +Salloc(s) + char *s; +{ + char *malloc(); + char *ns = malloc(strlen(s) + 1); + + if (ns) { + strcpy(ns, s); + } + return ns; +} + +option(str) + char *str; +{ + /* note that *str indicates the source of the option: + either COMCOM (from command line) or FILECOM (from a file). + */ + switch (*++str) { + + case ' ': /* command */ + case '\t': + case '\0': + break; + case 'I': + InputForm = *++str; + break; + case 'f': + if (*++str == '\0') { + fprintf(stderr, "%s: -f: name expected\n", ProgCall); + exit(1); + } + DoFile(str); + break; + case 'F': + sprintf(OutputForm, "%s\n", ++str); + break; + case 'T': + printf("%s\n", ++str); + break; + case 'p': + PrintTable(); + break; + case 'C': + ClearTable(); + break; + case 'S': + { + register i = stoi(++str); + + if (i <= 0 || i > MAXTAB) { + fprintf(stderr, "%s: size would exceed maximum\n", + ProgCall); + } + else { + TabSize = i; + } + break; + } + default: + fprintf(stderr, "%s: bad option -%s\n", ProgCall, str); + } +} + +ClearTable() +{ + register i; + + for (i = 0; i < MAXTAB; i++) { + Table[i] = 0; + } +} + +PrintTable() +{ + register i; + + for (i = 0; i < TabSize; i++) { + if (Table[i]) { + printf(OutputForm, Table[i]); + } + else { + printf(OutputForm, "0"); + } + } +} + +process(str, format) + char *str; +{ + char *cstr = str; + char *Name = cstr; /* overwrite original string! */ + + /* strip of the entry name + */ + while (*str && *str != ':') { + if (*str == '\\') { + ++str; + } + *cstr++ = *str++; + } + + if (*str != ':') { + fprintf(stderr, "%s: bad specification: \"%s\", ignored\n", + ProgCall, Name); + return 0; + } + *cstr = '\0'; + str++; + + switch (format) { + + case 'c': + return c_proc(str, Name); + default: + fprintf(stderr, "%s: bad input format\n", ProgCall); + } + return 0; +} + +c_proc(str, Name) + char *str; + char *Name; +{ + int ch, ch2; + int quoted(); + + while (*str) { + if (*str == '\\') { + ch = quoted(&str); + } + else { + ch = *str++; + } + if (*str == '-') { + if (*++str == '\\') { + ch2 = quoted(&str); + } + else { + if (ch2 = *str++); + else str--; + } + if (ch > ch2) { + fprintf(stderr, "%s: bad range\n", ProgCall); + return 0; + } + if (ch >= 0 && ch2 <= 255) + while (ch <= ch2) + Table[ch++] = Salloc(Name); + } + else { + if (ch >= 0 && ch <= 255) + Table[ch] = Salloc(Name); + } + } + return 1; +} + +int +quoted(pstr) + char **pstr; +{ + register int ch; + register int i; + register char *str = *pstr; + + if ((*++str >= '0') && (*str <= '9')) { + ch = 0; + for (i = 0; i < 3; i++) { + ch = 8 * ch + *str - '0'; + if (*++str < '0' || *str > '9') + break; + } + } + else { + switch (*str++) { + + case 'n': + ch = '\n'; + break; + case 't': + ch = '\t'; + break; + case 'b': + ch = '\b'; + break; + case 'r': + ch = '\r'; + break; + case 'f': + ch = '\f'; + break; + default : + ch = *str; + } + } + *pstr = str; + return ch & 0377; +} + +int +stoi(str) + char *str; +{ + register i = 0; + + while (*str >= '0' && *str <= '9') { + i = i * 10 + *str++ - '0'; + } + return i; +} + +char * +getline(s, n, fp) + char *s; + FILE *fp; +{ + register c = getc(fp); + char *str = s; + + while (n--) { + if (c == EOF) { + return NULL; + } + else + if (c == '\n') { + *str++ = '\0'; + return s; + } + *str++ = c; + c = getc(fp); + } + s[n - 1] = '\0'; + return s; +} + +#define BUFSIZE 1024 + +DoFile(name) + char *name; +{ + char text[BUFSIZE]; + FILE *fp; + + if ((fp = fopen(name, "r")) == NULL) { + fprintf(stderr, "%s: cannot read file %s\n", ProgCall, name); + exit(1); + } + while (getline(text, BUFSIZE, fp) != NULL) { + if (text[0] == FILECOM) { + option(text); + } + else { + process(text, InputForm); + } + } +} diff --git a/lang/m2/test/Wirth/makefile b/lang/m2/test/Wirth/makefile new file mode 100644 index 00000000..b4a35cdd --- /dev/null +++ b/lang/m2/test/Wirth/makefile @@ -0,0 +1,47 @@ +IFLAGS = +M2FLAGS = +MOD = m2 +SUFFIX = o +LIBS = + +all: PowersOf2 XREF + +objects: PowersOf2_o_files XREF_o_files + + +PowersOf2.$(SUFFIX): \ + PowersOf2.mod \ + /proj/em/Work/lib/m2/InOut.def + $(MOD) -c $(M2FLAGS) $(IFLAGS) PowersOf2.mod +TableHandl.$(SUFFIX): \ + TableHandl.mod \ + TableHandl.def \ + /proj/em/Work/lib/m2/InOut.def \ + /proj/em/Work/lib/m2/Storage.def + $(MOD) -c $(M2FLAGS) $(IFLAGS) TableHandl.mod +XREF.$(SUFFIX): \ + XREF.mod \ + /proj/em/Work/lib/m2/InOut.def \ + TableHandl.def + $(MOD) -c $(M2FLAGS) $(IFLAGS) XREF.mod + +OBS_PowersOf2 = \ + PowersOf2.$(SUFFIX) + +OBS2_PowersOf2 = + +PowersOf2_o_files: $(OBS_PowersOf2) + +PowersOf2: $(OBS_PowersOf2) $(OBS2_PowersOf2) + $(MOD) -o PowersOf2 $(M2FLAGS) $(OBS_PowersOf2) $(OBS2_PowersOf2) $(LIBS) + +OBS_XREF = \ + XREF.$(SUFFIX) \ + TableHandl.$(SUFFIX) + +OBS2_XREF = + +XREF_o_files: $(OBS_XREF) + +XREF: $(OBS_XREF) $(OBS2_XREF) + $(MOD) -o XREF $(M2FLAGS) $(OBS_XREF) $(OBS2_XREF) $(LIBS) diff --git a/lang/occam/comp/Makefile b/lang/occam/comp/Makefile new file mode 100644 index 00000000..86e5c6c4 --- /dev/null +++ b/lang/occam/comp/Makefile @@ -0,0 +1,54 @@ +EMHOME = ../../.. +MODLIB = $(EMHOME)/modules/lib +INCL = -I$(EMHOME)/modules/h -I$(EMHOME)/h +GFILES= occam.g +PRIMARY= occam.o Lpars.o keytab.o lex.yy.o code.o em.o +SECUNDARY= symtab.o expr.o builtin.o +TERTIARY= report.o +LLOPT= +LEXLIB=-ll +LIBRARY= $(MODLIB)/libem_mes.a $(MODLIB)/libemk.a \ + $(MODLIB)/liballoc.a $(MODLIB)/libprint.a \ + $(MODLIB)/libstring.a \ + $(MODLIB)/libsystem.a $(LEXLIB) +CFLAGS = -Dvoid=int -O $(INCL) +LDFLAGS = +# void = int, because some compilers don't understand void +HSRC = code.h em.h expr.h sizes.h symtab.h token.h +CSRC = builtin.c code.c em.c expr.c keytab.c report.c symtab.c + +all: dummy + make oc + +dummy: $(GFILES) + LLgen $(LLOPT) $(GFILES) + touch dummy + +oc: $(PRIMARY) $(SECUNDARY) $(TERTIARY) + $(CC) $(LDFLAGS) -o oc $(PRIMARY) $(SECUNDARY) $(TERTIARY) $(LIBRARY) + +lex.yy.c: lex.l + lex lex.l + +install: all + rm -f $(EMHOME)/lib/em_occam + cp oc $(EMHOME)/lib/em_occam + +cmp: all + -cmp oc $(EMHOME)/lib/em_occam + +pr: + @pr Makefile $(HSRC) occam.g lex.l $(CSRC) + +opr: + make pr | opr + +clean: + rm -f lex.yy.c occam.c *.o oc dummy Lpars.c Lpars.h + +$(PRIMARY): Lpars.h +occam.o keytab.o: token.h +occam.o $(SECUNDARY): symtab.h expr.h +$(PRIMARY) $(SECUNDARY): sizes.h +occam.o code.o: code.h +code.o em.o: em.h diff --git a/lang/occam/lib/AR2 b/lang/occam/lib/AR2 new file mode 100755 index 00000000..d249beb9 --- /dev/null +++ b/lang/occam/lib/AR2 @@ -0,0 +1,11 @@ +#!/bin/sh +case $# in + 0) ar ru /user0/bot/lib/lib2.a *.o + ranlib /user0/bot/lib/lib2.a + rm -f *.o + ;; + *) keys=$1 + shift + ar $keys /user0/bot/lib/lib2.a $* + ;; +esac diff --git a/lang/occam/lib/AR4 b/lang/occam/lib/AR4 new file mode 100755 index 00000000..0560c4a8 --- /dev/null +++ b/lang/occam/lib/AR4 @@ -0,0 +1,11 @@ +#!/bin/sh +case $# in + 0) ar ru /user0/bot/lib/lib4.a *.o + ranlib /user0/bot/lib/lib4.a + rm -f *.o + ;; + *) keys=$1 + shift + ar $keys /user0/bot/lib/lib4.a $* + ;; +esac diff --git a/lang/occam/lib/Makefile b/lang/occam/lib/Makefile new file mode 100644 index 00000000..357ab5fb --- /dev/null +++ b/lang/occam/lib/Makefile @@ -0,0 +1,28 @@ +PRIMITIVES= par_vax.s +PARALLEL= parco.c par.c co.c +OCRT= ocrt.c builtin.c channel.c chan_struct.c + +COMMON= $(PRIMITIVES) $(PARALLEL) $(OCRT) + +SIZE2= em2.e +SIZE4= em4.e + +LIB2= /user0/bot/lib/lib2.a +LIB4= /user0/bot/lib/lib4.a + +ACK2= vax2 +ACK4= vax4 + +all: lib2 lib4 + +lib2: $(COMMON) $(SIZE2) + rm -f *.o $(LIB2) + $(ACK2) -c.o -L -Dvoid=char -Dptrdiff=long $(COMMON) $(SIZE2) + ar cq $(LIB2) *.o + rm -f *.o + +lib4: $(COMMON) $(SIZE4) + rm -f *.o $(LIB4) + $(ACK4) -c.o -L -Dvoid=char $(COMMON) $(SIZE4) + ar cq $(LIB4) *.o + rm -f *.o diff --git a/lang/occam/lib/em2.e b/lang/occam/lib/em2.e new file mode 100644 index 00000000..fb81a1ed --- /dev/null +++ b/lang/occam/lib/em2.e @@ -0,0 +1,52 @@ + mes 2,2,4 + +oldtrp + bss 4, 0, 0 + + exp $init + pro $init, 0 + loc -321-1 + sim + lpi $catch1 + sig + sde oldtrp + cal $initfile + ret 0 + end 0 + + pro $catch1, 0 + lde oldtrp + sig + asp 4 + loe 0 + lde 4 + lol 0 + cal $catch + asp 8 + lol 0 + trp + rtt + end 0 + + exp $now + pro $now, 12 + zre deadlock + lal -12 + loc 35 + mon + asp 2 + ldl -12 + ret 4 + end 12 + + exp $block_mo + pro $block_mo, 0 + ldl 4 + ldl 8 + ldl 0 + loc 4 + loc 2 + cuu + bls 2 + ret 0 + end 0 diff --git a/lang/occam/lib/em4.e b/lang/occam/lib/em4.e new file mode 100644 index 00000000..ff948932 --- /dev/null +++ b/lang/occam/lib/em4.e @@ -0,0 +1,49 @@ + mes 2,4,4 + +oldtrp + bss 4, 0, 0 + + exp $init + pro $init, 0 + loc -321-1 + sim + lpi $catch1 + sig + ste oldtrp + cal $initfile + ret 0 + end 0 + + pro $catch1, 0 + loe oldtrp + sig + asp 4 + loe 0 + loe 4 + lol 0 + cal $catch + asp 12 + lol 0 + trp + rtt + end 0 + + exp $now + pro $now, 12 + zre deadlock + lal -12 + loc 35 + mon + asp 4 + lol -12 + ret 4 + end 12 + + exp $block_mo + pro $block_mo, 0 + lol 4 + lol 8 + lol 0 + bls 4 + ret 0 + end 0 diff --git a/lang/occam/lib/ocm_chan.h b/lang/occam/lib/ocm_chan.h new file mode 100644 index 00000000..0a010758 --- /dev/null +++ b/lang/occam/lib/ocm_chan.h @@ -0,0 +1,48 @@ +/* $Header$ */ +/* channel.h - channel definitions */ +#include +#include "parco.h" + +typedef union channel { + struct { /* Interprocess channel */ + char _type; /* Channel type, see note */ + char synch; /* State in channel synchronization */ + long val; /* Transmitted value */ + } c; + struct { /* File channel */ + char _type; /* Dummy field, see note */ + char index; /* Index in the file array */ + char flgs; /* Status flags: in use & readahead */ + char preread; /* Possible preread character */ + } f; +} chan; +#define type c._type /* Channel type */ +/* Note: The channel type should not be part of each structure in chan. But + * the C alignment rules would make chan about 50% bigger if we had done it + * the right way. Note that the order of fields in a struct cannot be a problem + * as long as struct c is the largest within the union. + */ + +#define C_T_CHAN 0 /* Type of a interprocess channel */ +#define C_T_FILE 1 /* Type of a file channel */ + +#define C_S_FREE 0 /* IP channel is free */ +#define C_S_ANY 1 /* IP channel contains data */ +#define C_S_ACK 2 /* IP channel data is removed */ + +#define C_F_EOF (-1L) /* File channel returns EOF */ +#define C_F_TEXT (-2L) /* File channel becomes line oriented */ +#define C_F_RAW (-3L) /* File channel becomes character oriented */ + +#define C_F_INUSE 0x01 /* File channel is connected to a UNIX file */ +#define C_F_READAHEAD 0x02 /* File channel has a preread character */ + +extern chan file[_NFILE]; /* Array of file channels */ +extern FILE *unix_file[_NFILE]; /* Pointers to buffered UNIX files */ + +void c_init(); + +void chan_in(), cbyte_in(), c_wa_in(), c_ba_in(); +void chan_out(), c_wa_out(), c_ba_out(); + +int chan_any(); diff --git a/lang/occam/lib/ocm_parco.h b/lang/occam/lib/ocm_parco.h new file mode 100644 index 00000000..9fb1c647 --- /dev/null +++ b/lang/occam/lib/ocm_parco.h @@ -0,0 +1,19 @@ +/* $Header$ */ +/* parco.h - Define names for simulation routines + * + * This file is to be included by users of the higher-level routines + * + */ + +void pc_begin(), resumenext(), parend(), resume(), coend(); +int pc_fork(); + +#define nullid ((int *) 0 - (int *) 0) + /* I.e. a 0 of type "pointer difference" */ + +#define parbegin(sbrk) pc_begin(sbrk, nullid) +#define parfork() pc_fork(nullid) +#define cobegin(sbrk, id) pc_begin(sbrk, id) +#define cofork(id) pc_fork(id) + +extern int deadlock; diff --git a/lang/occam/lib/ocm_proc.h b/lang/occam/lib/ocm_proc.h new file mode 100644 index 00000000..6eb2824f --- /dev/null +++ b/lang/occam/lib/ocm_proc.h @@ -0,0 +1,53 @@ +/* $Header$ */ +/* process.h - Define administration types and functions + * + * This file is to be included by implementors of the higher + * level routines + * + */ +#include "parco.h" + +#ifndef ptrdiff /* This type must be able to hold a pointer difference */ +#define ptrdiff int /* Define as long int if necessary */ +#endif + +#define nil 0 +void *alloc(), free(); + +typedef ptrdiff wordsize, identification; + +wordsize top_size(); +int top_save(); +void top_load(); /* Primitives */ + +struct procgroup; + +struct process { + struct process *next; /* Next process in the same group */ + struct procgroup *down; /* Process group running under this process */ + void *stack; /* Pointer to the saved stack top */ + identification id; /* Coroutine identification */ +}; + +#define init_between __i_b__ /* These names are hidden */ +#define save_between __s_b__ +#define load_betweens __l_b__ +#define delete_between __d_b__ + +void init_between(), save_between(), load_betweens(), delete_between(); + +struct procgroup { + struct process **active;/* Active process within this group */ + struct procgroup *up; /* The group that this group belongs to */ + struct process *first; /* List of processes belonging to this group */ + void *s_brk; /* Point where the stack is split */ + void *between; /* Stack space between s_brk and up->s_brk */ +}; + +#define group __grp__ /* Ignore this please */ +#define highest_group __hgrp__ + +extern struct procgroup *group; /* Current running group */ +extern struct procgroup *highest_group; /* highest group that has been seen + * while searching for a process + */ diff --git a/lang/occam/lib/par_em2.e b/lang/occam/lib/par_em2.e new file mode 100644 index 00000000..ed45d527 --- /dev/null +++ b/lang/occam/lib/par_em2.e @@ -0,0 +1,53 @@ + mes 2,2,4 + exp $top_size + pro $top_size, 14 + ldl 0 ; s_brk + lor 1 ; s_brk SP + sbs 4 ; s_brk-SP + ret 4 ; return size of block to be saved + end 14 + + exp $top_save + pro $top_save, 0 + loe 0 + lde 4 ; load line number and file name + lim ; ignore mask + lor 0 ; LB + ldl 0 ; size of block + loc 4 + loc 2 + cuu + dup 2 + stl 0 ; push & store size in 2 bytes + lor 1 ; SP (the SP BEFORE pushing) + lor 1 ; SP (address of stack top to save) + ldl 4 ; area + lol 0 ; size + bls 2 ; move whole block + asp 18 ; remove the lot from the stack + loc 1 + ret 2 ; return 1 + end 0 + + exp $top_load + pro $top_load, 0 + ldl 0 + dup 4 + sde area ; copy area pointer from argument 0 + loi 4 ; load indirect to + str 1 ; restore SP + lde area ; load area, note that the SP is now correct + lor 1 ; SP (the SP AFTER, see above) + lde area + lof 4 ; size of block + bls 2 ; move block back (SP becomes the SP BEFORE again!) + asp 2 ; drop size + str 0 ; LB + sim ; ignore mask + sde 4 + ste 0 ; line and file + loc 0 + ret 2 ; return 0 + end 0 +area + bss 4,0,0 diff --git a/lang/occam/lib/par_em4.e b/lang/occam/lib/par_em4.e new file mode 100644 index 00000000..b47cffbd --- /dev/null +++ b/lang/occam/lib/par_em4.e @@ -0,0 +1,46 @@ + mes 2,4,4 + exp $top_size + pro $top_size, 20 + lol 0 ; s_brk + lor 1 ; s_brk SP + sbs 4 ; s_brk-SP + ret 4 ; return size of block to be saved + end 20 + + exp $top_save + pro $top_save, 0 + lde 0 ; load line number and file name + lim ; ignore mask + lor 0 ; LB + lol 0 ; size of block + lor 1 ; SP (the SP BEFORE pushing) + lor 1 ; SP (address of stack top to save) + lol 4 ; area + lol 0 ; size + bls 4 ; move whole block + asp 24 ; remove the lot from the stack + loc 1 + ret 4 ; return 1 + end 0 + + exp $top_load + pro $top_load, 0 + lol 0 + dup 4 + ste area ; copy area pointer from argument 0 + loi 4 ; load indirect to + str 1 ; restore sp + loe area ; load area, note that the SP is now correct + lor 1 ; SP (the SP AFTER, see above) + loe area + lof 4 ; size of block + bls 4 ; move block back (SP becomes the SP BEFORE again!) + asp 4 ; drop size + str 0 ; LB + sim ; ignore mask + sde 0 ; line and file + loc 0 + ret 4 ; return 0 + end 0 +area + bss 4,0,0 diff --git a/lang/occam/lib/par_vax.s b/lang/occam/lib/par_vax.s new file mode 100644 index 00000000..04ab0a97 --- /dev/null +++ b/lang/occam/lib/par_vax.s @@ -0,0 +1,51 @@ + # VAX code for the top_* primitives + + .set BIG, 0x8000 # 32K chunk per movc3 + .text + .align 1 + .globl _top_size + .globl _top_save + .globl _top_load + +_top_size: .word 0x0000 + subl3 sp, 4(ap), r0 # bytes between stack pointer and break + addl2 $(8+6+1)*4, r0 # add 8 regs, 6 pushed longwords (line, file, + ret # ap, fp, size, sp) and 1 extra argument + +_top_save: .word 0x0ff0 # save regs r4-r11 + movq hol0, -(sp) # push line number and file name + movq ap, -(sp) # push LB equivalents ap and fp + pushl 4(ap) # push size + pushal -4(sp) # push sp (the sp AFTER pushing) + movl $BIG, r6 # chunk size in r6 + movl 4(ap), r7 # size of block to move + movl sp, r1 # source address + movl 8(ap), r3 # destination address + cmpl r7, r6 + jlequ 0f +1: movc3 r6, (r1), (r3) # move chunk of the block, add r6 to r1 and r3 + subl2 r6, r7 + cmpl r7, r6 + jgtru 1b +0: movc3 r7, (r1), (r3) # move what's left + movl $1, r0 # return 1 + ret + +_top_load: .word 0x0000 + movl 4(ap), r1 # source + movl (r1), sp # restore sp + movl $BIG, r6 # chunk size + movl 4(r1), r7 # size + movl sp, r3 # destination + cmpl r7, r6 + jlequ 0f +1: movc3 r6, (r1), (r3) # move chunk of the block back + subl2 r6, r7 + cmpl r7, r6 + jgtru 1b +0: movc3 r7, (r1), (r3) # move what's left back + addl2 $8, sp # pop saved sp and size + movq (sp)+, ap # pop LB's + movq (sp)+, hol0 # pop line and file + clrl r0 # return 0 + ret diff --git a/lang/occam/test/tst.ocm b/lang/occam/test/tst.ocm new file mode 100644 index 00000000..7064d84e --- /dev/null +++ b/lang/occam/test/tst.ocm @@ -0,0 +1,24 @@ +#include +#include + +var fmt[byte 100]: +var d, c: +seq + input ? c + decin(input, d, c) + while c<>EOF + seq + chan link: + par + printd(link, "XXXX %%%ds XXXXX*#00", d) + var c, i: + seq + i:=0 + link ? c + while c<>0 + seq + i:=i+1 + fmt[byte i]:=c + link ? c + prints("XXXX %s XXXXX", "YYYYY") + decin(input, d, c) diff --git a/lang/pc/Makefile b/lang/pc/Makefile new file mode 100644 index 00000000..764153fe --- /dev/null +++ b/lang/pc/Makefile @@ -0,0 +1,19 @@ +d=../.. +h=$d/h + +cmp: + (cd comp ; make cmp) + +install: + (cd comp ; make install) + +clean: + -rm -f *.o *.old + (cd comp ; make clean) + +opr: + make pr ^ opr + +pr: + @(cd comp ; make pr) + @(cd libpc ; make pr) diff --git a/lang/pc/comp/Resolve b/lang/pc/comp/Resolve new file mode 100755 index 00000000..e64381d5 --- /dev/null +++ b/lang/pc/comp/Resolve @@ -0,0 +1,60 @@ +: create a directory Xsrc with name clashes resolved +: and run make in that directory +: '$Header$' + +case $# in +1) + ;; +*) echo "$0: one argument expected" 1>&2 + exit 1 + ;; +esac +PW=`pwd` +case $1 in +main) target=$PW/$1 + ;; +omain) target=$PW/$1 + options=-DPEEPHOLE + ;; +cemain) target=$PW/$1 + options=-DCODE_EXPANDER + ;; +Xlint) target=$1 + ;; +*) echo "$0: $1: Illegal argument" 1>&2 + exit 1 + ;; +esac +if test -d ../Xsrc +then + : +else mkdir ../Xsrc +fi +make EMHOME=$EMHOME longnames +: remove code generating routines from the clashes list as they are defines. +: code generating routine names start with C_ +sed '/^C_/d' < longnames > tmp$$ +cclash -c -l7 tmp$$ > ../Xsrc/Xclashes +rm -f tmp$$ +cd ../Xsrc +if cmp -s Xclashes clashes +then + : +else + mv Xclashes clashes +fi +rm -f Makefile +ed - $PW/Makefile <<'EOF' +/^#EXCLEXCL/,/^#INCLINCL/d +w Makefile +q +EOF +for i in `cat $PW/Cfiles` +do + cat >> Makefile < $i +EOF +done +make EMHOME=$EMHOME COPTIONS=$options MACH=$MACH CURRDIR=$PW/ $target diff --git a/lang/pc/comp/Version.c b/lang/pc/comp/Version.c new file mode 100644 index 00000000..42ba0f21 --- /dev/null +++ b/lang/pc/comp/Version.c @@ -0,0 +1 @@ +static char Version[] = "ACK Pascal compiler Version 2.2"; diff --git a/lang/pc/comp/char.c b/lang/pc/comp/char.c new file mode 100644 index 00000000..ee457314 --- /dev/null +++ b/lang/pc/comp/char.c @@ -0,0 +1,394 @@ +#include "class.h" +char tkclass[] = { + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STSKIP, + STNL, + STNL, + STNL, + STSKIP, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STSKIP, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STGARB, + STSTR, + STSIMP, + STSIMP, + STSIMP, + STSIMP, + STSIMP, + STSIMP, + STCOMP, + STSIMP, + STNUM, + STNUM, + STNUM, + STNUM, + STNUM, + STNUM, + STNUM, + STNUM, + STNUM, + STNUM, + STCOMP, + STSIMP, + STCOMP, + STSIMP, + STCOMP, + STGARB, + STSIMP, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STSIMP, + STGARB, + STSIMP, + STSIMP, + STGARB, + STGARB, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STIDF, + STSIMP, + STGARB, + STSIMP, + STGARB, + STGARB, + STEOI, +}; +char inidf[] = { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, +}; +char isdig[] = { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +}; diff --git a/lang/pc/comp/next.c b/lang/pc/comp/next.c new file mode 100644 index 00000000..dc5064a0 --- /dev/null +++ b/lang/pc/comp/next.c @@ -0,0 +1,49 @@ +#include "debug.h" +struct lab *h_lab = 0; +#ifdef DEBUG +int cnt_lab = 0; +#endif +struct forwtype *h_forwtype = 0; +#ifdef DEBUG +int cnt_forwtype = 0; +#endif +struct def *h_def = 0; +#ifdef DEBUG +int cnt_def = 0; +#endif +struct withdesig *h_withdesig = 0; +#ifdef DEBUG +int cnt_withdesig = 0; +#endif +struct node *h_node = 0; +#ifdef DEBUG +int cnt_node = 0; +#endif +struct scope *h_scope = 0; +#ifdef DEBUG +int cnt_scope = 0; +#endif +struct scopelist *h_scopelist = 0; +#ifdef DEBUG +int cnt_scopelist = 0; +#endif +struct paramlist *h_paramlist = 0; +#ifdef DEBUG +int cnt_paramlist = 0; +#endif +struct type *h_type = 0; +#ifdef DEBUG +int cnt_type = 0; +#endif +struct case_hdr *h_case_hdr = 0; +#ifdef DEBUG +int cnt_case_hdr = 0; +#endif +struct case_entry *h_case_entry = 0; +#ifdef DEBUG +int cnt_case_entry = 0; +#endif +struct tmpvar *h_tmpvar = 0; +#ifdef DEBUG +int cnt_tmpvar = 0; +#endif diff --git a/lang/pc/comp/nmclash.c b/lang/pc/comp/nmclash.c new file mode 100644 index 00000000..ca2567a8 --- /dev/null +++ b/lang/pc/comp/nmclash.c @@ -0,0 +1,4 @@ +/* Accepted if many characters of long names are significant */ +abcdefghijklmnopr() { } +abcdefghijklmnopq() { } +main() { } diff --git a/lang/pc/comp/tab.c b/lang/pc/comp/tab.c new file mode 100644 index 00000000..17065cf9 --- /dev/null +++ b/lang/pc/comp/tab.c @@ -0,0 +1,295 @@ +/* @cc tab.c -o $INSTALLDIR/tab@ + tab - table generator + + Author: Erik Baalbergen (..tjalk!erikb) +*/ + +#include + +static char *RcsId = "$Header$"; + +#define MAXTAB 10000 +#define MAXBUF 10000 +#define COMCOM '-' +#define FILECOM '%' + +int InputForm = 'c'; +char OutputForm[MAXBUF] = "%s,\n"; +int TabSize = 257; +char *Table[MAXTAB]; +char *Name; +char *ProgCall; + +main(argc, argv) + char *argv[]; +{ + ProgCall = *argv++; + argc--; + while (argc-- > 0) { + if (**argv == COMCOM) { + option(*argv++); + } + else { + process(*argv++, InputForm); + } + } +} + +char * +Salloc(s) + char *s; +{ + char *malloc(); + char *ns = malloc(strlen(s) + 1); + + if (ns) { + strcpy(ns, s); + } + return ns; +} + +option(str) + char *str; +{ + /* note that *str indicates the source of the option: + either COMCOM (from command line) or FILECOM (from a file). + */ + switch (*++str) { + + case ' ': /* command */ + case '\t': + case '\0': + break; + case 'I': + InputForm = *++str; + break; + case 'f': + if (*++str == '\0') { + fprintf(stderr, "%s: -f: name expected\n", ProgCall); + exit(1); + } + DoFile(str); + break; + case 'F': + sprintf(OutputForm, "%s\n", ++str); + break; + case 'T': + printf("%s\n", ++str); + break; + case 'p': + PrintTable(); + break; + case 'C': + ClearTable(); + break; + case 'S': + { + register i = stoi(++str); + + if (i <= 0 || i > MAXTAB) { + fprintf(stderr, "%s: size would exceed maximum\n", + ProgCall); + } + else { + TabSize = i; + } + break; + } + default: + fprintf(stderr, "%s: bad option -%s\n", ProgCall, str); + } +} + +ClearTable() +{ + register i; + + for (i = 0; i < MAXTAB; i++) { + Table[i] = 0; + } +} + +PrintTable() +{ + register i; + + for (i = 0; i < TabSize; i++) { + if (Table[i]) { + printf(OutputForm, Table[i]); + } + else { + printf(OutputForm, "0"); + } + } +} + +process(str, format) + char *str; +{ + char *cstr = str; + char *Name = cstr; /* overwrite original string! */ + + /* strip of the entry name + */ + while (*str && *str != ':') { + if (*str == '\\') { + ++str; + } + *cstr++ = *str++; + } + + if (*str != ':') { + fprintf(stderr, "%s: bad specification: \"%s\", ignored\n", + ProgCall, Name); + return 0; + } + *cstr = '\0'; + str++; + + switch (format) { + + case 'c': + return c_proc(str, Name); + default: + fprintf(stderr, "%s: bad input format\n", ProgCall); + } + return 0; +} + +c_proc(str, Name) + char *str; + char *Name; +{ + int ch, ch2; + int quoted(); + + while (*str) { + if (*str == '\\') { + ch = quoted(&str); + } + else { + ch = *str++; + } + if (*str == '-') { + if (*++str == '\\') { + ch2 = quoted(&str); + } + else { + if (ch2 = *str++); + else str--; + } + if (ch > ch2) { + fprintf(stderr, "%s: bad range\n", ProgCall); + return 0; + } + if (ch >= 0 && ch2 <= 255) + while (ch <= ch2) + Table[ch++] = Salloc(Name); + } + else { + if (ch >= 0 && ch <= 255) + Table[ch] = Salloc(Name); + } + } + return 1; +} + +int +quoted(pstr) + char **pstr; +{ + register int ch; + register int i; + register char *str = *pstr; + + if ((*++str >= '0') && (*str <= '9')) { + ch = 0; + for (i = 0; i < 3; i++) { + ch = 8 * ch + *str - '0'; + if (*++str < '0' || *str > '9') + break; + } + } + else { + switch (*str++) { + + case 'n': + ch = '\n'; + break; + case 't': + ch = '\t'; + break; + case 'b': + ch = '\b'; + break; + case 'r': + ch = '\r'; + break; + case 'f': + ch = '\f'; + break; + default : + ch = *str; + } + } + *pstr = str; + return ch & 0377; +} + +int +stoi(str) + char *str; +{ + register i = 0; + + while (*str >= '0' && *str <= '9') { + i = i * 10 + *str++ - '0'; + } + return i; +} + +char * +getline(s, n, fp) + char *s; + FILE *fp; +{ + register c = getc(fp); + char *str = s; + + while (n--) { + if (c == EOF) { + return NULL; + } + else + if (c == '\n') { + *str++ = '\0'; + return s; + } + *str++ = c; + c = getc(fp); + } + s[n - 1] = '\0'; + return s; +} + +#define BUFSIZE 1024 + +DoFile(name) + char *name; +{ + char text[BUFSIZE]; + FILE *fp; + + if ((fp = fopen(name, "r")) == NULL) { + fprintf(stderr, "%s: cannot read file %s\n", ProgCall, name); + exit(1); + } + while (getline(text, BUFSIZE, fp) != NULL) { + if (text[0] == FILECOM) { + option(text); + } + else { + process(text, InputForm); + } + } +} diff --git a/lib/descr/fe.src b/lib/descr/fe.src new file mode 100644 index 00000000..c77669d5 --- /dev/null +++ b/lib/descr/fe.src @@ -0,0 +1,225 @@ +# (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. +# $Header$ +# +# Don't generate line updating code by default (i.e.: -L flag provided to cem). +# To put it on again: use -NL +var LFLAG=-L +var C_INCLUDES=-I{EM}/include/_tail_cc +var ANSI_C_INCLUDES=-I{EM}/include/tail_ac + +callname ack +name cpp + # no from, this is a preprocessor + to .i + program {EM}/lib/cpp{ANSI_C?} + mapflag -I* CPP_F={CPP_F?} -I* + mapflag -U* CPP_F={CPP_F?} -U* + mapflag -D* CPP_F={CPP_F?} -D* + mapflag -P CPP_F={CPP_F?} -P + mapflag -C CPP_F={CPP_F?} -C + mapflag -wo CPP_F={CPP_F?} -o + mapflag -ansi ANSI_C=.ansi + args {CPP_F?} ({SUFFIX?}:.ocm=-I{EM}/include/occam) \ + ({ANSI_C?}:.ansi={SYSINCLUDES?} {ANSI_C_INCLUDES} {INCLUDES?}) \ + ({ANSI_C?.c}:{SUFFIX}={SYSINCLUDES?} {C_INCLUDES} {INCLUDES?}) \ + -D{NAME} \ + ({ANSI_C?.xx}:.xx=-DEM_WSIZE={w} -DEM_PSIZE={p} \ + -DEM_SSIZE={s} -DEM_LSIZE={l} -DEM_FSIZE={f} -DEM_DSIZE={d}) \ + -D_EM_WSIZE={w} -D_EM_PSIZE={p} \ + -D_EM_SSIZE={s} -D_EM_LSIZE={l} -D_EM_FSIZE={f} -D_EM_DSIZE={d} \ + < + stdout + prep is +end +name cem + from .c + to .k + program {EM}/lib/em_cemcom{ANSI_C?} + mapflag -ansi ANSI=ansi +# mapflag -I* CPP_F={CPP_F?} -I* +# mapflag -U* CPP_F={CPP_F?} -U* +# mapflag -D* CPP_F={CPP_F?} -D* + mapflag -M* CEM_F={CEM_F?} -M* + mapflag -L CEM_F={CEM_F?} -L + mapflag -A CEM_F={CEM_F?} -A + mapflag -NL LFLAG= + mapflag -KR CEM_F={CEM_F?} -R + mapflag -w CEM_F={CEM_F?} -w + mapflag -wa CEM_F={CEM_F?} -a + mapflag -wo CEM_F={CEM_F?} -o + mapflag -ws CEM_F={CEM_F?} -s + mapflag -g CEM_F={CEM_F?} -g + mapflag -p CEM_F={CEM_F?} -p + mapflag -V* CEM_F={CEM_F?} -V* + rts .c + need .c + args \ + {CPP_F?} \ + {SYSINCLUDES?} \ + ({ANSI_C?}:.ansi={ANSI_C_INCLUDES}) \ + ({ANSI_C?.c}:.c={C_INCLUDES}) \ + {INCLUDES?} \ + -D{NAME} \ + -D_EM_WSIZE={w} -D_EM_PSIZE={p} \ + -D_EM_SSIZE={s} -D_EM_LSIZE={l} -D_EM_FSIZE={f} -D_EM_DSIZE={d} \ + -Vw{w}.{w}i{w}.{w}p{p}.{w}f{f}.{w}s{s}.{s}l{l}.{w}d{d}.{w} \ + {CC_ALIGN?} \ + {CEM_F?} {LFLAG?} < > + callname acc + callname cc +end +name pc + from .p + to .k + program {EM}/lib/em_pc + mapflag -L PC_F={PC_F?} -L +# mapflag -s PC_F={PC_F?} -s + mapflag -_ PC_F={PC_F?} -U + mapflag -w PC_F={PC_F?} -w + mapflag -V* PC_F={PC_F?} -V* + mapflag -M* PC_F={PC_F?} -M* +# mapflag -i* PC_F={PC_F?} -i* + mapflag -A PC_F={PC_F?} -A +# mapflag -R PC_F={PC_F?} -R + mapflag --* PC_F={PC_F?} -* +#range checks can only be disabled through comments + args \ + -Vw{w}.{w}i{w}.{w}l{l}.{w}p{p}.{w}f{d}.{w}S{w}.{w} \ + {PC_F?} < > {SOURCE} + prep cond + rts .p + need .p + callname apc + callname pc +end +name m2 + from .mod.def + to .k + program {EM}/lib/em_m2 + mapflag -I* M2_INCL={M2_INCL?} -I* + mapflag -L M2_F={M2_F?} -L + mapflag -g M2_F={M2_F?} -g + mapflag -w* M2_F={M2_F?} -w* + mapflag -W* M2_F={M2_F?} -W* + mapflag -_ M2_F={M2_F?} -U + mapflag -M* M2_F={M2_F?} -M* + mapflag -x M2_F={M2_F?} -x + mapflag -Xs M2_F={M2_F?} -s + mapflag -V* M2_F={M2_F?} -V* + mapflag --* M2_F={M2_F?} -* + args \ + {M2_INCL?} -I{EM}/lib/m2 {M2SYSLIB?} \ + -Vw{w}.{w}i{w}.{w}p{p}.{w}l{l}.{w}f{f}.{w}d{d}.{w} \ + {M2_ALIGN?} {M2_F?} < > + prep cond + rts .mod + need .mod + callname m2 +end +name ocm + from .ocm + to .k + program {EM}/lib/em_occam + mapflag -L OCM_F={OCM_F?} -L + mapflag -V* OCM_F={OCM_F?} -V* + args -Vw{w}p{p}l{l} {OCM_F?} + stdin + stdout + rts .ocm + need .ocm + prep cond + callname ocm +end +name abc + from .b + to .k + program {EM}/lib/em_bem + mapflag -h ABC_F={ABC_F?} -h + mapflag -w ABC_F={ABC_F?} -w + mapflag -L ABC_F={ABC_F?} -L + mapflag -E ABC_F={ABC_F?} -E +# mapflag -d ABC_F={ABC_F?} -d + args -Vw{w}p{p}f{d} {ABC_F?} < > {SOURCE} + prep cond + rts .b + need .b + callname abc +end +var A68INIT={EM}/lib/em_a68s_init +name a68s + from .8.a68 + to .k + program {EM}/lib/em_a68s{w}{p} + mapflag -PA* A68INIT=* + args < > {SOURCE}.lst {A68INIT}{w}{p} /dev/null + prep cond + rts .8 + need .8 + callname a68s +end +name encode + from .e + to .k + program {EM}/lib/em_encode + args < + prep cond + stdout +end +name opt + from .k + to .m + program {EM}/lib/em_opt + mapflag -LIB OPT_F={OPT_F?} -L + args {OPT_F?} < + stdout + optimizer +end +name ego + from .m.ma + to .gk + program {EM}/lib/em_ego + mapflag -EGO-* EGO_F={EGO_F?} -* +# The following lines are obsolete, but here for backwards compatibility. +# They should be removed some day. + mapflag -IL* EGO_F={EGO_F?} -IL* + mapflag -CS* EGO_F={EGO_F?} -CS* + mapflag -SR* EGO_F={EGO_F?} -SR* + mapflag -UD* EGO_F={EGO_F?} -UD* + mapflag -LV* EGO_F={EGO_F?} -LV* + mapflag -SA* EGO_F={EGO_F?} -RA* + mapflag -SP* EGO_F={EGO_F?} -SP* + mapflag -BO* EGO_F={EGO_F?} -BO* + mapflag -CJ* EGO_F={EGO_F?} -CJ* + mapflag -EV EGO_F={EGO_F?} -V +# End of obsolete lines + mapflag -Q* EGO_F={EGO_F?} -Q* + mapflag -T* EGO_F={EGO_F?} -T* + mapflag -S* EGO_F={EGO_F?} -S* + mapflag -s* EGO_F={EGO_F?} -s* + mapflag -a EGO_F={EGO_F?} -a + mapflag -O* EGO_F={EGO_F?} -O* + args \ + {EGO_F?} -P {EM}/lib/ego \ + -M{EM}/lib/ego/{M}descr < + optimizer 2 + stdout + combiner +end +name opt2 + # output of the global optimizer is processed by a stripped version + # of the em peephole optimizer + from .gk + to .g + program {EM}/lib/em_opt2 +# mapflag -LIB OPT_F={OPT_F?} -L + args {OPT_F?} < + optimizer + stdout +end +name decode + from .k.m.g.gk + to .e + program {EM}/lib/em_decode + args < + stdout +end diff --git a/lib/descr/ibm.nosid b/lib/descr/ibm.nosid new file mode 100644 index 00000000..d334f57b --- /dev/null +++ b/lib/descr/ibm.nosid @@ -0,0 +1,40 @@ +# $Revision$ +var w=2 +var p=2 +var s=2 +var l=4 +var f=4 +var d=8 +var NAME=i8086 +var M=i86 +var LIB=lib/i86/tail_ +var LIBIBM=lib/ibm/tail_ +var RT=lib/i86/head_ +var RTIBM=lib/ibm/head_ +var CPP_F=-Dunix +var INCLUDES=-I{EM}/include -I{EM}/lib/ibm/include +name be + from .m.g + to .s + program {EM}/lib/{M}/cg + args < + stdout + need .e +end +name asld + from .s.a + to .out + outfile a.out + program {EM}/lib/{M}/as + mapflag -l* LNAME={EM}/{LIB}* + mapflag -i IFILE={EM}/{RT}i + args {IFILE?} (.e:{HEAD}={EM}/{RTIBM}em) \ + ({RTS}:.b.c={EM}/{RT}cc) ({RTS}:.p={EM}/{RT}pc) -o > < \ + (.p:{TAIL}={EM}/{LIB}pc) \ + (.b:{TAIL}={EM}/{LIB}bc) \ + (.b.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \ + (.e:{TAIL}={EM}/{LIBIBM}em) \ + (.b.c.p:{TAIL}={EM}/{LIBIBM}mon) \ + (.e:{TAIL}={EM}/{LIBIBM}em.vend) + linker +end diff --git a/lib/descr/int b/lib/descr/int new file mode 100644 index 00000000..a4043e7b --- /dev/null +++ b/lib/descr/int @@ -0,0 +1,35 @@ +# $Revision$ +var w=2 +var p=2 +var s=2 +var l=4 +var f=4 +var d=8 +var M=int +var NAME=int22 +var LIB=lib/int22/tail_ +var RT=lib/int22/head_ +var SIZE_FLAG=-sm +var CPP_F=-Dunix=unix +var INCLUDES=-I{EM}/include/_tail_cc -I{EM}/include/_tail_mon +name asld + from .k.m.a.g + to .out + outfile e.out + program {EM}/lib/em_ass + mapflag -l* LNAME={EM}/{LIB}* + mapflag -+* ASS_F={ASS_F?} -+* + mapflag --* ASS_F={ASS_F?} --* + mapflag -s* SIZE_FLAG=-s* + args {SIZE_FLAG} \ + ({RTS}:.ocm.b.c={EM}/{RT}cc) \ + ({RTS}:.mod={EM}/{RT}m2) \ + ({RTS}:.p={EM}/{RT}pc) -o > < \ + (.p:{TAIL}={EM}/{LIB}pc) \ + (.b:{TAIL}={EM}/{LIB}bc) \ + (.ocm:{TAIL}={EM}/{LIB}ocm) \ + (.mod:{TAIL}={EM}/{LIB}m2) \ + (.ocm.b.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \ + (.mod.ocm.b.c.p:{TAIL}={EM}/{LIB}mon) + linker +end diff --git a/lib/descr/m68k2.macs b/lib/descr/m68k2.macs new file mode 100644 index 00000000..203e7e31 --- /dev/null +++ b/lib/descr/m68k2.macs @@ -0,0 +1,39 @@ +# $Revision$ +var w=2 +var p=4 +var s=2 +var l=4 +var f=4 +var d=8 +var NAME=m68k2 +var M=m68k2 +var LIBDIR=/lib/{M} +var LIB=lib/{M}/tail_ +var RT=lib/{M}/head_ +var INCLUDES=-I{EM}/include -I/usr/include +name be + from .m.g + to .s + program {EM}/lib/{M}/cg + args < + stdout + need .e +end +name asld + from .s.a + to .out + outfile a.out + program {EM}/lib/{M}/as + mapflag -l* LNAME={EM}/{LIB}* + args (.e:{HEAD}={EM}/{RT}em) \ +({RTS}:.b.c={EM}/{RT}cc) ({RTS}:.p={EM}/{RT}pc) -o > < \ +(.p.c.b:{TAIL}={EM}/{LIBDIR}/sys1.s) (.p:{TAIL}={EM}/{LIBDIR}/sys2.s) \ +(.c:{TAIL}={EM}/{LIBDIR}/write.s) \ +(.p:{TAIL}={EM}/{LIB}pc) \ +(.b:{TAIL}={EM}/{LIB}bc) \ +(.b.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \ +(.b.c:{TAIL}={EM}/{LIB}mon {EM}/{LIB}fake) \ +(.e:{TAIL}={EM}/{LIB}em.rt {EM}/{LIB}em.vend) + prep cond + linker +end diff --git a/lib/descr/nascom b/lib/descr/nascom new file mode 100644 index 00000000..db67d200 --- /dev/null +++ b/lib/descr/nascom @@ -0,0 +1,30 @@ +# $Revision$ +var w=1 +var p=2 +var s=1 +var l=2 +var f=4 +var d=8 +var NAME=nascom +var M=z80a +var LIB=lib/{M}/tail_ +var RT=lib/{M}/head_ +var INCLUDES=-I{EM}/include -I/usr/include +name be + from .m.g + to .s + program {EM}/lib/{M}/be + args < + stdout + need .e +end +name asld + from .s.a + to .out + outfile a.out + program {EM}/lib/z80/as + mapflag -l* LNAME={EM}/{LIB}* + args (.e:{HEAD}={EM}/{RT}em) ({RTS}:.b.c={EM}/{RT}cc) -o > \ +(.e:{TAIL}={EM}/{LIB}em.1 {EM}/{LIB}em.2) + linker +end diff --git a/lib/descr/net86 b/lib/descr/net86 new file mode 100644 index 00000000..27097aed --- /dev/null +++ b/lib/descr/net86 @@ -0,0 +1,32 @@ +var w=2 +var p=2 +var s=2 +var l=4 +var f=4 +var d=8 +var NAME=i8086 +var M=i86 +var LIB=mach/i86/lib/tail_ +var RT=mach/i86/lib/head_ +var INCLUDES=-I{EM}/include -I/usr/include +name be + from .m + to .s + program {EM}/lib/{M}_cg + args < + prop > + need .e +end +name asld + from .s.a + to a.out + program {EM}/lib/{M}_as + mapflag -l* LNAME={EM}/{LIB}* + mapflag -i IFILE={EM}/{RT}i + args {IFILE?} (.e:{HEAD}={EM}/{RT}em) \ +({RTS}:.c={EM}/{RT}cc) ({RTS}:.p={EM}/{RT}pc) -o > < \ +(.p:{TAIL}={EM}/{LIB}pc) (.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \ +(.c.p.e:{TAIL}={EM}/{LIB}netio) (.c.p.e:{TAIL}={EM}/{LIB}alo) \ +(.c.p:{TAIL}={EM}/{LIB}mon) (.e:{TAIL}={EM}/{LIB}em) + prop C +end diff --git a/lib/descr/sat86 b/lib/descr/sat86 new file mode 100644 index 00000000..ecfa18d8 --- /dev/null +++ b/lib/descr/sat86 @@ -0,0 +1,34 @@ +var w=2 +var p=2 +var s=2 +var l=4 +var f=4 +var d=8 +var NAME=i8086 +var M=i86 +var LIB=mach/i86/lib/tail_ +var ALIB=mach/i86/lib/sat_tail_ +var RT=mach/i86/lib/head_ +var ART=mach/i86/lib/sat_head_ +var CCP_F=-Dunix +var INCLUDES=-I{EM}/include -I/usr/include +name be + from .m + to .s + program {EM}/lib/{M}_cg + args < + prop > + need .e +end +name asld + from .s.a + to a.out + program {EM}/lib/{M}_as + mapflag -l* LNAME={EM}/{LIB}* + args (.e:{HEAD}={EM}/{ART}em) \ +({RTS}:.c={EM}/{RT}cc) ({RTS}:.p={EM}/{RT}pc) -o > < \ +(.p:{TAIL}={EM}/{LIB}pc) (.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \ +(.c.p:{TAIL}={EM}/{ALIB}mon) (.c.p.e:{TAIL}={EM}/{LIB}alo) \ +(.e:{TAIL}={EM}/{LIB}em) + prop C +end diff --git a/lib/minix/include/minix/error.h b/lib/minix/include/minix/error.h new file mode 100644 index 00000000..302207f2 --- /dev/null +++ b/lib/minix/include/minix/error.h @@ -0,0 +1,59 @@ +/* Error codes. They are negative since a few system calls, such as READ, can + * either return a positive number indicating success, or an error code. + */ + +#define NERROR 34 +#define OK 0 +#define ERROR -1 +#define EPERM -1 +#define ENOENT -2 +#define ESRCH -3 +#define EINTR -4 +#define EIO -5 +#define ENXIO -6 +#define E2BIG -7 +#define ENOEXEC -8 +#define EBADF -9 +#define ECHILD -10 +#define EAGAIN -11 +#define ENOMEM -12 +#define EACCES -13 +#define EFAULT -14 +#define ENOTBLK -15 +#define EBUSY -16 +#define EEXIST -17 +#define EXDEV -18 +#define ENODEV -19 +#define ENOTDIR -20 +#define EISDIR -21 +#define EINVAL -22 +#define ENFILE -23 +#define EMFILE -24 +#define ENOTTY -25 +#define ETXTBSY -26 +#define EFBIG -27 +#define ENOSPC -28 +#define ESPIPE -29 +#define EROFS -30 +#define EMLINK -31 +#define EPIPE -32 +#define EDOM -33 +#define ERANGE -34 + +#define E_LOCKED -101 +#define E_BAD_CALL -102 +#define E_LONG_STRING -103 +#define EOF -104 /* End Of File - used by drivers */ + +/* The following error codes are generated by the kernel itself. */ +#define E_BAD_DEST -1 /* destination address illegal */ +#define E_BAD_SRC -2 /* source address illegal */ +#define E_TRY_AGAIN -3 /* can't send-- tables full */ +#define E_OVERRUN -4 /* interrupt for task that is not waiting */ +#define E_BAD_BUF -5 /* message buf outside caller's addr space */ +#define E_TASK -6 /* can't send to task */ +#define E_NO_MESSAGE -7 /* RECEIVE failed: no message present */ +#define E_NO_PERM -8 /* ordinary users can't send to tasks */ +#define E_BAD_FCN -9 /* only valid fcns are SEND, RECEIVE, BOTH */ +#define E_BAD_ADDR -10 /* bad address given to utility routine */ +#define E_BAD_PROC -11 /* bad proc number given to utility */ diff --git a/lib/minix/include/minix/sgtty.h b/lib/minix/include/minix/sgtty.h new file mode 100644 index 00000000..302207f2 --- /dev/null +++ b/lib/minix/include/minix/sgtty.h @@ -0,0 +1,59 @@ +/* Error codes. They are negative since a few system calls, such as READ, can + * either return a positive number indicating success, or an error code. + */ + +#define NERROR 34 +#define OK 0 +#define ERROR -1 +#define EPERM -1 +#define ENOENT -2 +#define ESRCH -3 +#define EINTR -4 +#define EIO -5 +#define ENXIO -6 +#define E2BIG -7 +#define ENOEXEC -8 +#define EBADF -9 +#define ECHILD -10 +#define EAGAIN -11 +#define ENOMEM -12 +#define EACCES -13 +#define EFAULT -14 +#define ENOTBLK -15 +#define EBUSY -16 +#define EEXIST -17 +#define EXDEV -18 +#define ENODEV -19 +#define ENOTDIR -20 +#define EISDIR -21 +#define EINVAL -22 +#define ENFILE -23 +#define EMFILE -24 +#define ENOTTY -25 +#define ETXTBSY -26 +#define EFBIG -27 +#define ENOSPC -28 +#define ESPIPE -29 +#define EROFS -30 +#define EMLINK -31 +#define EPIPE -32 +#define EDOM -33 +#define ERANGE -34 + +#define E_LOCKED -101 +#define E_BAD_CALL -102 +#define E_LONG_STRING -103 +#define EOF -104 /* End Of File - used by drivers */ + +/* The following error codes are generated by the kernel itself. */ +#define E_BAD_DEST -1 /* destination address illegal */ +#define E_BAD_SRC -2 /* source address illegal */ +#define E_TRY_AGAIN -3 /* can't send-- tables full */ +#define E_OVERRUN -4 /* interrupt for task that is not waiting */ +#define E_BAD_BUF -5 /* message buf outside caller's addr space */ +#define E_TASK -6 /* can't send to task */ +#define E_NO_MESSAGE -7 /* RECEIVE failed: no message present */ +#define E_NO_PERM -8 /* ordinary users can't send to tasks */ +#define E_BAD_FCN -9 /* only valid fcns are SEND, RECEIVE, BOTH */ +#define E_BAD_ADDR -10 /* bad address given to utility routine */ +#define E_BAD_PROC -11 /* bad proc number given to utility */ diff --git a/lib/minix/include/minix/stat.h b/lib/minix/include/minix/stat.h new file mode 100644 index 00000000..4c8b018f --- /dev/null +++ b/lib/minix/include/minix/stat.h @@ -0,0 +1,26 @@ +struct stat { + short int st_dev; + unsigned short st_ino; + unsigned short st_mode; + short int st_nlink; + short int st_uid; + short int st_gid; + short int st_rdev; + long st_size; + long st_atime; + long st_mtime; + long st_ctime; +}; + +/* Some common definitions. */ +#define S_IFMT 0170000 /* type of file */ +#define S_IFDIR 0040000 /* directory */ +#define S_IFCHR 0020000 /* character special */ +#define S_IFBLK 0060000 /* block special */ +#define S_IFREG 0100000 /* regular */ +#define S_ISUID 04000 /* set user id on execution */ +#define S_ISGID 02000 /* set group id on execution */ +#define S_ISVTX 01000 /* save swapped text even after use */ +#define S_IREAD 00400 /* read permission, owner */ +#define S_IWRITE 00200 /* write permission, owner */ +#define S_IEXEC 00100 /* execute/search permission, owner */ diff --git a/lib/minix/include/sys/dir.h b/lib/minix/include/sys/dir.h new file mode 100644 index 00000000..91bb04ac --- /dev/null +++ b/lib/minix/include/sys/dir.h @@ -0,0 +1,17 @@ +/* The header gives the layout of a directory. */ + +#ifndef _DIR_H +#define _DIR_H + +#define DIRBLKSIZ 512 /* size of directory block */ + +#ifndef DIRSIZ +#define DIRSIZ 14 +#endif + +struct direct { + ino_t d_ino; + char d_name[DIRSIZ]; +}; + +#endif /* _DIR_H */ diff --git a/lib/minixST/include/minix/callnr.h b/lib/minixST/include/minix/callnr.h new file mode 100644 index 00000000..9ecc2d95 --- /dev/null +++ b/lib/minixST/include/minix/callnr.h @@ -0,0 +1,58 @@ +#define NCALLS 70 /* number of system calls allowed */ + +#define EXIT 1 +#define FORK 2 +#define READ 3 +#define WRITE 4 +#define OPEN 5 +#define CLOSE 6 +#define WAIT 7 +#define CREAT 8 +#define LINK 9 +#define UNLINK 10 +#define CHDIR 12 +#define TIME 13 +#define MKNOD 14 +#define CHMOD 15 +#define CHOWN 16 +#define BRK 17 +#define STAT 18 +#define LSEEK 19 +#define GETPID 20 +#define MOUNT 21 +#define UMOUNT 22 +#define SETUID 23 +#define GETUID 24 +#define STIME 25 +#define PTRACE 26 +#define ALARM 27 +#define FSTAT 28 +#define PAUSE 29 +#define UTIME 30 +#define ACCESS 33 +#define SYNC 36 +#define KILL 37 +#define RENAME 38 +#define MKDIR 39 +#define RMDIR 40 +#define DUP 41 +#define PIPE 42 +#define TIMES 43 +#define SETGID 46 +#define GETGID 47 +#define SIGNAL 48 +#define IOCTL 54 +#define FCNTL 55 +#define EXEC 59 +#define UMASK 60 +#define CHROOT 61 + +/* The following are not system calls, but are processed like them. */ +#define KSIG 64 /* kernel detected a signal */ +#define UNPAUSE 65 /* to MM or FS: check for EINTR */ +#define BRK2 66 /* to MM: used to say how big FS & INIT are */ +#define REVIVE 67 /* to FS: revive a sleeping process */ +#define TASK_REPLY 68 /* to FS: reply code from tty task */ + +/* The following IS a system call for amoeba transactions */ +#define AM_SYSCALL 69 diff --git a/lib/minixST/include/minix/com.h b/lib/minixST/include/minix/com.h new file mode 100644 index 00000000..2096f8ba --- /dev/null +++ b/lib/minixST/include/minix/com.h @@ -0,0 +1,166 @@ +/* System calls. */ +#define SEND 1 /* function code for sending messages */ +#define RECEIVE 2 /* function code for receiving messages */ +#define BOTH 3 /* function code for SEND + RECEIVE */ +#define ANY (NR_PROCS+100) /* receive(ANY, buf) accepts from any source */ + +/* Task numbers, function codes and reply codes. */ + +#define TTY -NR_TASKS /* terminal I/O class */ +# define TTY_READ 3 /* fcn code for reading from tty */ +# define TTY_WRITE 4 /* fcn code for writing to tty */ +# define TTY_IOCTL 5 /* fcn code for ioctl */ +# define TTY_SETPGRP 6 /* fcn code for setpgrp */ +# define TTY_OPEN 7 /* fcn code for opening tty */ +# define TTY_CLOSE 8 /* fcn code for closing tty */ +# define SUSPEND -998 /* used in interrupts when tty has no data */ + +#ifdef AM_KERNEL +#define AMOEBA +#endif + +#ifdef AMOEBA + +/* There are AM_NTASK copies of the amoeba kernel task. + * If you change AM_NTASKS be sure to adjust kernel/table.c and fs/table.c + */ +#define AM_NTASKS 4 /* number of kernel tasks of this class */ + +#define AMINT_CLASS (TTY+1) /* Amoeba event handler */ +#define AMOEBA_CLASS (AMINT_CLASS+AM_NTASKS) /* transaction handlers */ +# define ETHER_ARRIV 1 /* fcn code for packet arrival */ +# define AM_TRANS 2 /* amoeba transaction */ +# define AM_GETREQ 3 /* amoeba getrequest */ +# define AM_PUTREP 4 /* amoeba putrep */ +# define AM_REVIVE 6 /* used by kernel task to revive luser task */ +# define AM_TIMEOUT 8 /* used to talk to clock task */ +# define AM_PUTSIG 9 /* when the luser hits the DEL ! */ +# define AM_TASK_DIED 10 /* sent if task died during a transaction */ + +#else /* if AMOEBA not defined */ + +#define AMOEBA_CLASS TTY + +#endif /* AMOEBA */ + +/* + * New class definitions should go here and should be defined relative + * to AMOEBA_CLASS (ie. as AMOEBA_CLASS+n, for the nth task added). + */ + +#define IDLE (AMOEBA_CLASS+1) /* task to run when there's nothing to run */ + +#define PRINTER -7 /* printer I/O class */ +/* The printer uses the same commands as TTY. */ + +#define WINCHESTER -6 /* winchester (hard) disk class */ +#define FLOPPY -5 /* floppy disk class */ +# define DISK_READ 3 /* fcn code to DISK (must equal TTY_READ) */ +# define DISK_WRITE 4 /* fcn code to DISK (must equal TTY_WRITE) */ +# define DISK_IOCTL 5 /* fcn code for setting up RAM disk */ +# define SCATTERED_IO 6 /* fcn code for multiple reads/writes */ +# define OPTIONAL_IO 16 /* modifier to DISK_* codes within vector */ + +#define MEM -4 /* /dev/ram, /dev/(k)mem and /dev/null class */ +# define RAM_DEV 0 /* minor device for /dev/ram */ +# define MEM_DEV 1 /* minor device for /dev/mem */ +# define KMEM_DEV 2 /* minor device for /dev/kmem */ +# define NULL_DEV 3 /* minor device for /dev/null */ +#if (CHIP == INTEL) +# define PORT_DEV 4 /* minor device for /dev/port */ +#endif + +#define CLOCK -3 /* clock class */ +# define SET_ALARM 1 /* fcn code to CLOCK, set up alarm */ +# define GET_TIME 3 /* fcn code to CLOCK, get real time */ +# define SET_TIME 4 /* fcn code to CLOCK, set real time */ +# define REAL_TIME 1 /* reply from CLOCK: here is real time */ + +#define SYSTASK -2 /* internal functions */ +# define SYS_XIT 1 /* fcn code for sys_xit(parent, proc) */ +# define SYS_GETSP 2 /* fcn code for sys_sp(proc, &new_sp) */ +# define SYS_SIG 3 /* fcn code for sys_sig(proc, sig) */ +# define SYS_FORK 4 /* fcn code for sys_fork(parent, child) */ +# define SYS_NEWMAP 5 /* fcn code for sys_newmap(procno, map_ptr) */ +# define SYS_COPY 6 /* fcn code for sys_copy(ptr) */ +# define SYS_EXEC 7 /* fcn code for sys_exec(procno, new_sp) */ +# define SYS_TIMES 8 /* fcn code for sys_times(procno, bufptr) */ +# define SYS_ABORT 9 /* fcn code for sys_abort() */ +# define SYS_FRESH 10 /* fcn code for sys_fresh() (Atari only) */ +# define SYS_KILL 11 /* fcn code for sys_kill(proc, sig) */ +# define SYS_GBOOT 12 /* fcn code for sys_gboot(procno, bootptr) */ +# define SYS_UMAP 13 /* fcn code for sys_umap(procno, etc) */ +# define SYS_MEM 14 /* fcn code for sys_mem() */ +# define SYS_TRACE 15 /* fcn code for sys_trace(req,pid,addr,data) */ + +#define HARDWARE -1 /* used as source on interrupt generated msgs*/ + +/* Names of message fields for messages to CLOCK task. */ +#define DELTA_TICKS m6_l1 /* alarm interval in clock ticks */ +#define FUNC_TO_CALL m6_f1 /* pointer to function to call */ +#define NEW_TIME m6_l1 /* value to set clock to (SET_TIME) */ +#define CLOCK_PROC_NR m6_i1 /* which proc (or task) wants the alarm? */ +#define SECONDS_LEFT m6_l1 /* how many seconds were remaining */ + +/* Names of message fields used for messages to block and character tasks. */ +#define DEVICE m2_i1 /* major-minor device */ +#define PROC_NR m2_i2 /* which (proc) wants I/O? */ +#define COUNT m2_i3 /* how many bytes to transfer */ +#define POSITION m2_l1 /* file offset */ +#define ADDRESS m2_p1 /* core buffer address */ + +/* Names of message fields for messages to TTY task. */ +#define TTY_LINE m2_i1 /* message parameter: terminal line */ +#define TTY_REQUEST m2_i3 /* message parameter: ioctl request code */ +#define TTY_SPEK m2_l1 /* message parameter: ioctl speed, erasing */ +#define TTY_FLAGS m2_l2 /* message parameter: ioctl tty mode */ +#define TTY_PGRP m2_i3 /* message parameter: process group */ + +/* Names of messages fields used in reply messages from tasks. */ +#define REP_PROC_NR m2_i1 /* # of proc on whose behalf I/O was done */ +#define REP_STATUS m2_i2 /* bytes transferred or error number */ + +/* Names of fields for copy message to SYSTASK. */ +#define SRC_SPACE m5_c1 /* T or D space (stack is also D) */ +#define SRC_PROC_NR m5_i1 /* process to copy from */ +#define SRC_BUFFER m5_l1 /* virtual address where data come from */ +#define DST_SPACE m5_c2 /* T or D space (stack is also D) */ +#define DST_PROC_NR m5_i2 /* process to copy to */ +#define DST_BUFFER m5_l2 /* virtual address where data go to */ +#define COPY_BYTES m5_l3 /* number of bytes to copy */ + +/* Field names for accounting, SYSTASK and miscellaneous. */ +#define USER_TIME m4_l1 /* user time consumed by process */ +#define SYSTEM_TIME m4_l2 /* system time consumed by process */ +#define CHILD_UTIME m4_l3 /* user time consumed by process' children */ +#define CHILD_STIME m4_l4 /* sys time consumed by process' children */ + +#define PROC1 m1_i1 /* indicates a process */ +#define PROC2 m1_i2 /* indicates a process */ +#define PID m1_i3 /* process id passed from MM to kernel */ +#define STACK_PTR m1_p1 /* used for stack ptr in sys_exec, sys_getsp */ +#define PR m6_i1 /* process number for sys_sig */ +#define SIGNUM m6_i2 /* signal number for sys_sig */ +#define FUNC m6_f1 /* function pointer for sys_sig */ +#define MEM_PTR m1_p1 /* tells where memory map is for sys_newmap */ +#define CANCEL 0 /* general request to force a task to cancel */ +#define SIG_MAP m1_i2 /* used by kernel for passing signal bit map */ + +#ifdef AMOEBA + +/* Names of message fields for amoeba tasks */ +#define AM_OP m2_i1 /* one of the above operators */ +#define AM_PROC_NR m2_i2 /* process # of proc doing operation */ +#define AM_COUNT m2_i3 /* size of buffer for operation */ +#define AM_ADDRESS m2_p1 /* address of buffer for operation */ + +/* For communication between MM and AMOEBA_CLASS kernel tasks */ +#define AM_STATUS m2_i3 /* same use as REP_STATUS but for amoeba */ +#define AM_FREE_IT m2_l1 /* 1=not a getreq, 0=is a getreq */ + +/* Special for passing a physical address from the ethernet driver */ +#define AM_PADDR m2_l1 /* to the transaction layer */ + +#endif /* AMOEBA */ + +#define HARD_INT 2 /* fcn code for all hardware interrupts */ diff --git a/lib/minixST/include/minix/const.h b/lib/minixST/include/minix/const.h new file mode 100644 index 00000000..77fc6fe4 --- /dev/null +++ b/lib/minixST/include/minix/const.h @@ -0,0 +1,88 @@ +/* Copyright (C) 1990 by Prentice-Hall, Inc. Permission is hereby granted + * to redistribute the binary and source programs of this system for + * educational or research purposes. For other use, written permission from + * Prentice-Hall is required. + */ + +#define EXTERN extern /* used in *.h files */ +#define PRIVATE static /* PRIVATE x limits the scope of x */ +#define PUBLIC /* PUBLIC is the opposite of PRIVATE */ +#define FORWARD static /* some compilers require this to be 'static'*/ + +#define TRUE 1 /* used for turning integers into Booleans */ +#define FALSE 0 /* used for turning integers into Booleans */ + +#define HZ 60 /* clock freq (software settable on IBM-PC) */ +#define BLOCK_SIZE 1024 /* # bytes in a disk block */ +#define SUPER_USER (uid_t) 0 /* uid_t of superuser */ + +#define MAJOR 8 /* major device = (dev>>MAJOR) & 0377 */ +#define MINOR 0 /* minor device = (dev>>MINOR) & 0377 */ + +#ifdef AM_KERNEL +#define NR_TASKS 14 /* must be 5 more than without amoeba */ +#else +#define NR_TASKS 9 /* number of tasks in the transfer vector */ +#endif + +#define NR_PROCS 32 /* number of slots in proc table */ +#define NR_SEGS 3 /* # segments per process */ +#define T 0 /* proc[i].mem_map[T] is for text */ +#define D 1 /* proc[i].mem_map[D] is for data */ +#define S 2 /* proc[i].mem_map[S] is for stack */ + +#define MAX_P_LONG 2147483647 /* maximum positive long, i.e. 2**31 - 1 */ + +/* Memory is allocated in clicks. */ +#if (CHIP == INTEL) || (CHIP == M68000) +#define CLICK_SIZE 256 /* unit in which memory is allocated */ +#define CLICK_SHIFT 8 /* log2 of CLICK_SIZE */ +#endif + +#define click_to_round_k(n) \ + ((unsigned) ((((unsigned long) (n) << CLICK_SHIFT) + 512) / 1024)) +#if CLICK_SIZE < 1024 +#define k_to_click(n) ((n) * (1024 / CLICK_SIZE)) +#else +#define k_to_click(n) ((n) / (CLICK_SIZE / 1024)) +#endif + +/* Process numbers of some important processes */ +#define MM_PROC_NR 0 /* process number of memory manager */ +#define FS_PROC_NR 1 /* process number of file system */ +#define INIT_PROC_NR 2 /* init -- the process that goes multiuser */ +#define LOW_USER 2 /* first user not part of operating system */ + +/* Miscellaneous */ +#define BYTE 0377 /* mask for 8 bits */ +#define TO_USER 0 /* flag telling to copy from fs to user */ +#define FROM_USER 1 /* flag telling to copy from user to fs */ +#define READING 0 /* copy data to user */ +#define WRITING 1 /* copy data from user */ + +#if (MACHINE != ATARI) +#define ABS -999 /* this process means absolute memory */ +#endif + +#define WORD_SIZE 2 /* number of bytes per word */ + +#define NIL_PTR (char *) 0 /* generally useful expression */ + +#define NO_NUM 0x8000 /* used as numerical argument to panic() */ +#define SIG_PUSH_BYTES (4*sizeof(int)) /* how many bytes pushed by signal */ + +/* Flag bits for i_mode in the inode. */ +#define I_TYPE 0170000 /* this field gives inode type */ +#define I_REGULAR 0100000 /* regular file, not dir or special */ +#define I_BLOCK_SPECIAL 0060000 /* block special file */ +#define I_DIRECTORY 0040000 /* file is a directory */ +#define I_CHAR_SPECIAL 0020000 /* character special file */ +#define I_NAMED_PIPE 0010000 /* named pipe (FIFO) */ +#define I_SET_UID_BIT 0004000 /* set effective uid_t on exec */ +#define I_SET_GID_BIT 0002000 /* set effective gid_t on exec */ +#define ALL_MODES 0006777 /* all bits for user, group and others */ +#define RWX_MODES 0000777 /* mode bits for RWX only */ +#define R_BIT 0000004 /* Rwx protection bit */ +#define W_BIT 0000002 /* rWx protection bit */ +#define X_BIT 0000001 /* rwX protection bit */ +#define I_NOT_ALLOC 0000000 /* this inode is free */ diff --git a/lib/minixST/include/minix/error.h b/lib/minixST/include/minix/error.h new file mode 100644 index 00000000..302207f2 --- /dev/null +++ b/lib/minixST/include/minix/error.h @@ -0,0 +1,59 @@ +/* Error codes. They are negative since a few system calls, such as READ, can + * either return a positive number indicating success, or an error code. + */ + +#define NERROR 34 +#define OK 0 +#define ERROR -1 +#define EPERM -1 +#define ENOENT -2 +#define ESRCH -3 +#define EINTR -4 +#define EIO -5 +#define ENXIO -6 +#define E2BIG -7 +#define ENOEXEC -8 +#define EBADF -9 +#define ECHILD -10 +#define EAGAIN -11 +#define ENOMEM -12 +#define EACCES -13 +#define EFAULT -14 +#define ENOTBLK -15 +#define EBUSY -16 +#define EEXIST -17 +#define EXDEV -18 +#define ENODEV -19 +#define ENOTDIR -20 +#define EISDIR -21 +#define EINVAL -22 +#define ENFILE -23 +#define EMFILE -24 +#define ENOTTY -25 +#define ETXTBSY -26 +#define EFBIG -27 +#define ENOSPC -28 +#define ESPIPE -29 +#define EROFS -30 +#define EMLINK -31 +#define EPIPE -32 +#define EDOM -33 +#define ERANGE -34 + +#define E_LOCKED -101 +#define E_BAD_CALL -102 +#define E_LONG_STRING -103 +#define EOF -104 /* End Of File - used by drivers */ + +/* The following error codes are generated by the kernel itself. */ +#define E_BAD_DEST -1 /* destination address illegal */ +#define E_BAD_SRC -2 /* source address illegal */ +#define E_TRY_AGAIN -3 /* can't send-- tables full */ +#define E_OVERRUN -4 /* interrupt for task that is not waiting */ +#define E_BAD_BUF -5 /* message buf outside caller's addr space */ +#define E_TASK -6 /* can't send to task */ +#define E_NO_MESSAGE -7 /* RECEIVE failed: no message present */ +#define E_NO_PERM -8 /* ordinary users can't send to tasks */ +#define E_BAD_FCN -9 /* only valid fcns are SEND, RECEIVE, BOTH */ +#define E_BAD_ADDR -10 /* bad address given to utility routine */ +#define E_BAD_PROC -11 /* bad proc number given to utility */ diff --git a/lib/minixST/include/minix/stat.h b/lib/minixST/include/minix/stat.h new file mode 100644 index 00000000..4c8b018f --- /dev/null +++ b/lib/minixST/include/minix/stat.h @@ -0,0 +1,26 @@ +struct stat { + short int st_dev; + unsigned short st_ino; + unsigned short st_mode; + short int st_nlink; + short int st_uid; + short int st_gid; + short int st_rdev; + long st_size; + long st_atime; + long st_mtime; + long st_ctime; +}; + +/* Some common definitions. */ +#define S_IFMT 0170000 /* type of file */ +#define S_IFDIR 0040000 /* directory */ +#define S_IFCHR 0020000 /* character special */ +#define S_IFBLK 0060000 /* block special */ +#define S_IFREG 0100000 /* regular */ +#define S_ISUID 04000 /* set user id on execution */ +#define S_ISGID 02000 /* set group id on execution */ +#define S_ISVTX 01000 /* save swapped text even after use */ +#define S_IREAD 00400 /* read permission, owner */ +#define S_IWRITE 00200 /* write permission, owner */ +#define S_IEXEC 00100 /* execute/search permission, owner */ diff --git a/lib/minixST/include/minix/type.h b/lib/minixST/include/minix/type.h new file mode 100644 index 00000000..0669ceca --- /dev/null +++ b/lib/minixST/include/minix/type.h @@ -0,0 +1,134 @@ +#ifndef _TYPE_H +#define _TYPE_H +/* Macros */ +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#define MIN(a,b) ((a) < (b) ? (a) : (b)) + +/* Type definitions */ +typedef unsigned short unshort; /* must be 16-bit unsigned */ +typedef unshort block_nr; /* block number */ +typedef unshort zone_nr; /* zone number */ + +#define MAX_BLOCK_NR ((block_nr) 0177777) /* largest block number */ +#define HIGHEST_ZONE ((zone_nr) 0177777) /* largest zone number */ +#define MAX_INODE_NR ((ino_t 0177777) /* largest inode number */ +#define MAX_FILE_POS 017777777777L /* largest legal file offset */ + +#define NO_BLOCK ((block_nr) 0) /* absence of a block number */ +#define NO_ENTRY ((ino_t) 0) /* absence of a dir entry */ +#define NO_ZONE ((zone_nr) 0) /* absence of a zone number */ +#define NO_DEV ((dev_t) ~0) /* absence of a device numb */ + +typedef unshort bit_nr; /* if ino_t & zone_nr both unshort, + then also unshort, else long */ +typedef long zone_type; /* zone size */ + +#if (CHIP == INTEL) +typedef unsigned vir_bytes; /* virtual addresses and lengths in bytes */ +#endif + +#if (CHIP == M68000) +typedef long vir_bytes; /* virtual addresses and lengths in bytes */ +#endif + +typedef unsigned vir_clicks; /* virtual addresses and lengths in clicks */ +typedef long phys_bytes; /* physical addresses and lengths in bytes */ +typedef unsigned phys_clicks; /* physical addresses and lengths in clicks */ +typedef int signed_clicks; /* same length as phys_clicks, but signed */ + +/* Types relating to messages. */ +#define M1 1 +#define M3 3 +#define M4 4 +#define M3_STRING 14 + +typedef struct {int m1i1, m1i2, m1i3; char *m1p1, *m1p2, *m1p3;} mess_1; +typedef struct {int m2i1, m2i2, m2i3; long m2l1, m2l2; char *m2p1;} mess_2; +typedef struct {int m3i1, m3i2; char *m3p1; char m3ca1[M3_STRING];} mess_3; +typedef struct {long m4l1, m4l2, m4l3, m4l4;} mess_4; +typedef struct {char m5c1, m5c2; int m5i1, m5i2; long m5l1, m5l2, m5l3;} mess_5; +#if _ANSI +typedef struct {int m6i1, m6i2, m6i3; long m6l1; void (*m6f1)(int);} mess_6; +#else +typedef struct {int m6i1, m6i2, m6i3; long m6l1; void (*m6f1)();} mess_6; +#endif + +typedef struct { + int m_source; /* who sent the message */ + int m_type; /* what kind of message is it */ + union { + mess_1 m_m1; + mess_2 m_m2; + mess_3 m_m3; + mess_4 m_m4; + mess_5 m_m5; + mess_6 m_m6; + } m_u; +} message; + +#define MESS_SIZE (sizeof(message)) +#define NIL_MESS (message *) 0 + +/* The following defines provide names for useful members. */ +#define m1_i1 m_u.m_m1.m1i1 +#define m1_i2 m_u.m_m1.m1i2 +#define m1_i3 m_u.m_m1.m1i3 +#define m1_p1 m_u.m_m1.m1p1 +#define m1_p2 m_u.m_m1.m1p2 +#define m1_p3 m_u.m_m1.m1p3 + +#define m2_i1 m_u.m_m2.m2i1 +#define m2_i2 m_u.m_m2.m2i2 +#define m2_i3 m_u.m_m2.m2i3 +#define m2_l1 m_u.m_m2.m2l1 +#define m2_l2 m_u.m_m2.m2l2 +#define m2_p1 m_u.m_m2.m2p1 + +#define m3_i1 m_u.m_m3.m3i1 +#define m3_i2 m_u.m_m3.m3i2 +#define m3_p1 m_u.m_m3.m3p1 +#define m3_ca1 m_u.m_m3.m3ca1 + + +#define m4_l1 m_u.m_m4.m4l1 +#define m4_l2 m_u.m_m4.m4l2 +#define m4_l3 m_u.m_m4.m4l3 +#define m4_l4 m_u.m_m4.m4l4 + +#define m5_c1 m_u.m_m5.m5c1 +#define m5_c2 m_u.m_m5.m5c2 +#define m5_i1 m_u.m_m5.m5i1 +#define m5_i2 m_u.m_m5.m5i2 +#define m5_l1 m_u.m_m5.m5l1 +#define m5_l2 m_u.m_m5.m5l2 +#define m5_l3 m_u.m_m5.m5l3 + +#define m6_i1 m_u.m_m6.m6i1 +#define m6_i2 m_u.m_m6.m6i2 +#define m6_i3 m_u.m_m6.m6i3 +#define m6_l1 m_u.m_m6.m6l1 +#define m6_f1 m_u.m_m6.m6f1 + +struct mem_map { + vir_clicks mem_vir; /* virtual address */ + phys_clicks mem_phys; /* physical address */ + vir_clicks mem_len; /* length */ +}; + +struct copy_info { /* used by sys_copy(src, dst, bytes) */ + int cp_src_proc; + int cp_src_space; + vir_bytes cp_src_vir; + int cp_dst_proc; + int cp_dst_space; + vir_bytes cp_dst_vir; + vir_bytes cp_bytes; +}; + +struct iorequest_s { + long io_position; /* position in device file (really off_t) */ + char *io_buf; /* buffer in user space */ + unsigned short io_nbytes; /* size of request */ + unsigned short io_request; /* read, write (optionally) */ +}; +#endif /* _TYPE_H */ diff --git a/lib/vax4/descr.src b/lib/vax4/descr.src new file mode 100644 index 00000000..57673217 --- /dev/null +++ b/lib/vax4/descr.src @@ -0,0 +1,74 @@ +# $Revision$ +var w=4 +var p=4 +var s=2 +var l=4 +var f=4 +var d=8 +var NAME=vax4 +var M=vax4 +var LIB=lib/{M}/tail_ +var RT=lib/{M}/head_ +var CPP_F=-Dunix -Dvax +var CC_ALIGN=-Vw4.1 +# 413 align is the default, rom in text +var ALIGN=-a0:4 -a1:4 -a2:0x400 -a3:4 +var C_LIB={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g +var OLD_C_LIB={C_LIB} +name be + from .m.g + to .s + program {EM}/lib/{M}/cg + args < + stdout + need .e +end +name asopt + from .s + to .so + program {EM}/lib/{M}/top + args + optimizer + stdin + stdout +end +name as + from .s.so + to .o + program {EM}/lib/{M}/as + args - -o > < + prep cond +end +name led + from .o.a + to .out + program {EM}/lib/em_led + mapflag -l* LNAME={EM}/{LIB}* + mapflag -N ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 + mapflag -r ALIGN=-a0:4 -a1:0x400 -a2:4 -a3:4 + mapflag -ansi C_LIB={EM}/{LIB}ac + args {ALIGN} (.e:{HEAD}= {EM}/{RT}em) \ + ({RTS}:.ocm.b={EM}/{RT}cc) \ + ({RTS}{ANSI?}:.c={EM}/{RT}cc) \ + ({RTS}{ANSI?}:.cansi={EM}/{RT}ac) \ + ({RTS}:.mod={EM}/{RT}m2) \ + ({RTS}:.p.8={EM}/{RT}pc) \ + -o > < \ + (.8:{TAIL}={EM}/{LIB}a68s) \ + (.p.8:{TAIL}={EM}/{LIB}pc) \ + (.b:{TAIL}={EM}/{LIB}bc) \ + (.ocm:{TAIL}={EM}/{LIB}ocm) \ + (.mod:{TAIL}={EM}/{LIB}m2) \ + (.ocm.b:{TAIL}={OLD_C_LIB}) \ + (.c:{TAIL}={C_LIB}) \ + (.e:{TAIL}={EM}/{LIB}em {EM}/{LIB}mon {EM}/lib/{M}/end_em) + linker +end +name cv + from .out + to .cv + program {EM}/lib/{M}/cv + mapflag -n CV_ARG=-n + args {CV_ARG?} < > + outfile a.out +end diff --git a/lib/vax4/sedf b/lib/vax4/sedf new file mode 100644 index 00000000..b26db01c --- /dev/null +++ b/lib/vax4/sedf @@ -0,0 +1,104 @@ +# $Header$ +/movab/ { +s/movab 1(\(.*\)),\1$/incl \1/ +s/movab -1(\(.*\)),\1$/decl \1/ +s/movab \([0-9]*\)(\(.*\)),\2$/addl2 $\1,\2/ +s/movab -\([0-9]*\)(\(.*\)),\2$/subl2 $\1,\2/ +s/movab 0(\(.*\)) \[\(.*\)\],\1$/addl2 \2,\1/ +s/movab 0(\(.*\)) \[\(.*\)\],\2$/addl2 \1,\2/ +} +/$0/ { +s/movz[bw]\([wl]\) $0,/clr\1 / +s/mov\([bwl]\) $0,/clr\1 / +s/cvt[bw]\([wl]\) $0,/clr\1 / +} +/add/ { +s/\(add[fdlw]\)3 \(.*\),\(.*\),\3$/\12 \2,\3/ +s/\(add[fdlw]\)3 \(.*\),\(.*\),\2$/\12 \3,\2/ +s/add\([wl]\)2 \$-\([0-9]*\),/sub\12 $\2,/ +s/add\([wl]\)3 \$-\([0-9]*\),/sub\13 $\2,/ +s/add\([wl]\)3 \(.*\),\$-\([0-9]*\),/sub\13 $\3,\2,/ +} +/mul/ { +s/\(mul[fdlw]\)3 \(.*\),\(.*\),\3$/\12 \2,\3/ +s/\(mul[fdlw]\)3 \(.*\),\(.*\),\2$/\12 \3,\2/ +} +/sub/ { +s/\(sub[fdlw]\)3 \(.*\),\(.*\),\3$/\12 \2,\3/ +s/sub\([wl]\)2 \$-\([0-9]*\),/add\12 $\2,/ +s/sub\([wl]\)3 \$-\([0-9]*\),/add\13 $\2,/ +} +/div/s/\(div[fdlw]\)3 \(.*\),\(.*\),\3$/\12 \2,\3/ +/bi/s/\(bi[cs][lw]\)3 \(.*\),\(.*\),\3$/\12 \2,\3/ +/bis/s/\(bis[lw]\)3 \(.*\),\(.*\),\2$/\12 \3,\2/ +/xor/ { +s/\(xor[lw]\)3 \(.*\),\(.*\),\3$/\12 \2,\3/ +s/\(xor[lw]\)3 \(.*\),\(.*\),\2$/\12 \3,\2/ +} +/$1/ { +s/add\([wl]\)2 \$1,/inc\1 / +s/sub\([wl]\)2 \$1,/dec\1 / +} +/$-1/ { +s/add\([wl]\)2 \$-1,/dec\1 / +s/sub\([wl]\)2 \$-1,/inc\1 / +} +/cmp[bwl].*$0/ { +N +s/cmp\([bwl]\) \(.*\),$0$/tst\1 \2/ +s/cmp\([bwl]\) $0,\(.*\)\njneq/tst\1 \2\ +jneq/ +s/cmp\([bwl]\) $0,\(.*\)\njeql/tst\1 \2\ +jeql/ +s/cmp\([bwl]\) $0,\(.*\)\njgtr/tst\1 \2\ +jlss/ +s/cmp\([bwl]\) $0,\(.*\)\njlss/tst\1 \2\ +jgtr/ +s/cmp\([bwl]\) $0,\(.*\)\njgeq/tst\1 \2\ +jleq/ +s/cmp\([bwl]\) $0,\(.*\)\njleq/tst\1 \2\ +jgeq/ +P +D +} +/(sp)+/ { +N +s/movl (sp)+,\(.*\)\npushl \1$/movl (sp),\1/ +s/tst[wl] (sp)+\nmovl fp,sp$/movl fp,sp/ +s/tst\([wl]\) (sp)+\nmov\1 \(.*\),-(sp)/mov\1 \2,(sp)/ +s/tst\([wl]\) (sp)+\nclr\1 -(sp)/clr\1 (sp)/ +s/tst\([wl]\) (sp)+\nmovzb\1 \(.*\),-(sp)/movzb\1 \2,(sp)/ +s/tst\([wl]\) (sp)+\ncvtb\1 \(.*\),-(sp)/cvtb\1 \2,(sp)/ +s/tst\([wl]\) (sp)+\ntst\1 \(.*\)$/mov\1 \2,(sp)+/ +s/tstl (sp)+\npushl \(.*\)$/movl \1,(sp)/ +s/tstl (sp)+\npusha\([bwlq]\) \(.*\)$/mova\1 \2,(sp)/ +P +D +} +/^addl2 .*,sp/ { +N +s/addl2 .*,sp\nmovl fp,sp$/movl fp,sp/ +s/^addl2 $6,sp\nmovw \(.*\),-(sp)/tstl (sp)+\ +movw \1,(sp)/ +s/^addl2 $6,sp\nclrw -(sp)/tstl (sp)+\ +clrw (sp)/ +s/^addl2 $8,sp\nmovq \(.*\),-(sp)/movq \1,(sp)/ +P +D +} +/clrw -(sp)/ { +N +s/clrw -(sp)\nmovw \($[0-9]*\),-(sp)/pushl \1/ +s/clrw -(sp)\nmnegw $\([0-9]*\),-(sp)/movzwl $-\1,-(sp)/ +s/clrw -(sp)\nmovw \(.*\),-(sp)/movzwl \1,-(sp)/ +s/clrw -(sp)\ncvtbw \(\$[0-9]*\),-(sp)/pushl \1/ +s/clrw -(sp)\ncvtbw \(\$.*\),-(sp)/movzwl \1,-(sp)/ +P +D +} +/mov/ { +N +s/mov\([wl]\) \(.*\),\(.*\)\ntst\1 \3$/mov\1 \2,\3/ +P +D +} diff --git a/mach/6500/as/Makefile b/mach/6500/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/6500/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/6500/cg/Makefile b/mach/6500/cg/Makefile new file mode 100644 index 00000000..22f5f603 --- /dev/null +++ b/mach/6500/cg/Makefile @@ -0,0 +1,184 @@ +# $Header$ + +EMHOME=../../.. +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-hbxac +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/cg +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/main.c $(CDIR)/move.c \ + $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c $(CDIR)/salloc.c \ + $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o main.o\ + move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + ../../install cg + +cmp: all + -../../compare cg + +distr: tables.c + rm -f tables1.[ch] + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + + +tables.c: table + -mv tables.h tables.h.save + $(EMHOME)/lib/cpp -P table | $(EMHOME)/lib/cgg > debug.out + -if cmp -s tables.h.save tables.h; then mv tables.h.save tables.h; else exit 0; fi + -if cmp -s /dev/null tables.h; then mv tables.h.save tables.h; else exit 0; fi + +lint: $(CFILES) + lint $(LINTOPTS) $(PREFLAGS) $(CFILES) +clean: + rm -f *.o tables.c tables.h debug.out cg tables.h.save + +codegen.o: $(CDIR)/assert.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +move.o: $(CDIR)/assert.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/6500/dl/Makefile b/mach/6500/dl/Makefile new file mode 100644 index 00000000..d1b1ba84 --- /dev/null +++ b/mach/6500/dl/Makefile @@ -0,0 +1,20 @@ +EMHOME=../../.. +CFLAGS=-O -I$(EMHOME)/h + +dl: dl.o + $(CC) -o dl dl.o $(EMHOME)/modules/lib/libobject.a + +install: dl + ../../install dl + +cmp: dl + -../../compare dl + +opr: + make pr | opr + +pr: + @pr `pwd`/dl.c + +clean: + -rm -f *.o *.old dl diff --git a/mach/6500/libem/Makefile b/mach/6500/libem/Makefile new file mode 100644 index 00000000..42daff56 --- /dev/null +++ b/mach/6500/libem/Makefile @@ -0,0 +1,21 @@ +all: + +install: + ../../install head_em.s head_em + ../../install libem_s.a tail_em + ../../install end.s end_em + +cmp: + -../../compare head_em.s head_em + -../../compare libem_s.a tail_em + -../../compare end.s end_em + +opr: + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libem_s.a | pr -h `pwd`/libem_s.a + @pr `pwd`/end.s + +clean: diff --git a/mach/6500/libem/end.s b/mach/6500/libem/end.s new file mode 100644 index 00000000..1bb218eb --- /dev/null +++ b/mach/6500/libem/end.s @@ -0,0 +1,17 @@ +.define endtext, enddata, endbss, end +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +.sect .text +endtext: +.align 2 +.sect .data +.align 2 +enddata: +.sect .bss +.align 2 +endbss: +end: diff --git a/mach/6500/libem/head_em.s b/mach/6500/libem/head_em.s new file mode 100644 index 00000000..5e4a1c26 --- /dev/null +++ b/mach/6500/libem/head_em.s @@ -0,0 +1,233 @@ +.define WRCH, RDCH, Earray, Erange, Eset +.define Eiovfl, Eidivz, Eiund, Econv +.define Estack, Eheap, Eillins, Eoddz +.define Ecase , Ebadmon, OSBYTE, MON +.define Ebadlin, Ebadgto, BASE, NBYTES +.define hol0, IGNMASK, ADDR, PROGNAME +.define LB, LBl, SP, HP, ERRPROC, UNSIGN +.define Ytmp, EXG, ARTH, RETURN, SIGN +.define RETSIZE, TRAPVAL, STACK, BRANCH +.define start, Push, Pop, STACKTh, STACKTl +.define F_DUM +.sect .zero +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +! DEFINITIONS + + ! The next three definitions are special for the + ! BBC microcomputer + +WRCH = 0x0FFEE ! This subroutine writes the character in + ! register A to the screen +RDCH = 0x0FFE0 ! This subroutine returns a character in + ! register A from the current input stream +OSBYTE = 0x0FFF4 ! This subroutine performs miscelaneous + ! operating system calls + +F_DUM = 0 ! Dummy floating point constant + + ! Here are the error numbers + +Earray = 0 +Erange = 1 +Eset = 2 +Eiovfl = 3 +Eidivz = 6 +Eiund = 8 +Econv = 10 +Estack = 16 +Eheap = 17 +Eillins = 18 +Eoddz = 19 +Ecase = 20 +Ebadmon = 25 +Ebadlin = 26 +Ebadgto = 27 +MON = 0x78D0 + +BASE = 240 ! This is the offset from the localbase + ! for the second localbase + +STACKTh = 0x78 ! This is the top of the stack +STACKTl = 0x0D0 + + ! Some zeropage declarations + +.sect .zero + +RES: .space 76 ! special for the operating system + +hol0: .space 16 ! the hol0 block + +IGNMASK: .space 2 ! can hold the ingnore mask + +ADDR: .space 4 ! used for indirect addressing + +LB: .space 2 ! the localbase + +LBl: .space 2 ! the second localbase (localbase-BASE) + +SP: .space 3 ! the stackpointer (real_stack) + +HP: .space 2 ! the heap pointer + +BRANCH: .space 2 ! used for branch instructions + +ERRPROC: .space 2 ! can hold the address of the error handler + +Ytmp: .space 1 ! used for intermediate storage in Y + +EXG: .space 2 ! used by the exchange subroutine Exg + +ARTH: .space 16 ! used for arithmetic + +NBYTES: .space 2 ! containes the number of bytes for a block move + + +RETURN: .space 4 ! the return area + +RETSIZE: .space 1 ! the size of the object returned + +SIGN: .space 1 ! the sign of the calculation + +UNSIGN : .space 1 ! is it signed or unsigned arithmetic + +TRAPVAL: .space 1 ! intermediate storage of the error number + +STACK: .space 1 ! contains the hardware stackpointer on + ! entering _m_a_i_n for a neat return + +RESERVED: .space 112 ! used by the operating system + +.sect .text +.base 0x0E02 ! where to start in the BBC micro +! GENERAL PURPOSE ROUTINES + +start: + tsx + stx STACK ! save stackpointer for exit and error + + ! The following three operating system calls are only + ! for the BBC microcomputer + + lda #2 + ldx #0 + ldy #0 + jsr OSBYTE ! return control to the keyboard + lda #15 + ldx #0 + ldy #0 + jsr OSBYTE ! clear all internal buffers + lda #3 + ldx #5 + ldy #0 + jsr OSBYTE ! output to screen and RS423 + + lda #STACKTl + sta LB ! set localbase (lowbyte) + sta SP+2 + lda #0 + sta SP ! set stackpointer (lowbyte) + sta ERRPROC ! set start address for error handler (lowbyte) + sta ERRPROC+1 ! set start address for error handler (highbyte) + sta hol0 ! set the line number (lowbyte) + sta hol0+1 ! set the line number (highbyte) + lda #STACKTh + sta SP+1 ! set the stacpointer (highbyte) + sta LB+1 ! set the localbase (highbyte) + lda #[endbss].l + sta HP ! set the heap pointer (lowbyte) + lda #[endbss].h + sta HP+1 ! set the heap pointer (highbyte) + lda #[PROGNAME].l + sta hol0+4 ! set fake programname pointer (lowbyte) + lda #[PROGNAME].h + sta hol0+5 ! set fake programname pointer (highbyte) + lda #[beginbss].l + sta ADDR ! start address of bss block (lowbyte) + lda #[beginbss].h + sta ADDR+1 ! start address of bss block (highbyte) + ldy #0 + lda #0 + 4: ldx #[endbss].h ! clear bss block + cpx ADDR+1 + bcc 1f ! end of bss block reached + bne 2f + ldx #[endbss].l + cpx ADDR + bcc 1f ! end of bss block reached + 2: sta (ADDR),y + inc ADDR + bne 3f + inc ADDR+1 + 3: jmp 4b + 1: lda #0 + tax + jsr Push ! push fake envelope pointer + lda #[PROGNAME].h + ldx #[PROGNAME].l + jsr Push ! push argv[0] + lda #0 + ldx #1 + jsr Push ! push argc + jsr __m_a_i_n ! start the real program + + lda #0x0FF + jsr WRCH ! send end of program to R423 + lda #3 + ldx #0 + jsr OSBYTE ! send output to screen only + lda #2 + ldx #1 + jsr OSBYTE ! input only from R423 + rts + + +! The subroutine Push pushes the registerpair AX onto the stack. + +Push: + sty Ytmp ! save Y + ldy SP+2 + bne 1f ! lowbyte of stackpointer <> 0 + dec SP+1 ! decrement highbyte of stackpointer + 1: dey + dey ! decrement lowbyte of stackpointer + sty SP+2 ! save lowbyte of stackpointer + pha ! save A + txa + sta (SP),y ! push X onto the stack + iny + pla ! get A + sta (SP),y ! push A onto the stack + ldy Ytmp ! restore Y + rts + + +! The subroutine Pop pops the registerpair AX from the stack. + +Pop: + sty Ytmp ! save Y + ldy SP+2 + lda (SP),y ! pop X from the stack + tax + iny + lda (SP),y ! pop A from the stack + iny + bne 1f ! lowbyte of stackpointer <> 0 + inc SP+1 ! increment highbyte of stackpointer + 1: sty SP+2 ! store lowbyte of stackpointer + pha ! save A + pla ! get A + ldy Ytmp ! restore Y + rts + + +.sect .data +PROGNAME: ! for initialising the programname pointer +.asciz "program" +.sect .bss +beginbss: diff --git a/mach/6500/libem/mon.s b/mach/6500/libem/mon.s new file mode 100644 index 00000000..1d094c51 --- /dev/null +++ b/mach/6500/libem/mon.s @@ -0,0 +1,40 @@ +.define Mon +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +! This subroutine performs some monitor calls. +! The exit call just resets the hardware_stackpointer so +! this routine will return to the operating system. +! The close call just returns a zero. +! The ioctl call just pops its arguments and returns a zero. +! The write routine is a real one. + + +Mon: + cpx #1 + bne 1f ! exit + ldx STACK ! load stackpointer + dex + dex ! adjust stackpointer + txs ! set stackpointer + rts + 1: cpx #4 + bne 1f + jmp Mwrite + 1: cpx #6 ! facked + bne 1f ! close + lda #0 + tax ! return zero + rts + 1: cpx #54 + jsr Pop ! pop first argument (fildes) + jsr Pop ! pop second argument (request) + jsr Pop ! pop third argument (argp) + lda #0 + tax ! return zero + rts + + diff --git a/mach/6500/libem/print.s b/mach/6500/libem/print.s new file mode 100644 index 00000000..eea8e73d --- /dev/null +++ b/mach/6500/libem/print.s @@ -0,0 +1,27 @@ +.define Mprint +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +! This subroutine prints a zero terminated ascii string. +! The registerpair AX contains the start of the string. +! The subroutine WRCH is a special routine on the BBC microcomputer +! which prints the character in A to the screen. +! The subroutine WRCH is a special one provided by the BBC +! microcomputer. + + +Mprint: + stx ADDR ! start address of string (lowbyte) + sta ADDR+1 ! start address of string (highbyte) + ldy #0 + 1: lda (ADDR),y ! get ascii character + beq 2f + jsr WRCH ! put it on the screen + iny + bne 1b + 2: rts + + diff --git a/mach/6500/libem/printhex.s b/mach/6500/libem/printhex.s new file mode 100644 index 00000000..e1d3e4b3 --- /dev/null +++ b/mach/6500/libem/printhex.s @@ -0,0 +1,32 @@ +.define Printhex +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +! This subroutine print the contents of register A to the screen +! in hexadecimal form. +! The subroutine WRCH is a special one provided by the BBC +! microcomputer. + + +Printhex: + pha ! save A + lsr a + lsr a + lsr a + lsr a ! get four high bits + jsr 1f + pla ! restore A + and #0x0F ! get four low bits + jsr 1f + rts + 1: sed ! print in hex + clc + adc #0x90 + adc #0x40 + cld + jmp WRCH + + diff --git a/mach/6500/libem/printstack.s b/mach/6500/libem/printstack.s new file mode 100644 index 00000000..27f1512a --- /dev/null +++ b/mach/6500/libem/printstack.s @@ -0,0 +1,49 @@ +.define Printstack +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +! This a special subroutine which prints some things to the +! monitorscreen for debugging. + + +Printstack: + ldy #0 + 2: lda (hol0+4),y + beq 1f + jsr WRCH ! print filename + iny + jmp 2b + 1: lda #32 + jsr WRCH ! print a space + lda hol0+1 + jsr Printhex ! print line number (highbyte) + lda hol0 + jsr Printhex ! print line number (lowbyte) + lda #32 + jsr WRCH ! print a space + lda SP+1 + jsr Printhex ! print stackpointer (highbyte) + lda SP+2 + jsr Printhex ! print stackpointer (lowbyte) + lda #32 + jsr WRCH ! print a space + lda LB+1 + jsr Printhex ! print real localbase (highbyte) + lda LB + jsr Printhex ! print real localbase (lowbyte) + lda #32 + jsr WRCH ! print a space + lda LBl+1 + jsr Printhex ! print second lowerbase (highbyte) + lda LBl + jsr Printhex ! print second lowerbase (lowbyte) + lda #10 + jsr WRCH ! print a newline + lda #13 + jsr WRCH ! print a carriagereturn + rts + + diff --git a/mach/6500/libem/read.s b/mach/6500/libem/read.s new file mode 100644 index 00000000..12d2c58b --- /dev/null +++ b/mach/6500/libem/read.s @@ -0,0 +1,37 @@ +.define Mread +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +! This subroutine reads characters from the standard input. +! It ignores the filedes. +! It reads atmost 255 characters. So the runtime system must +! provide a way of dealing with this. +! The subroutine RDCH is a special one provided by the BBC +! microcomputer. + + +Mread: + jsr Pop ! ignore filedescriptor + jsr Pop ! bufptr + stx ADDR ! address of character buffer (lowbyte) + sta ADDR+1 ! address of character buffer (highbyte) + jsr Pop ! number of characters + ldy #0 ! <= 255 + inx + 1: jsr RDCH ! read a character from the current inputstream + bcs 8f + sta (ADDR),y + iny + dex + bne 1b + 8: tya + tax + lda #0 + jsr Push ! number of characters red. + tax ! report a succesfull read. + rts + + diff --git a/mach/6500/libem/write.s b/mach/6500/libem/write.s new file mode 100644 index 00000000..7b87cf44 --- /dev/null +++ b/mach/6500/libem/write.s @@ -0,0 +1,39 @@ +.define Mwrite +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +! This subroutine performs the monitor call write. +! Writing is always done to standardoutput. +! A zero is returned on exit. +! The subroutine WRCH is a special routine of the BBC +! microcomputer. + + +Mwrite: + jsr Pop ! get fildes + jsr Pop ! get address of characterbuffer + stx ADDR ! bufferaddress (lowbyte) + sta ADDR+1 ! bufferaddress (highbyte) + jsr Pop ! number of characters to be writen. + ldy #0 + 1: lda (ADDR),y + cmp #10 + bne 2f + pha + lda #13 + jsr WRCH + pla + 2: jsr WRCH + iny + dex + bne 1b + tya + tax + lda #0 + jsr Push + tax + rts + diff --git a/mach/6800/as/Makefile b/mach/6800/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/6800/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/6805/as/Makefile b/mach/6805/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/6805/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/6809/as/Makefile b/mach/6809/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/6809/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/arm/as/Makefile b/mach/arm/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/arm/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/arm/cv/Makefile b/mach/arm/cv/Makefile new file mode 100644 index 00000000..40fd8362 --- /dev/null +++ b/mach/arm/cv/Makefile @@ -0,0 +1,22 @@ +EMHOME=../../.. +OBJLIB=$(EMHOME)/modules/lib/libobject.a + +head: cv + +cv: cv.c + $(CC) $(CFLAGS) $(LDFLAGS) -I$(EMHOME)/h -o cv cv.c $(OBJLIB) + +install: head + ../../install cv + +cmp: head + ../../compare cv + +clean: + rm -f *.o + +pr: + @pr `pwd`/Makefile `pwd`/cv.c + +opr: + make pr | opr diff --git a/mach/arm/libem/Makefile b/mach/arm/libem/Makefile new file mode 100644 index 00000000..b2c179d9 --- /dev/null +++ b/mach/arm/libem/Makefile @@ -0,0 +1,21 @@ +all: + +install: + ../../install head_em.s head_em + ../../install libem_s.a tail_em + ../../install end.s end_em + +cmp: + -../../compare head_em.s head_em + -../../compare libem_s.a tail_em + -../../compare end.s end_em + +clean: + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libem_s.a | pr -h `pwd`/libem_s.a + @pr `pwd`/end.s diff --git a/mach/arm/libem/end.s b/mach/arm/libem/end.s new file mode 100644 index 00000000..e31db94e --- /dev/null +++ b/mach/arm/libem/end.s @@ -0,0 +1,16 @@ +.define _endtext,_enddata,_endbss +.sect .text + .align 4 +.sect .rom + .align 4 +.sect .data + .align 4 +.sect .bss + .align 4 + + .sect .text +_endtext: + .sect .data +_enddata: + .sect .bss +_endbss: diff --git a/mach/arm/libem/head_em.s b/mach/arm/libem/head_em.s new file mode 100644 index 00000000..26040b60 --- /dev/null +++ b/mach/arm/libem/head_em.s @@ -0,0 +1,178 @@ +! head_em.s +.define begdat,begbss,hol0,argv,envp,_RegHp,_incptflag +.define _Lineno,_Filna,_IgnoreMask,_TrpReg + +.sect .text +.sect .rom +.sect .data +.sect .bss + +.sect .text +.base 0x8000 + ADR R0,begbss + ADR R1,_endbss + MOV R2,#0 + ADR R3,_incptflag + STR R2,[R3] +1: + STR R2,[R0],#4 + CMP R0,R1 + BLT 1B +! the next 2 lines are OS specific: + SWI 16 ! OS_Getenv + SUB R12, R1, #8 ! Get end of ram +! R0 points to command string +! (argv,argc) code for C +! or Pascal file names + MOV R9,R0 ! save pt in R0 + MOV R8,#0 ! string length +len: + LDR.B R7,[R9],#1 + CMP R7,#0 + ADD.NE R8,R8,#1 + BNE len + MOV R7,R8 ! save len in R7 +! round up to multiple of 4 + ADD R8,R8,#4 + MVN R6, #3 !FFFFFFFC + AND R8,R8,R6 +! make room on stack + SUB R12,R12,R8 ! word aligned +! now determine argc +! OS intercepts blank lines, so +! there must be at least one arg + MOV R9,R0 + MOV R6,#0 ! holds argc + MOV R5,#0 ! char count +loop1: + CMP R5,R7 + BGT next1 + LDR.B R4,[R9],#1 + ADD R5,R5,#1 + CMP R4,#32 + BEQ loop1 !skip spaces + ADD R6,R6,#1 ! new arg +nospace1: + CMP R5,R7 + BGT next1 + LDR.B R4,[R9],#1 + ADD R5,R5,#1 + CMP R4,#32 + BNE nospace1 + CMP R5,R7 + BCC loop1 +! BEQ loop1 +next1: +! store argc + ADR R5,argc + STR R6,[R5] +! copy the string +! onto the stack + MOV R9,R0 !source + MOV R2,R12 !dest + MOV R3,R7 !#chars +loop2: + LDR.B R4,[R9],#1 + STR.B R4,[R2],#1 + SUB.S R3,R3,#1 + BNE loop2 + MOV R4, #0 ! zero terminator + STR.B R4,[R2] +! create space on the stack for +! the pointers to individual args + MOV R11, R12 ! string pt + MOV R8,R6,LSL #2 + SUB R12,R12,R8 +! save pointer to argv[0] + ADR R1,argv + STR R12,[R1] +! determine argv[0] .. argv[argc-1] +! and store on stack +! R11 = start of string +! R7 = string lenth +! R12 = stack pointer +! R6 = argc + MOV R9, #0 !char count + MOV R8, #0 !arg count + MOV R5,R11 +loop3: + CMP R9,R7 + BGT next2 + LDR.B R4,[R5],#1 + ADD R9,R9,#1 + CMP R4,#32 + BEQ loop3 + CMP R9,R7 + BGT next2 + SUB R4,R5,#1 !compensate for incr + STR R4,[R12,R8,LSL #2] + ADD R8,R8,#1 +nospace2: + CMP R9,R7 + BGT next2 + LDR.B R4,[R5],#1 + ADD R9,R9,#1 + CMP R4,#32 + BNE nospace2 + CMP R9,R7 + BCC loop3 +! BEQ loop3 +! finally, replace spaces by 0 +next2: + MOV R5,R11 !string ptr + MOV R6,R7 !string length + MOV R3,#0 +loop4: + CMP R6,#0 + BEQ next3 + LDR.B R4,[R5] + CMP R4,#32 + STR.EQ.B R3,[R5] + ADD R5,R5,#1 + SUB R6,R6,#1 + BAL loop4 +next3: + ADR R11, envp + STMFD R12<,{R11} + ADR R11,argv + LDR R11,[R11] + STMFD R12<,{R11} + ADR R11, argc + LDR R11,[R11] + STMFD R12<,{R11} + BAL.L __m_a_i_n + MOV R11,#0 + STMFD R12<,{R11} + MOV R11,#1 + STMFD R12<,{R11} + BAL.L _EmMon + +.sect .bss +begbss: +.sect .data +begdat: +hol0: + .data4 0 + .data4 0 +argv: + .data4 0 +envp: + .data4 0 +argc: +.data4 0 +2: + .asciz 'PROGRAM' + .align +_RegHp: + .data4 _endbss +_Lineno: + .data4 0 +_Filna: + .data4 0 +_IgnoreMask: + .data4 0 +_TrpReg: + .data4 0 +_incptflag: +.data4 0 + diff --git a/mach/arm/libfp/Makefile b/mach/arm/libfp/Makefile new file mode 100644 index 00000000..eceeb76a --- /dev/null +++ b/mach/arm/libfp/Makefile @@ -0,0 +1,22 @@ +EMHOME=../../.. +SUF=so +MAKEFILE=$(EMHOME)/mach/proto/fp/Makefile +MACHDEF="MACH=arm" "CFLAGS=-DUSE_DIVIDE" "SUF=$(SUF)" "ASAR=arch" + +all: + make -f $(MAKEFILE) $(MACHDEF) all + +install: + make -f $(MAKEFILE) $(MACHDEF) install + +cmp: all + -../../compare FP_$(MACH).a tail_fp + +clean: + make -f $(MAKEFILE) $(MACHDEF) clean + +opr: + make pr | opr + +pr: + @pr Makefile diff --git a/mach/arm/libmon/Makefile b/mach/arm/libmon/Makefile new file mode 100644 index 00000000..1df00138 --- /dev/null +++ b/mach/arm/libmon/Makefile @@ -0,0 +1,15 @@ +all: + +install: + ../../install libros_s.a tail_ros + +cmp: + -../../compare libros_s.a tail_ros + +clean: + +opr : + make pr | opr + +pr: + @arch pv libros_s.a | pr -h `pwd`/libros_s.a diff --git a/mach/arm/ncg/Makefile b/mach/arm/ncg/Makefile new file mode 100644 index 00000000..f5e2bda6 --- /dev/null +++ b/mach/arm/ncg/Makefile @@ -0,0 +1,197 @@ +# $Header$ + +EMHOME=../../.. +#preprocessor flags for table +TABLEFLAGS= +#cgg options +CGGFLAGS= + +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/ncg +CGG=$(EMHOME)/lib/ncgg +CPP=$(EMHOME)/lib/cpp +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/label.c $(CDIR)/main.c \ + $(CDIR)/move.c $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c \ + $(CDIR)/salloc.c $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o label.o \ + main.o move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +label.o: $(CDIR)/label.c + $(CC) -c $(CFLAGS) $(CDIR)/label.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + $(EMHOME)/mach/install cg + +cmp: all + -$(EMHOME)/mach/compare cg + + +tables.c: table $(CGG) + $(CPP) $(TABLEFLAGS) table | $(CGG) $(CGGFLAGS) + -cmp tables.h tables.H || cp tables.H tables.h + +lint: $(CFILES) tables.c + lint $(LINTOPTS) $(PREFLAGS) -I$(CDIR) $(CFILES) tables.c +clean: + rm -f *.o tables.c tables.h debug.out cg tables.H + +distr: tables.c + rm -f tables1.c tables1.h + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + +codegen.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/label.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +label.o: $(CDIR)/label.h +label.o: $(CDIR)/param.h +label.o: tables.h +label.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +main.o: tables.h +move.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/arm/top/Makefile b/mach/arm/top/Makefile new file mode 100644 index 00000000..57908427 --- /dev/null +++ b/mach/arm/top/Makefile @@ -0,0 +1,42 @@ +EMHOME=../../.. +LIBS=$(EMHOME)/modules/lib/libstring.a +PREFLAGS=-I. +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O -DNDEBUG +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +CDIR=$(EMHOME)/mach/proto/top +CFILES=$(CDIR)/top.c $(CDIR)/queue.c +OFILES=top.o queue.o + +all: gen.c + make top + +top: $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) $(LIBS) -o top + +top.o: $(CDIR)/top.c gen.c + $(CC) -c $(CFLAGS) $(CDIR)/top.c + +queue.o: $(CDIR)/queue.c + $(CC) -c $(CFLAGS) $(CDIR)/queue.c + +install: all + $(EMHOME)/mach/install top + +cmp: all + -$(EMHOME)/mach/compare top + +gen.c: table + $(EMHOME)/lib/topgen table + +lint: $(CFILES) + lint $(LINTOPTS) $(PREFLAGS) $(CFILES) + +clean: + rm -f *.o gen.c gen.h top + +top.o: gen.h +top.o: $(CDIR)/top.h +top.o: $(CDIR)/queue.h +queue.o: $(CDIR)/queue.h diff --git a/mach/compare b/mach/compare new file mode 100755 index 00000000..fc54003f --- /dev/null +++ b/mach/compare @@ -0,0 +1,7 @@ +case $# in +1) DEST="$1" ;; +2) DEST="$2" ;; +*) echo $0 [source] destination ;; +esac +MACH=`(cd .. ; basename \`pwd\`)` +cmp "$1" ../../../lib/${MACH}/$DEST diff --git a/mach/i386/as/Makefile b/mach/i386/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/i386/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/i386/ce/Makefile b/mach/i386/ce/Makefile new file mode 100644 index 00000000..b08bc0fd --- /dev/null +++ b/mach/i386/ce/Makefile @@ -0,0 +1,26 @@ +EMHOME = ../../.. +CEG = $(EMHOME)/lib/ceg/util +OBJ = obj + +all: + make -f $(CEG)/make_asobj "OBJ="$(OBJ) + +install: + make -f $(CEG)/make_asobj "OBJ="$(OBJ) install + +cmp: + -make -f $(CEG)/make_asobj "OBJ="$(OBJ) cmp + +pr: + @pr Makefile EM_table mach.h mach.c as_table as.h as.c + +opr: + make pr | opr + +# total cleanup +clean: + make -f $(CEG)/make_asobj "OBJ="$(OBJ) clean + +# only remove ce, ceg, and back directories +dclean: + make -f $(CEG)/make_asobj "OBJ="$(OBJ) dclean diff --git a/mach/i386/cv/Makefile b/mach/i386/cv/Makefile new file mode 100644 index 00000000..845481fc --- /dev/null +++ b/mach/i386/cv/Makefile @@ -0,0 +1,25 @@ +EMHOME = ../../.. +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +INCLUDE = $(EMHOME)/h +CFLAGS = -I. -I$(INCLUDE) -O +TARGETS = cv + +all: $(TARGETS) + +install: all + ../../install cv + +cmp: all + -../../compare cv + +cv: cv.o + $(CC) $(LDFLAGS) -o cv cv.o $(LIBOBJ) + +clean: + rm -f $(TARGETS) *.o nohup.out Out + +pr: + @pr Makefile cv.c + +opr: + make pr | opr diff --git a/mach/i386/libem/Makefile b/mach/i386/libem/Makefile new file mode 100644 index 00000000..b6a883d7 --- /dev/null +++ b/mach/i386/libem/Makefile @@ -0,0 +1,30 @@ +# $Header$ +MACH=i386 + +all: libem_o.a end.o + +install: all + ../../install libem_o.a tail_em + ../../install end.o end_em + +cmp: all + -../../compare libem_o.a tail_em + -../../compare end.o end_em + + +end.o: end.s + $(MACH) -I../../../h -O -c end.s + +libem_o.a: libem_s.a + ASAR=aal ; export ASAR ;\ + march . libem_o.a + +clean: + rm -f *.o libem_o.a + +opr : + make pr | opr + +pr: + @arch pv libem_s.a | pr -h `pwd`/libem_s.a + @pr `pwd`/end.s diff --git a/mach/i386/libem/compmodule b/mach/i386/libem/compmodule new file mode 100755 index 00000000..575cf59d --- /dev/null +++ b/mach/i386/libem/compmodule @@ -0,0 +1,4 @@ +if i386 -c $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/i386/libem/end.s b/mach/i386/libem/end.s new file mode 100644 index 00000000..b986b7a6 --- /dev/null +++ b/mach/i386/libem/end.s @@ -0,0 +1,17 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define endtext,enddata,endbss +.define _end,_etext,_edata + + ! $Header$ + .sect .text +endtext: +_etext: + .align 4 + .sect .data +enddata: +_edata: + .align 4 +.sect .endsect +_end: +endbss: + .align 4 diff --git a/mach/i386/libem/fakfp.s b/mach/i386/libem/fakfp.s new file mode 100644 index 00000000..0baadb91 --- /dev/null +++ b/mach/i386/libem/fakfp.s @@ -0,0 +1,38 @@ +.define .adf4, .adf8, .sbf4, .sbf8, .mlf4, .mlf8, .dvf4, .dvf8 +.define .ngf4, .ngf8, .fif4, .fif8, .fef4, .fef8 +.define .cif4, .cif8, .cuf4, .cuf8, .cfi, .cfu, .cff4, .cff8 +.define .cmf4, .cmf8 +.sect .text +.sect .rom +.sect .data +.sect .bss + +! $Header$ + + .sect .text +.adf4: +.adf8: +.sbf4: +.sbf8: +.mlf4: +.mlf8: +.dvf4: +.dvf8: +.ngf4: +.ngf8: +.fif4: +.fif8: +.fef4: +.fef8: +.cif4: +.cif8: +.cuf4: +.cuf8: +.cfi: +.cfu: +.cff4: +.cff8: +.cmf4: +.cmf8: + mov eax,18 ! illegal instruction EILLINS + jmp .trp diff --git a/mach/i386/libem/return.s b/mach/i386/libem/return.s new file mode 100644 index 00000000..f12a8813 --- /dev/null +++ b/mach/i386/libem/return.s @@ -0,0 +1,17 @@ +.define .sdret, .dsret, .sret, .dret, .cret +.sect .text + +.dsret: + pop edi +.sret: + pop esi +.cret: + mov esp,ebp + pop ebp + ret + +.sdret: + pop esi +.dret: + pop edi + jmp .cret diff --git a/mach/i386/libem/stop.s b/mach/i386/libem/stop.s new file mode 100644 index 00000000..200d6422 --- /dev/null +++ b/mach/i386/libem/stop.s @@ -0,0 +1,5 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .stop +.stop: + jmp __exit diff --git a/mach/i386/libfp/Makefile b/mach/i386/libfp/Makefile new file mode 100644 index 00000000..1f7e12bc --- /dev/null +++ b/mach/i386/libfp/Makefile @@ -0,0 +1,22 @@ +EMHOME=../../.. +SUF=o +MAKEFILE=$(EMHOME)/mach/proto/fp/Makefile +MACHDEF="MACH=i386" "CFLAGS=-DUSE_DIVIDE" "SUF=$(SUF)" "ASAR=aal" + +all: + make -f $(MAKEFILE) $(MACHDEF) all + +install: + make -f $(MAKEFILE) $(MACHDEF) install + +cmp: all + -../../compare FP_$(MACH).a tail_fp + +clean: + make -f $(MAKEFILE) $(MACHDEF) clean + +opr: + make pr | opr + +pr: + @pr Makefile diff --git a/mach/i386/libsys/Makefile b/mach/i386/libsys/Makefile new file mode 100644 index 00000000..d00169f2 --- /dev/null +++ b/mach/i386/libsys/Makefile @@ -0,0 +1,28 @@ +# $Header$ +MACH=i386 +all: libmon_o.a head_em.o + +install: all + ../../install libmon_o.a tail_mon + ../../install head_em.o head_em + +cmp: all + -../../compare libmon_o.a tail_mon + -../../compare head_em.o head_em + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +head_em.o: head_em.s + $(MACH) -O -c head_em.s + +clean: + rm -f *.o libmon_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/i386/libsys/_pipe.s b/mach/i386/libsys/_pipe.s new file mode 100644 index 00000000..a5110329 --- /dev/null +++ b/mach/i386/libsys/_pipe.s @@ -0,0 +1,12 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define __pipe +.sect .text +__pipe: + mov ax,42 + callf 0x7:0x0 + jae 1f + jmp cerror +1: + shl dx,0x10 + or eax,edx + ret diff --git a/mach/i386/libsys/_profil.s b/mach/i386/libsys/_profil.s new file mode 100644 index 00000000..53ce0879 --- /dev/null +++ b/mach/i386/libsys/_profil.s @@ -0,0 +1,6 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define __profil +.sect .text +__profil: + mov ax,44 + jmp syscal diff --git a/mach/i386/libsys/_stime.s b/mach/i386/libsys/_stime.s new file mode 100644 index 00000000..5b8aa68e --- /dev/null +++ b/mach/i386/libsys/_stime.s @@ -0,0 +1,6 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define __stime +.sect .text +__stime: + mov ax,25 + jmp sysx diff --git a/mach/i386/libsys/_time.s b/mach/i386/libsys/_time.s new file mode 100644 index 00000000..9e71c45b --- /dev/null +++ b/mach/i386/libsys/_time.s @@ -0,0 +1,6 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define __time +.sect .text +__time: + mov ax,13 + jmp syscal diff --git a/mach/i386/libsys/_wait.s b/mach/i386/libsys/_wait.s new file mode 100644 index 00000000..045f50e6 --- /dev/null +++ b/mach/i386/libsys/_wait.s @@ -0,0 +1,12 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define __wait +.sect .text +__wait: + mov ax,7 + callf 0x7:0x0 + jb 1f + shl dx,0x10 + or eax,edx + ret +1: + jmp cerror diff --git a/mach/i386/libsys/compmodule b/mach/i386/libsys/compmodule new file mode 100755 index 00000000..db47c610 --- /dev/null +++ b/mach/i386/libsys/compmodule @@ -0,0 +1,4 @@ +if i386 -c -L $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/i386/ncg/Makefile b/mach/i386/ncg/Makefile new file mode 100644 index 00000000..f5e2bda6 --- /dev/null +++ b/mach/i386/ncg/Makefile @@ -0,0 +1,197 @@ +# $Header$ + +EMHOME=../../.. +#preprocessor flags for table +TABLEFLAGS= +#cgg options +CGGFLAGS= + +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/ncg +CGG=$(EMHOME)/lib/ncgg +CPP=$(EMHOME)/lib/cpp +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/label.c $(CDIR)/main.c \ + $(CDIR)/move.c $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c \ + $(CDIR)/salloc.c $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o label.o \ + main.o move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +label.o: $(CDIR)/label.c + $(CC) -c $(CFLAGS) $(CDIR)/label.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + $(EMHOME)/mach/install cg + +cmp: all + -$(EMHOME)/mach/compare cg + + +tables.c: table $(CGG) + $(CPP) $(TABLEFLAGS) table | $(CGG) $(CGGFLAGS) + -cmp tables.h tables.H || cp tables.H tables.h + +lint: $(CFILES) tables.c + lint $(LINTOPTS) $(PREFLAGS) -I$(CDIR) $(CFILES) tables.c +clean: + rm -f *.o tables.c tables.h debug.out cg tables.H + +distr: tables.c + rm -f tables1.c tables1.h + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + +codegen.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/label.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +label.o: $(CDIR)/label.h +label.o: $(CDIR)/param.h +label.o: tables.h +label.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +main.o: tables.h +move.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/i80/as/Makefile b/mach/i80/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/i80/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/i80/dl/Makefile b/mach/i80/dl/Makefile new file mode 100644 index 00000000..e684c21e --- /dev/null +++ b/mach/i80/dl/Makefile @@ -0,0 +1,25 @@ +EMHOME=../../.. +OBJLIB=$(EMHOME)/modules/lib/libobject.a + +head: mccpm nascom + +mccpm: mccpm.c + $(CC) -I$(EMHOME)/h -o mccpm mccpm.c $(OBJLIB) + +nascom: nascom.c + $(CC) -I$(EMHOME)/h -o nascom nascom.c $(OBJLIB) + +install: head + @echo Nothing is installed + +cmp: head + @echo Nothing is compared + +clean: + rm -f *.o + +pr: + @pr `pwd`/Makefile `pwd`/mccpm.c `pwd`/nascom.c + +opr: + make pr | opr diff --git a/mach/i80/libem/Makefile b/mach/i80/libem/Makefile new file mode 100644 index 00000000..e4ec304d --- /dev/null +++ b/mach/i80/libem/Makefile @@ -0,0 +1,29 @@ +# $Header$ +MACH=i80 +all: libem_o.a end.o + +install: all + ../../install end.o end_em + ../../install libem_o.a tail_em + + +cmp: all + -../../compare end.o end_em + -../../compare libem_o.a tail_em + +libem_o.a: libem_s.a + ASAR=aal ; export ASAR ;\ + march . libem_o.a + +end.o: end.s + $(MACH) -I../../../h -c end.s + +clean: + rm -f *.o libem_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/end.s + @arch pv libem_s.a | pr -h `pwd`/libem_s.a diff --git a/mach/i80/libem/compmodule b/mach/i80/libem/compmodule new file mode 100755 index 00000000..2e87032c --- /dev/null +++ b/mach/i80/libem/compmodule @@ -0,0 +1,4 @@ +if i80 -c $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/i80/libem/end.s b/mach/i80/libem/end.s new file mode 100644 index 00000000..6b9ce418 --- /dev/null +++ b/mach/i80/libem/end.s @@ -0,0 +1,17 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define endtext,enddata,endbss +.define _end,_etext,_edata + + ! $Header$ + .sect .text +endtext: +_etext: + .align 2 + .sect .data +enddata: +_edata: + .align 2 +.sect .endsect +_end: +endbss: + .align 2 diff --git a/mach/i80/libmon/Makefile b/mach/i80/libmon/Makefile new file mode 100644 index 00000000..c334b9ba --- /dev/null +++ b/mach/i80/libmon/Makefile @@ -0,0 +1,29 @@ +# $Header$ +MACH=i80 +all: libsys_o.a head_em.o + +install: all + ../../install head_em.o head_em + ../../install libsys_o.a tail_sys + + +cmp: all + -../../compare head_em.o head_em + -../../compare libsys_o.a tail_sys + +libsys_o.a: libsys_s.a + ASAR=aal ; export ASAR ;\ + march . libsys_o.a + +head_em.o: head_em.s + $(MACH) -I../../../h -c head_em.s + +clean: + rm -f *.o libsys_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libsys_s.a | pr -h `pwd`/libsys_s.a diff --git a/mach/i80/libmon/compmodule b/mach/i80/libmon/compmodule new file mode 100755 index 00000000..de15217c --- /dev/null +++ b/mach/i80/libmon/compmodule @@ -0,0 +1,4 @@ +if i80 -c -L $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/i80/libmon/head.s b/mach/i80/libmon/head.s new file mode 100644 index 00000000..f5bd2351 --- /dev/null +++ b/mach/i80/libmon/head.s @@ -0,0 +1,49 @@ +.define hol0, argv, envp, begbss +.define .ignmask,.reghp,.trapproc,.fra +.define .retadr,.retadr1,.areg,.bcreg,.tmp1 +.define block1, block2, block3 +.define .stop + + .base 0x1000 +.text + lxi h,0x1000 ! stack will grow from 0x1000 downwards + sphl + lxi h,begbss ! clear bss + lxi d,endbss-begbss + mvi c,0 + +2: mov m,c + inx h + dcx d + mov a,e + ora d + jnz 2b + + lxi h,envp ! call main + push h + lxi h,argv + push h + lxi h,0 + push h + call _m_a_i_n +.stop: jmp 0xfb52 + +.bss +begbss: +.trapproc: .space 2 +.ignmask: .space 2 +.data +hol0: .space 8 +.reghp: .word endbss +argv: .word 0 +envp: .word 0 +.retadr: .space 2 ! used to save return address +.retadr1: .space 2 ! reserve +.bcreg: .space 2 ! used to save localbase +.areg: .space 1 +.tmp1: .space 2 +.fra: .space 8 ! 8 bytes function return area +block1: .space 4 ! used by 32 bits divide and +block2: .space 4 ! multiply routines +block3: .space 4 + diff --git a/mach/i80/libmon/tail.s b/mach/i80/libmon/tail.s new file mode 100644 index 00000000..bd667480 --- /dev/null +++ b/mach/i80/libmon/tail.s @@ -0,0 +1,7 @@ +.define endtext, enddata, endbss +.text +endtext: .align 2 +.data +enddata: .align 2 +.bss +endbss: .align 2 diff --git a/mach/i80/ncg/Makefile b/mach/i80/ncg/Makefile new file mode 100644 index 00000000..f5e2bda6 --- /dev/null +++ b/mach/i80/ncg/Makefile @@ -0,0 +1,197 @@ +# $Header$ + +EMHOME=../../.. +#preprocessor flags for table +TABLEFLAGS= +#cgg options +CGGFLAGS= + +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/ncg +CGG=$(EMHOME)/lib/ncgg +CPP=$(EMHOME)/lib/cpp +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/label.c $(CDIR)/main.c \ + $(CDIR)/move.c $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c \ + $(CDIR)/salloc.c $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o label.o \ + main.o move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +label.o: $(CDIR)/label.c + $(CC) -c $(CFLAGS) $(CDIR)/label.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + $(EMHOME)/mach/install cg + +cmp: all + -$(EMHOME)/mach/compare cg + + +tables.c: table $(CGG) + $(CPP) $(TABLEFLAGS) table | $(CGG) $(CGGFLAGS) + -cmp tables.h tables.H || cp tables.H tables.h + +lint: $(CFILES) tables.c + lint $(LINTOPTS) $(PREFLAGS) -I$(CDIR) $(CFILES) tables.c +clean: + rm -f *.o tables.c tables.h debug.out cg tables.H + +distr: tables.c + rm -f tables1.c tables1.h + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + +codegen.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/label.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +label.o: $(CDIR)/label.h +label.o: $(CDIR)/param.h +label.o: tables.h +label.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +main.o: tables.h +move.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/i86/as/Makefile b/mach/i86/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/i86/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/i86/as/READ_ME b/mach/i86/as/READ_ME new file mode 100644 index 00000000..b620073b --- /dev/null +++ b/mach/i86/as/READ_ME @@ -0,0 +1,9 @@ +The mach?.c files in this directory were made for an earlier version of +the universal assembler and are too dependent on its innards. +I have no idea in what way they should be changed. + + Duk Bekema + +I adapted them to the new framework. It appears to work now. + + Ceriel Jacobs diff --git a/mach/i86/ce/Makefile b/mach/i86/ce/Makefile new file mode 100644 index 00000000..b08bc0fd --- /dev/null +++ b/mach/i86/ce/Makefile @@ -0,0 +1,26 @@ +EMHOME = ../../.. +CEG = $(EMHOME)/lib/ceg/util +OBJ = obj + +all: + make -f $(CEG)/make_asobj "OBJ="$(OBJ) + +install: + make -f $(CEG)/make_asobj "OBJ="$(OBJ) install + +cmp: + -make -f $(CEG)/make_asobj "OBJ="$(OBJ) cmp + +pr: + @pr Makefile EM_table mach.h mach.c as_table as.h as.c + +opr: + make pr | opr + +# total cleanup +clean: + make -f $(CEG)/make_asobj "OBJ="$(OBJ) clean + +# only remove ce, ceg, and back directories +dclean: + make -f $(CEG)/make_asobj "OBJ="$(OBJ) dclean diff --git a/mach/i86/cv/Makefile b/mach/i86/cv/Makefile new file mode 100644 index 00000000..5cfa97a6 --- /dev/null +++ b/mach/i86/cv/Makefile @@ -0,0 +1,25 @@ +EMHOME = ../../.. +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +INCLUDE = $(EMHOME)/h +CFLAGS = -I. -I$(INCLUDE) -O +TARGETS = cv + +all: $(TARGETS) + +install: all + ../../install cv + +cmp: all + ../../compare cv + +cv: cv.o + $(CC) $(LDFLAGS) -o cv cv.o $(LIBOBJ) + +clean: + rm -f $(TARGETS) *.o nohup.out Out + +pr: + @pr Makefile cv.c + +opr: + make pr | opr diff --git a/mach/i86/libem/Makefile b/mach/i86/libem/Makefile new file mode 100644 index 00000000..1924bb79 --- /dev/null +++ b/mach/i86/libem/Makefile @@ -0,0 +1,30 @@ +# $Header$ +MACH=i86 + +all: libem_o.a end.o + +install: all + ../../install libem_o.a tail_em + ../../install end.o end_em + +cmp: all + -../../compare libem_o.a tail_em + -../../compare end.o end_em + + +end.o: end.s + $(MACH) -I../../../h -O -c end.s + +libem_o.a: libem_s.a + ASAR=aal ; export ASAR ;\ + march . libem_o.a + +clean: + rm -f *.o libem_o.a + +opr : + make pr | opr + +pr: + @arch pv libem_s.a | pr -h `pwd`/libem_s.a + @pr `pwd`/end.s diff --git a/mach/i86/libem/compmodule b/mach/i86/libem/compmodule new file mode 100755 index 00000000..8ec2f672 --- /dev/null +++ b/mach/i86/libem/compmodule @@ -0,0 +1,4 @@ +if i86 -c $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/i86/libem/end.s b/mach/i86/libem/end.s new file mode 100644 index 00000000..6b9ce418 --- /dev/null +++ b/mach/i86/libem/end.s @@ -0,0 +1,17 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define endtext,enddata,endbss +.define _end,_etext,_edata + + ! $Header$ + .sect .text +endtext: +_etext: + .align 2 + .sect .data +enddata: +_edata: + .align 2 +.sect .endsect +_end: +endbss: + .align 2 diff --git a/mach/i86/libem/fakfp.s b/mach/i86/libem/fakfp.s new file mode 100644 index 00000000..bffaea36 --- /dev/null +++ b/mach/i86/libem/fakfp.s @@ -0,0 +1,38 @@ +.define .adf4, .adf8, .sbf4, .sbf8, .mlf4, .mlf8, .dvf4, .dvf8 +.define .ngf4, .ngf8, .fif4, .fif8, .fef4, .fef8 +.define .cif4, .cif8, .cuf4, .cuf8, .cfi, .cfu, .cff4, .cff8 +.define .cmf4, .cmf8 +.sect .text +.sect .rom +.sect .data +.sect .bss + +! $Header$ + + .sect .text +.adf4: +.adf8: +.sbf4: +.sbf8: +.mlf4: +.mlf8: +.dvf4: +.dvf8: +.ngf4: +.ngf8: +.fif4: +.fif8: +.fef4: +.fef8: +.cif4: +.cif8: +.cuf4: +.cuf8: +.cfi: +.cfu: +.cff4: +.cff8: +.cmf4: +.cmf8: + mov ax,18 ! illegal instruction EILLINS + jmp .trp diff --git a/mach/i86/libem/printf.s b/mach/i86/libem/printf.s new file mode 100644 index 00000000..83f13320 --- /dev/null +++ b/mach/i86/libem/printf.s @@ -0,0 +1,40 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define printf +.extern printc, printd, prints + +printf: + pop bx ! return address + xchg ax,di + mov si,sp +1: + movb al,(di) + inc di + testb al,al + jz 6f + cmpb al,'%' + je 3f +2: + call printc + jmp 1b +3: + movb al,(di) + inc di + cmpb al,'c' + jne 4f + lods + jmp 2b +4: + cmpb al,'d' + jne 5f + lods + call printd + jmp 1b +5: + cmpb al,'s' + jne 2b + lods + call prints + jmp 1b +6: + jmp bx diff --git a/mach/i86/libem/stop.s b/mach/i86/libem/stop.s new file mode 100644 index 00000000..fbf0e691 --- /dev/null +++ b/mach/i86/libem/stop.s @@ -0,0 +1,5 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .stop +.stop: + int 3 diff --git a/mach/i86/libem/tail.s b/mach/i86/libem/tail.s new file mode 100644 index 00000000..059b2376 --- /dev/null +++ b/mach/i86/libem/tail.s @@ -0,0 +1,16 @@ +.define endtext,enddata,endbss +.define _end,_etext,_edata + + ! $Header$ + .text +endtext: +_etext: + .align 2 + .data +enddata: +_edata: + .align 2 + .bss +_end: +endbss: + .align 2 diff --git a/mach/i86/libfp/Makefile b/mach/i86/libfp/Makefile new file mode 100644 index 00000000..67c3ad2d --- /dev/null +++ b/mach/i86/libfp/Makefile @@ -0,0 +1,22 @@ +EMHOME=../../.. +SUF=o +MAKEFILE=$(EMHOME)/mach/proto/fp/Makefile +MACHDEF="MACH=i86" "SUF=$(SUF)" "ASAR=aal" + +all: + make -f $(MAKEFILE) $(MACHDEF) all + +install: + make -f $(MAKEFILE) $(MACHDEF) install + +cmp: all + -../../compare FP_$(MACH).a tail_fp + +clean: + make -f $(MAKEFILE) $(MACHDEF) clean + +opr: + make pr | opr + +pr: + @pr Makefile diff --git a/mach/i86/libsys/Makefile b/mach/i86/libsys/Makefile new file mode 100644 index 00000000..c03a0394 --- /dev/null +++ b/mach/i86/libsys/Makefile @@ -0,0 +1,27 @@ +# $Header$ +MACH=i86 +all: libmon_o.a head_em.o + +install: all + ../../install libmon_o.a tail_mon + ../../install head_em.o head_em + +cmp: all + -../../compare libmon_o.a tail_mon + -../../compare head_em.o head_em + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +head_em.o: head_em.s + $(MACH) -O -c head_em.s +clean: + rm -f *.o libmon_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/i86/libsys/compmodule b/mach/i86/libsys/compmodule new file mode 100755 index 00000000..70233902 --- /dev/null +++ b/mach/i86/libsys/compmodule @@ -0,0 +1,4 @@ +if i86 -c -L $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/i86/ncg/Makefile b/mach/i86/ncg/Makefile new file mode 100644 index 00000000..f5e2bda6 --- /dev/null +++ b/mach/i86/ncg/Makefile @@ -0,0 +1,197 @@ +# $Header$ + +EMHOME=../../.. +#preprocessor flags for table +TABLEFLAGS= +#cgg options +CGGFLAGS= + +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/ncg +CGG=$(EMHOME)/lib/ncgg +CPP=$(EMHOME)/lib/cpp +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/label.c $(CDIR)/main.c \ + $(CDIR)/move.c $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c \ + $(CDIR)/salloc.c $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o label.o \ + main.o move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +label.o: $(CDIR)/label.c + $(CC) -c $(CFLAGS) $(CDIR)/label.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + $(EMHOME)/mach/install cg + +cmp: all + -$(EMHOME)/mach/compare cg + + +tables.c: table $(CGG) + $(CPP) $(TABLEFLAGS) table | $(CGG) $(CGGFLAGS) + -cmp tables.h tables.H || cp tables.H tables.h + +lint: $(CFILES) tables.c + lint $(LINTOPTS) $(PREFLAGS) -I$(CDIR) $(CFILES) tables.c +clean: + rm -f *.o tables.c tables.h debug.out cg tables.H + +distr: tables.c + rm -f tables1.c tables1.h + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + +codegen.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/label.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +label.o: $(CDIR)/label.h +label.o: $(CDIR)/param.h +label.o: tables.h +label.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +main.o: tables.h +move.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/install b/mach/install new file mode 100755 index 00000000..8d87ed14 --- /dev/null +++ b/mach/install @@ -0,0 +1,21 @@ +case $# in +1) DEST="$1" ;; +2) DEST="$2" ;; +*) echo $0 [source] destination ;; +esac +MACH=`(cd .. ; basename \`pwd\`)` +mkdir ../../../lib/$MACH >/dev/null 2>&1 +if cp "$1" ../../../lib/${MACH}/$DEST >/dev/null 2>&1 || + { rm -f ../../../lib/${MACH}/$DEST >/dev/null 2>&1 && + cp "$1" ../../../lib/${MACH}/$DEST >/dev/null 2>&1 + } +then + if (ar t ../../../lib/${MACH}/$DEST | grep __.SYMDEF ) >/dev/null 2>&1 + then + ranlib ../../../lib/${MACH}/$DEST + fi + exit 0 +else + echo Sorry, can not create "lib/${MACH}/$DEST". + exit 1 +fi diff --git a/mach/m68020/as/Makefile b/mach/m68020/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/m68020/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/m68020/ce/Makefile b/mach/m68020/ce/Makefile new file mode 100644 index 00000000..b08bc0fd --- /dev/null +++ b/mach/m68020/ce/Makefile @@ -0,0 +1,26 @@ +EMHOME = ../../.. +CEG = $(EMHOME)/lib/ceg/util +OBJ = obj + +all: + make -f $(CEG)/make_asobj "OBJ="$(OBJ) + +install: + make -f $(CEG)/make_asobj "OBJ="$(OBJ) install + +cmp: + -make -f $(CEG)/make_asobj "OBJ="$(OBJ) cmp + +pr: + @pr Makefile EM_table mach.h mach.c as_table as.h as.c + +opr: + make pr | opr + +# total cleanup +clean: + make -f $(CEG)/make_asobj "OBJ="$(OBJ) clean + +# only remove ce, ceg, and back directories +dclean: + make -f $(CEG)/make_asobj "OBJ="$(OBJ) dclean diff --git a/mach/m68020/cv/Makefile b/mach/m68020/cv/Makefile new file mode 100644 index 00000000..292eacbb --- /dev/null +++ b/mach/m68020/cv/Makefile @@ -0,0 +1,22 @@ +CFLAGS=-O -I../../../h +LDFLAGS = + +cv: cv.o + $(CC) -o cv $(LDFLAGS) cv.o + +install: ins_cv +ins_cv: cv + ../../install cv + +cmp: cmp_cv +cmp_cv: cv + -../../compare cv + +opr: + make pr | opr + +pr: + @pr `pwd`/cv.c + +clean: + -rm -f *.o *.old cv diff --git a/mach/m68020/libem/Makefile b/mach/m68020/libem/Makefile new file mode 100644 index 00000000..1233a1f0 --- /dev/null +++ b/mach/m68020/libem/Makefile @@ -0,0 +1,38 @@ +# $Header$ +MACH=m68020 +ASAR=aal +all: libem_o.a end.a + +install: all + ../../install libem_o.a tail_em + ../../install end.a end_em + +cmp: all + -../../compare libem_o.a tail_em + -../../compare end.a end_em + +end.a: em_end.s etext.s edata.s end.s + $(MACH) -I../../../h -c em_end.s + $(MACH) -I../../../h -c edata.s + $(MACH) -I../../../h -c etext.s + $(MACH) -I../../../h -c end.s + $(ASAR) cr end.a em_end.o etext.o edata.o end.o + +libem_o.a: libem_s.a + ASAR=$(ASAR) ; export ASAR ;\ + march . libem_o.a + +clean: + rm -f *.o libem_o.a end.a + +opr : + make pr | opr + +pr: + @arch pv libem_s.a | pr -h `pwd`/libem_s.a + @pr `pwd`/em_end.s `pwd`/edata.s `pwd`/etext.s `pwd`/end.s + +trpstr.s: trpstr.c strscript + sh strscript + +distr: trpstr.s diff --git a/mach/m68020/libem/compmodule b/mach/m68020/libem/compmodule new file mode 100755 index 00000000..a61e867b --- /dev/null +++ b/mach/m68020/libem/compmodule @@ -0,0 +1,4 @@ +if m68020 -c $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/m68020/libem/edata.s b/mach/m68020/libem/edata.s new file mode 100644 index 00000000..f53adc10 --- /dev/null +++ b/mach/m68020/libem/edata.s @@ -0,0 +1,9 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _edata +.sect .data + .align 4 + .sect .data +_edata: diff --git a/mach/m68020/libem/em_end.s b/mach/m68020/libem/em_end.s new file mode 100644 index 00000000..a062368d --- /dev/null +++ b/mach/m68020/libem/em_end.s @@ -0,0 +1,22 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define endtext,enddata,endbss,__end +.sect .text + .align 4 +.sect .rom + .align 4 +.sect .data + .align 4 +.sect .bss + .align 4 +.sect .end ! only for declaration of _end, __end and endbss. + + .sect .text +endtext: + .sect .data +enddata: + .sect .end +__end: +endbss: diff --git a/mach/m68020/libem/end.s b/mach/m68020/libem/end.s new file mode 100644 index 00000000..93a1e6e0 --- /dev/null +++ b/mach/m68020/libem/end.s @@ -0,0 +1,7 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _end +.sect .end ! only for declaration of _end, __end and endbss. +_end: diff --git a/mach/m68020/libem/etext.s b/mach/m68020/libem/etext.s new file mode 100644 index 00000000..8c7453cb --- /dev/null +++ b/mach/m68020/libem/etext.s @@ -0,0 +1,9 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _etext +.sect .text + .align 4 + .sect .text +_etext: diff --git a/mach/m68020/libem/fakfp.s b/mach/m68020/libem/fakfp.s new file mode 100644 index 00000000..f6e6d240 --- /dev/null +++ b/mach/m68020/libem/fakfp.s @@ -0,0 +1,39 @@ +.define .adf4, .adf8, .sbf4, .sbf8, .mlf4, .mlf8, .dvf4, .dvf8 +.define .ngf4, .ngf8, .fif4, .fif8, .fef4, .fef8 +.define .cif4, .cif8, .cuf4, .cuf8, .cfi, .cfu, .cff4, .cff8 +.define .cmf4, .cmf8 +.sect .text +.sect .rom +.sect .data +.sect .bss + +! $Header$ + + .sect .text +.adf4: +.adf8: +.sbf4: +.sbf8: +.mlf4: +.mlf8: +.dvf4: +.dvf8: +.ngf4: +.ngf8: +.fif4: +.fif8: +.fef4: +.fef8: +.cif4: +.cif8: +.cuf4: +.cuf8: +.cfi: +.cfu: +.cff4: +.cff8: +.cmf4: +.cmf8: + move.l #18,-(sp) + jsr (.trp) + rts diff --git a/mach/m68020/libem/printf.s b/mach/m68020/libem/printf.s new file mode 100644 index 00000000..0ec7553c --- /dev/null +++ b/mach/m68020/libem/printf.s @@ -0,0 +1,83 @@ +.define _printf, _putchar, _getal, _char +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .bss +_getal: + .space 12 +_char: + .space 1 + .align 4 +.sect .data +hexs: + .ascii "0123456789abcdef" + .align 4 +.sect .text +_printf: + movem.l d0/d1/d2/a0/a1/a2/a3/a4/a5/a6, -(sp) + lea (44, sp), a6 ! a6 <- address of arguments + move.l (a6)+, a5 ! a5 <- address of format +next: move.b (a5)+, d0 + beq out + cmp.b #'%', d0 + beq procnt +put: move.l d0, -(sp) + jsr (_putchar) ! long argument on stack + tst.l (sp)+ + bra next + +procnt: move.b (a5)+, d0 + cmp.b #'d', d0 ! NOTE: %d means unsigned. + beq digit + cmp.b #'x', d0 + beq hex + cmp.b #'s', d0 + beq string + cmp.b #'%', d0 ! second % has to be printed. + beq put + tst.b -(a5) ! normal char should be printed + bra next + +string: move.l (a6)+, a2 ! a2 <- address of string +sloop: move.b (a2)+, d0 + beq next + move.l d0, -(sp) + jsr (_putchar) ! long argument on stack + tst.l (sp)+ + bra sloop + +digit: move.l (a6)+, d1 ! d1 <- integer + move.l #_getal+12, a2 ! a2 <- ptr to last part of buf + clr.b -(a2) ! stringterminator +1: divul.l #10, d2:d1 ! d1 <- qotient; d2 <- remainder + add.l #'0', d2 + move.b d2, -(a2) + tst.l d1 ! if quotient = 0 then ready + bne 1b + bra sloop ! print digitstring. + +hex: move.l (a6)+, d1 ! d1 <- integer + move.l #_getal+12, a2 ! a2 <- ptr to last part of buf + clr.b -(a2) ! stringterminator + move.l #7, d2 ! loop control +1: move.l d1, d0 + and.l #15, d0 + move.b (hexs,d0.w), -(a2) ! hex digit + asr.l #4, d1 + dbf d2, 1b + bra sloop + +out: + movem.l (sp)+, d0/d1/d2/a0/a1/a2/a3/a4/a5/a6 + rts + + +_putchar: + move.l #1, -(sp) + pea (11,sp) + move.l #1, -(sp) + jsr (_write) + lea (12, sp), sp + rts +.align 2 diff --git a/mach/m68020/libem/strscript b/mach/m68020/libem/strscript new file mode 100644 index 00000000..ee4cc1b4 --- /dev/null +++ b/mach/m68020/libem/strscript @@ -0,0 +1,3 @@ +m68020 -c.s -L -LIB -I../../../h trpstr.c +sed s/_trpstr/.trpstr/g < trpstr.s > trpstr.ss +mv trpstr.ss trpstr.s diff --git a/mach/m68020/libfp/Makefile b/mach/m68020/libfp/Makefile new file mode 100644 index 00000000..22e6c795 --- /dev/null +++ b/mach/m68020/libfp/Makefile @@ -0,0 +1,22 @@ +EMHOME=../../.. +SUF=o +MAKEFILE=$(EMHOME)/mach/proto/fp/Makefile +MACHDEF="MACH=m68020" "CFLAGS=-DUSE_DIVIDE" "SUF=$(SUF)" "ASAR=aal" + +all: + make -f $(MAKEFILE) $(MACHDEF) all + +install: + make -f $(MAKEFILE) $(MACHDEF) install + +cmp: all + -../../compare FP_$(MACH).a tail_fp + +clean: + make -f $(MAKEFILE) $(MACHDEF) clean + +opr: + make pr | opr + +pr: + @pr Makefile diff --git a/mach/m68020/libsys/Makefile b/mach/m68020/libsys/Makefile new file mode 100644 index 00000000..5861ef1d --- /dev/null +++ b/mach/m68020/libsys/Makefile @@ -0,0 +1,29 @@ +# $Header$ +MACH=m68020 +all: libmon_o.a head_em.o + +install: all + ../../install head_em.o head_em + ../../install libmon_o.a tail_mon + + +cmp: all + -../../compare head_em.o head_em + -../../compare libmon_o.a tail_mon + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +head_em.o: head_em.s + $(MACH) -I../../../h -c head_em.s + +clean: + rm -f *.o libmon_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/m68020/libsys/compmodule b/mach/m68020/libsys/compmodule new file mode 100755 index 00000000..58dc66c6 --- /dev/null +++ b/mach/m68020/libsys/compmodule @@ -0,0 +1,4 @@ +if m68020 -c -L $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/m68020/ncg/Makefile b/mach/m68020/ncg/Makefile new file mode 100644 index 00000000..f5e2bda6 --- /dev/null +++ b/mach/m68020/ncg/Makefile @@ -0,0 +1,197 @@ +# $Header$ + +EMHOME=../../.. +#preprocessor flags for table +TABLEFLAGS= +#cgg options +CGGFLAGS= + +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/ncg +CGG=$(EMHOME)/lib/ncgg +CPP=$(EMHOME)/lib/cpp +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/label.c $(CDIR)/main.c \ + $(CDIR)/move.c $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c \ + $(CDIR)/salloc.c $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o label.o \ + main.o move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +label.o: $(CDIR)/label.c + $(CC) -c $(CFLAGS) $(CDIR)/label.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + $(EMHOME)/mach/install cg + +cmp: all + -$(EMHOME)/mach/compare cg + + +tables.c: table $(CGG) + $(CPP) $(TABLEFLAGS) table | $(CGG) $(CGGFLAGS) + -cmp tables.h tables.H || cp tables.H tables.h + +lint: $(CFILES) tables.c + lint $(LINTOPTS) $(PREFLAGS) -I$(CDIR) $(CFILES) tables.c +clean: + rm -f *.o tables.c tables.h debug.out cg tables.H + +distr: tables.c + rm -f tables1.c tables1.h + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + +codegen.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/label.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +label.o: $(CDIR)/label.h +label.o: $(CDIR)/param.h +label.o: tables.h +label.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +main.o: tables.h +move.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/m68020/top/Makefile b/mach/m68020/top/Makefile new file mode 100644 index 00000000..57908427 --- /dev/null +++ b/mach/m68020/top/Makefile @@ -0,0 +1,42 @@ +EMHOME=../../.. +LIBS=$(EMHOME)/modules/lib/libstring.a +PREFLAGS=-I. +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O -DNDEBUG +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +CDIR=$(EMHOME)/mach/proto/top +CFILES=$(CDIR)/top.c $(CDIR)/queue.c +OFILES=top.o queue.o + +all: gen.c + make top + +top: $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) $(LIBS) -o top + +top.o: $(CDIR)/top.c gen.c + $(CC) -c $(CFLAGS) $(CDIR)/top.c + +queue.o: $(CDIR)/queue.c + $(CC) -c $(CFLAGS) $(CDIR)/queue.c + +install: all + $(EMHOME)/mach/install top + +cmp: all + -$(EMHOME)/mach/compare top + +gen.c: table + $(EMHOME)/lib/topgen table + +lint: $(CFILES) + lint $(LINTOPTS) $(PREFLAGS) $(CFILES) + +clean: + rm -f *.o gen.c gen.h top + +top.o: gen.h +top.o: $(CDIR)/top.h +top.o: $(CDIR)/queue.h +queue.o: $(CDIR)/queue.h diff --git a/mach/m68k2/as/Makefile b/mach/m68k2/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/m68k2/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/m68k2/cg/fppsim.h b/mach/m68k2/cg/fppsim.h new file mode 100644 index 00000000..a7d621e2 --- /dev/null +++ b/mach/m68k2/cg/fppsim.h @@ -0,0 +1,6 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* #define NOFLOAT /* define when not using fpp simulator */ diff --git a/mach/m68k2/cv/Makefile b/mach/m68k2/cv/Makefile new file mode 100644 index 00000000..d0a00288 --- /dev/null +++ b/mach/m68k2/cv/Makefile @@ -0,0 +1,22 @@ +CFLAGS=-I../../../h -O +LDFLAGS = + +cv: cv.o + $(CC) -o cv $(LDFLAGS) cv.o + +install: ins_cv +ins_cv: cv + ../../install cv + +cmp: cmp_cv +cmp_cv: cv + -../../compare cv + +opr: + make pr | opr + +pr: + @pr `pwd`/cv.c + +clean: + -rm -f *.o *.old cv diff --git a/mach/m68k2/dl/Makefile b/mach/m68k2/dl/Makefile new file mode 100644 index 00000000..e5217610 --- /dev/null +++ b/mach/m68k2/dl/Makefile @@ -0,0 +1,22 @@ +EMHOME=../../.. +OBJLIB=$(EMHOME)/modules/lib/libobject.a + +head: dl + +dl: dl.c + $(CC) -I$(EMHOME)/h -o dl dl.c $(OBJLIB) + +install: head + @echo Nothing is installed + +cmp: head + @echo Nothing is compared + +clean: + rm -f *.o + +pr: + @pr `pwd`/Makefile `pwd`/dl.c + +opr: + make pr | opr diff --git a/mach/m68k2/libem/Makefile b/mach/m68k2/libem/Makefile new file mode 100644 index 00000000..b8a2346a --- /dev/null +++ b/mach/m68k2/libem/Makefile @@ -0,0 +1,33 @@ +# $Header$ +MACH=m68k2 +ASAR=aal +all: libem_o.a end.a + +install: all + ../../install libem_o.a tail_em + ../../install end.a end_em + +cmp: all + -../../compare libem_o.a tail_em + -../../compare end.a end_em + +end.a: em_end.s etext.s edata.s end.s + $(MACH) -I../../../h -c em_end.s + $(MACH) -I../../../h -c edata.s + $(MACH) -I../../../h -c etext.s + $(MACH) -I../../../h -c end.s + $(ASAR) cr end.a em_end.o etext.o edata.o end.o + +libem_o.a: libem_s.a + ASAR=$(ASAR) ; export ASAR ;\ + march . libem_o.a + +clean: + rm -f *.o libem_o.a end.a + +opr : + make pr | opr + +pr: + @arch pv libem_s.a | pr -h `pwd`/libem_s.a + @pr `pwd`/em_end.s `pwd`/edata.s `pwd`/etext.s `pwd`/end.s diff --git a/mach/m68k2/libem/compmodule b/mach/m68k2/libem/compmodule new file mode 100755 index 00000000..02105f21 --- /dev/null +++ b/mach/m68k2/libem/compmodule @@ -0,0 +1,4 @@ +if m68k2 -c $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/m68k2/libem/cvf.s b/mach/m68k2/libem/cvf.s new file mode 100644 index 00000000..dc2c5d2e --- /dev/null +++ b/mach/m68k2/libem/cvf.s @@ -0,0 +1,19 @@ +.define .cfi,.cif,.cfu,.cuf,.cff +.sect .text +.sect .rom +.sect .data +.sect .bss + + .sect .text + + ! this is a dummy float conversion routine +.cfi: +.cif: +.cfu: +.cuf: +.cff: + move.l (sp)+,a0 ! return address + move (sp)+,d0 ! destination size + sub (sp)+,d0 ! diff. in sizes + sub d0,sp + jmp (a0) diff --git a/mach/m68k2/libem/edata.s b/mach/m68k2/libem/edata.s new file mode 100644 index 00000000..f53adc10 --- /dev/null +++ b/mach/m68k2/libem/edata.s @@ -0,0 +1,9 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _edata +.sect .data + .align 4 + .sect .data +_edata: diff --git a/mach/m68k2/libem/em_end.s b/mach/m68k2/libem/em_end.s new file mode 100644 index 00000000..a062368d --- /dev/null +++ b/mach/m68k2/libem/em_end.s @@ -0,0 +1,22 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define endtext,enddata,endbss,__end +.sect .text + .align 4 +.sect .rom + .align 4 +.sect .data + .align 4 +.sect .bss + .align 4 +.sect .end ! only for declaration of _end, __end and endbss. + + .sect .text +endtext: + .sect .data +enddata: + .sect .end +__end: +endbss: diff --git a/mach/m68k2/libem/end.s b/mach/m68k2/libem/end.s new file mode 100644 index 00000000..93a1e6e0 --- /dev/null +++ b/mach/m68k2/libem/end.s @@ -0,0 +1,7 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _end +.sect .end ! only for declaration of _end, __end and endbss. +_end: diff --git a/mach/m68k2/libem/etext.s b/mach/m68k2/libem/etext.s new file mode 100644 index 00000000..8c7453cb --- /dev/null +++ b/mach/m68k2/libem/etext.s @@ -0,0 +1,9 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _etext +.sect .text + .align 4 + .sect .text +_etext: diff --git a/mach/m68k2/libem/ffp.s b/mach/m68k2/libem/ffp.s new file mode 100644 index 00000000..ab99094c --- /dev/null +++ b/mach/m68k2/libem/ffp.s @@ -0,0 +1,39 @@ +.define .adf4, .adf8, .sbf4, .sbf8, .mlf4, .mlf8, .dvf4, .dvf8 +.define .ngf4, .ngf8, .fif4, .fif8, .fef4, .fef8 +.define .cif4, .cif8, .cuf4, .cuf8, .cfi, .cfu, .cff4, .cff8 +.define .cmf4, .cmf8 +.sect .text +.sect .rom +.sect .data +.sect .bss + +! $Header$ + + .sect .text +.adf4: +.adf8: +.sbf4: +.sbf8: +.mlf4: +.mlf8: +.dvf4: +.dvf8: +.ngf4: +.ngf8: +.fif4: +.fif8: +.fef4: +.fef8: +.cif4: +.cif8: +.cuf4: +.cuf8: +.cfi: +.cfu: +.cff4: +.cff8: +.cmf4: +.cmf8: + move.w #18,-(sp) + jsr .trp + rts diff --git a/mach/m68k2/libem/printf.s b/mach/m68k2/libem/printf.s new file mode 100644 index 00000000..044484df --- /dev/null +++ b/mach/m68k2/libem/printf.s @@ -0,0 +1,189 @@ +.define _printn +.define _printf +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text +_putchar: + move.w #1,-(sp) + pea 7(sp) + move.w #1,-(sp) + jsr _write + add.l #8,sp + rts +_printf: + link a6,#-12 +.sect .data +_12: + .data2 28786 + .data2 26990 + .data2 29798 + .data2 11875 + .data2 0 +.sect .text + pea 8+4(a6) + move.l (sp)+,-6(a6) +I004: + move.l 8+0(a6),-(sp) + move.l (sp),-(sp) + move.l (sp)+,a0 + add #1,a0 + move.l a0,-(sp) + move.l (sp)+,8+0(a6) + move.l (sp)+,a0 + clr d0 + move.b (a0),d0 + move.w d0,-(sp) + move.w (sp),-(sp) + move.w (sp)+,-2(a6) + move.w #37,-(sp) + move.w (sp)+,d0 + cmp (sp)+,d0 + beq I005 + move.w -2(a6),-(sp) + tst (sp)+ + beq I002 + move.w -2(a6),-(sp) + jsr _putchar + add #2,sp + jmp I004 +I005: + move.l 8+0(a6),-(sp) + move.l (sp),-(sp) + move.l (sp)+,a0 + add #1,a0 + move.l a0,-(sp) + move.l (sp)+,8+0(a6) + move.l (sp)+,a0 + clr d0 + move.b (a0),d0 + move.w d0,-(sp) + move.w (sp)+,-2(a6) + move.w -2(a6),-(sp) + move.w #100,-(sp) + move.w (sp)+,d0 + cmp (sp)+,d0 + beq I008 + move.w -2(a6),-(sp) + move.w #117,-(sp) + move.w (sp)+,d0 + cmp (sp)+,d0 + bne I007 +I008: + move.l -6(a6),-(sp) + move.l (sp)+,a0 + add #2,a0 + move.l a0,-(sp) + move.l (sp),-(sp) + move.l (sp)+,-6(a6) + move.l (sp)+,a0 + move.w -2(a0),-(sp) + move.w (sp)+,-8(a6) + move.w -2(a6),-(sp) + move.w #100,-(sp) + move.w (sp)+,d0 + cmp (sp)+,d0 + bne I009 + move.w -8(a6),-(sp) + tst (sp)+ + bge I009 + move.w #0,-(sp) + move.w -8(a6),-(sp) + move.w (sp)+,d0 + move.w (sp)+,d1 + sub d0,d1 + move.w d1,-(sp) + move.w (sp)+,-8(a6) + move.w #45,-(sp) + jsr _putchar + add #2,sp +I009: + move.w -8(a6),-(sp) + jsr _printn + add #2,sp + jmp I004 +I007: + move.w -2(a6),-(sp) + move.w #115,-(sp) + move.w (sp)+,d0 + cmp (sp)+,d0 + bne I004 + move.l -6(a6),-(sp) + move.l (sp)+,a0 + add #4,a0 + move.l a0,-(sp) + move.l (sp),-(sp) + move.l (sp)+,-6(a6) + move.l (sp)+,a0 + move.l -4(a0),-(sp) + move.l (sp)+,-12(a6) +I00c: + move.l -12(a6),-(sp) + move.l (sp),-(sp) + move.l (sp)+,a0 + add #1,a0 + move.l a0,-(sp) + move.l (sp)+,-12(a6) + move.l (sp)+,a0 + clr d0 + move.b (a0),d0 + move.w d0,-(sp) + move.w (sp),-(sp) + move.w (sp)+,-2(a6) + tst (sp)+ + beq I004 + move.w -2(a6),-(sp) + jsr _putchar + add #2,sp + jmp I00c +I002: + unlk a6 + rts +_printn: + link a6,#-2 +.sect .data +_15: + .data2 12337 + .data2 12851 + .data2 13365 + .data2 13879 + .data2 14393 + .data2 0 +.sect .text + move.w 8+0(a6),-(sp) + move.w #10,-(sp) + move.w (sp)+,d0 + clr.l d1 + move.w (sp)+,d1 + divu d0,d1 + move.w d1,-(sp) + move.w (sp),-(sp) + move.w (sp)+,-2(a6) + tst (sp)+ + beq I013 + move.w -2(a6),-(sp) + jsr _printn + add #2,sp +I013: + pea _15 + move.w 8+0(a6),-(sp) + move.w #10,-(sp) + move.w (sp)+,d0 + clr.l d1 + move.w (sp)+,d1 + divu d0,d1 + swap d1 + move.w d1,-(sp) + move.w (sp)+,d0 + ext.l d0 + add.l (sp)+,d0 + move.l d0,-(sp) + move.l (sp)+,a0 + clr d0 + move.b (a0),d0 + move.w d0,-(sp) + jsr _putchar + add #2,sp + unlk a6 + rts diff --git a/mach/m68k2/libfp/Makefile b/mach/m68k2/libfp/Makefile new file mode 100644 index 00000000..37ab1e98 --- /dev/null +++ b/mach/m68k2/libfp/Makefile @@ -0,0 +1,22 @@ +EMHOME=../../.. +SUF=o +MAKEFILE=$(EMHOME)/mach/proto/fp/Makefile +MACHDEF="MACH=m68k2" "SUF=$(SUF)" "ASAR=aal" + +all: + make -f $(MAKEFILE) $(MACHDEF) all + +install: + make -f $(MAKEFILE) $(MACHDEF) install + +cmp: all + -../../compare FP_$(MACH).a tail_fp + +clean: + make -f $(MAKEFILE) $(MACHDEF) clean + +opr: + make pr | opr + +pr: + @pr Makefile diff --git a/mach/m68k2/libsys/Makefile b/mach/m68k2/libsys/Makefile new file mode 100644 index 00000000..1caeccd0 --- /dev/null +++ b/mach/m68k2/libsys/Makefile @@ -0,0 +1,28 @@ +# $Header$ +MACH=m68k2 +all: libmon_o.a head_em.o + +install: all + ../../install head_em.o head_em + ../../install libmon_o.a tail_mon + +cmp: all + -../../compare head_em.o head_em + -../../compare libmon_o.a tail_mon + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +head_em.o: head_em.s + $(MACH) -c -I../../../h head_em.s + +clean: + rm -f *.o libmon_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/m68k2/libsys/compmodule b/mach/m68k2/libsys/compmodule new file mode 100755 index 00000000..bfdaef6d --- /dev/null +++ b/mach/m68k2/libsys/compmodule @@ -0,0 +1,4 @@ +if m68k2 -c -L $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/m68k2/ncg/Makefile b/mach/m68k2/ncg/Makefile new file mode 100644 index 00000000..f5e2bda6 --- /dev/null +++ b/mach/m68k2/ncg/Makefile @@ -0,0 +1,197 @@ +# $Header$ + +EMHOME=../../.. +#preprocessor flags for table +TABLEFLAGS= +#cgg options +CGGFLAGS= + +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/ncg +CGG=$(EMHOME)/lib/ncgg +CPP=$(EMHOME)/lib/cpp +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/label.c $(CDIR)/main.c \ + $(CDIR)/move.c $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c \ + $(CDIR)/salloc.c $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o label.o \ + main.o move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +label.o: $(CDIR)/label.c + $(CC) -c $(CFLAGS) $(CDIR)/label.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + $(EMHOME)/mach/install cg + +cmp: all + -$(EMHOME)/mach/compare cg + + +tables.c: table $(CGG) + $(CPP) $(TABLEFLAGS) table | $(CGG) $(CGGFLAGS) + -cmp tables.h tables.H || cp tables.H tables.h + +lint: $(CFILES) tables.c + lint $(LINTOPTS) $(PREFLAGS) -I$(CDIR) $(CFILES) tables.c +clean: + rm -f *.o tables.c tables.h debug.out cg tables.H + +distr: tables.c + rm -f tables1.c tables1.h + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + +codegen.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/label.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +label.o: $(CDIR)/label.h +label.o: $(CDIR)/param.h +label.o: tables.h +label.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +main.o: tables.h +move.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/m68k2/ncg/table_link b/mach/m68k2/ncg/table_link new file mode 100644 index 00000000..226ca8c2 --- /dev/null +++ b/mach/m68k2/ncg/table_link @@ -0,0 +1 @@ +TABLE = mach/m68020/ncg/table diff --git a/mach/m68k2/top/Makefile b/mach/m68k2/top/Makefile new file mode 100644 index 00000000..57908427 --- /dev/null +++ b/mach/m68k2/top/Makefile @@ -0,0 +1,42 @@ +EMHOME=../../.. +LIBS=$(EMHOME)/modules/lib/libstring.a +PREFLAGS=-I. +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O -DNDEBUG +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +CDIR=$(EMHOME)/mach/proto/top +CFILES=$(CDIR)/top.c $(CDIR)/queue.c +OFILES=top.o queue.o + +all: gen.c + make top + +top: $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) $(LIBS) -o top + +top.o: $(CDIR)/top.c gen.c + $(CC) -c $(CFLAGS) $(CDIR)/top.c + +queue.o: $(CDIR)/queue.c + $(CC) -c $(CFLAGS) $(CDIR)/queue.c + +install: all + $(EMHOME)/mach/install top + +cmp: all + -$(EMHOME)/mach/compare top + +gen.c: table + $(EMHOME)/lib/topgen table + +lint: $(CFILES) + lint $(LINTOPTS) $(PREFLAGS) $(CFILES) + +clean: + rm -f *.o gen.c gen.h top + +top.o: gen.h +top.o: $(CDIR)/top.h +top.o: $(CDIR)/queue.h +queue.o: $(CDIR)/queue.h diff --git a/mach/m68k4/libem/Makefile b/mach/m68k4/libem/Makefile new file mode 100644 index 00000000..5457c453 --- /dev/null +++ b/mach/m68k4/libem/Makefile @@ -0,0 +1,33 @@ +# $Header$ +MACH=m68k4 +ASAR=aal +all: libem_o.a end.a + +install: all + ../../install libem_o.a tail_em + ../../install end.a end_em + +cmp: all + -../../compare libem_o.a tail_em + -../../compare end.a end_em + +end.a: em_end.s etext.s edata.s end.s + $(MACH) -I../../../h -c em_end.s + $(MACH) -I../../../h -c edata.s + $(MACH) -I../../../h -c etext.s + $(MACH) -I../../../h -c end.s + $(ASAR) cr end.a em_end.o etext.o edata.o end.o + +libem_o.a: libem_s.a + ASAR=$(ASAR) ; export ASAR ;\ + march . libem_o.a + +clean: + rm -f *.o libem_o.a end.a + +opr : + make pr | opr + +pr: + @arch pv libem_s.a | pr -h `pwd`/libem_s.a + @pr `pwd`/em_end.s `pwd`/edata.s `pwd`/etext.s `pwd`/end.s diff --git a/mach/m68k4/libem/aciaio.s b/mach/m68k4/libem/aciaio.s new file mode 100644 index 00000000..09577e1f --- /dev/null +++ b/mach/m68k4/libem/aciaio.s @@ -0,0 +1,36 @@ +.define .outch1,.outch2,.inch1,.inch2 +.sect .text +.sect .rom +.sect .data +.sect .bss + + ! a0,d0 used + ! character in d1 + + .sect .text +.inch1: + move.l #acia1,a0 + bra .inch +.inch2: + move.l #acia2,a0 +.inch: + move.b (a0),d1 + asr #1,d1 + bcc .inch + move.b 2(a0),d1 + and #0x7f,d1 + rts + +.outch1: + move.l #acia1,a0 + bra .outch +.outch2: + move.l #acia2,a0 +.outch: + move.b (a0),d0 + asr #2,d0 + bcc .outch + move.b d1,2(a0) + rts + +.align 2 diff --git a/mach/m68k4/libem/ara.s b/mach/m68k4/libem/ara.s new file mode 100644 index 00000000..e4e9ab19 --- /dev/null +++ b/mach/m68k4/libem/ara.s @@ -0,0 +1,101 @@ +.define .sar +.define .lar +.define .aar +.sect .text +.sect .rom +.sect .data +.sect .bss + + !register usage: + ! a0 : descriptor address + ! d0 : index + ! a1 : base address + .sect .text +.aar: + move.l 4(sp),a0 ! descriptor address + move.l 8(sp),d0 ! index + sub.l (a0),d0 ! index - lower bound : relative index + move.l 8(a0),-(sp) ! # bytes / element + move.l d0,-(sp) + jsr .mlu + move.l 12(sp),a1 ! base address + add.l d1,a1 ! address of element + move.l (sp)+,a0 ! return address + add.l #8,sp ! pop arguments + move.l a1,(sp) ! returned on stack + jmp (a0) + +.lar: + ! register usage: like .aar + + move.l 4(sp),a0 + move.l 8(sp),d0 + move.l 12(sp),a1 + sub.l (a0),d0 + move.l d0,-(sp) + move.l 8(a0),-(sp) + jsr .mlu + move.l 12(sp),a1 + move.l 4(sp),a0 + add.l d1,a1 ! address of element + move.l 8(a0),d0 + add.l d0,a1 ! a1++ because of predecrement + move.l (sp)+,a0 ! return address + add.l #12,sp ! pop parameters + clr.l d1 !?nodig? + asr #1,d0 + bne 3f + move.b -(a1),d1 ! 1 byte element + move.l d1,-(sp) + bra 5f +3: + asr #1,d0 + bne 4f + move.w -(a1),d1 ! 2 byte element + move.l d1,-(sp) + bra 5f +4: + sub.l #1,d0 +1: + move.l -(a1),-(sp) ! 4n byte element (n = 1,2,...) + dbf d0,1b +5: + jmp (a0) + +.sar: + !register usage: same as lar + + move.l 4(sp),a0 + move.l 8(sp),d0 + move.l 12(sp),a1 + sub.l (a0),d0 + move.l d0,-(sp) + move.l 8(a0),-(sp) + jsr .mlu + move.l 12(sp),a1 + move.l 4(sp),a0 + add.l d1,a1 + move.l 8(a0),d0 ! # bytes / element + move.l (sp)+,a0 ! return address + add.l #12,sp ! pop parameters + clr.l d1 !?nodig? + asr #1,d0 + bne 3f + move.l (sp)+,d1 + move.b d1,(a1) ! 1 byte element + bra 4f +3: + asr #1,d0 + bne 5f + move.l (sp)+,d1 + move.w d1,(a1) ! 2 byte element + bra 4f +5: + sub.l #1,d0 +1: + move.l (sp)+,(a1)+ ! 4n byte element (n = 1,2,...) + dbf d0,1b +4: + jmp (a0) + +.align 2 diff --git a/mach/m68k4/libem/ari.s b/mach/m68k4/libem/ari.s new file mode 100644 index 00000000..cefb0f66 --- /dev/null +++ b/mach/m68k4/libem/ari.s @@ -0,0 +1,36 @@ +.define .sari +.define .lari +.define .aari +.sect .text +.sect .rom +.sect .data +.sect .bss + + .sect .text +.aari: + move.l (sp)+,d0 ! return address + cmp.l #4, (sp)+ ! size of descriptor elements + bne 9f + move.l d0,-(sp) + jmp .aar + + +.lari: + move.l (sp)+,d0 ! return address + cmp.l #4, (sp)+ ! size of descriptor elements + bne 9f + move.l d0,-(sp) + jmp .lar +9: + move.w #EILLINS,-(sp) + jmp .fat + + +.sari: + move.l (sp)+,d0 ! return address + cmp.l #4, (sp)+ ! size of descriptor elements + bne 9b + move.l d0,-(sp) + jmp .sar + +.align 2 diff --git a/mach/m68k4/libem/compmodule b/mach/m68k4/libem/compmodule new file mode 100755 index 00000000..80f42aab --- /dev/null +++ b/mach/m68k4/libem/compmodule @@ -0,0 +1,4 @@ +if m68k4 -c $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/m68k4/libem/cvf.s b/mach/m68k4/libem/cvf.s new file mode 100644 index 00000000..74dcc928 --- /dev/null +++ b/mach/m68k4/libem/cvf.s @@ -0,0 +1,21 @@ +.define .cfi,.cif,.cfu,.cuf,.cff +.sect .text +.sect .rom +.sect .data +.sect .bss + + .sect .text + + ! this is a dummy float conversion routine +.cfi: +.cif: +.cfu: +.cuf: +.cff: + move.l (sp)+,a0 ! return address + move (sp)+,d0 ! destination size + sub (sp)+,d0 ! diff. in sizes + sub d0,sp + jmp (a0) + +.align 2 diff --git a/mach/m68k4/libem/edata.s b/mach/m68k4/libem/edata.s new file mode 100644 index 00000000..f53adc10 --- /dev/null +++ b/mach/m68k4/libem/edata.s @@ -0,0 +1,9 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _edata +.sect .data + .align 4 + .sect .data +_edata: diff --git a/mach/m68k4/libem/em_end.s b/mach/m68k4/libem/em_end.s new file mode 100644 index 00000000..a062368d --- /dev/null +++ b/mach/m68k4/libem/em_end.s @@ -0,0 +1,22 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define endtext,enddata,endbss,__end +.sect .text + .align 4 +.sect .rom + .align 4 +.sect .data + .align 4 +.sect .bss + .align 4 +.sect .end ! only for declaration of _end, __end and endbss. + + .sect .text +endtext: + .sect .data +enddata: + .sect .end +__end: +endbss: diff --git a/mach/m68k4/libem/end.s b/mach/m68k4/libem/end.s new file mode 100644 index 00000000..93a1e6e0 --- /dev/null +++ b/mach/m68k4/libem/end.s @@ -0,0 +1,7 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _end +.sect .end ! only for declaration of _end, __end and endbss. +_end: diff --git a/mach/m68k4/libem/etext.s b/mach/m68k4/libem/etext.s new file mode 100644 index 00000000..8c7453cb --- /dev/null +++ b/mach/m68k4/libem/etext.s @@ -0,0 +1,9 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _etext +.sect .text + .align 4 + .sect .text +_etext: diff --git a/mach/m68k4/libem/fakfp.s b/mach/m68k4/libem/fakfp.s new file mode 100644 index 00000000..1c039b65 --- /dev/null +++ b/mach/m68k4/libem/fakfp.s @@ -0,0 +1,39 @@ +.define .adf4, .adf8, .sbf4, .sbf8, .mlf4, .mlf8, .dvf4, .dvf8 +.define .ngf4, .ngf8, .fif4, .fif8, .fef4, .fef8 +.define .cif4, .cif8, .cuf4, .cuf8, .cfi, .cfu, .cff4, .cff8 +.define .cmf4, .cmf8 +.sect .text +.sect .rom +.sect .data +.sect .bss + +! $Header$ + + .sect .text +.adf4: +.adf8: +.sbf4: +.sbf8: +.mlf4: +.mlf8: +.dvf4: +.dvf8: +.ngf4: +.ngf8: +.fif4: +.fif8: +.fef4: +.fef8: +.cif4: +.cif8: +.cuf4: +.cuf8: +.cfi: +.cfu: +.cff4: +.cff8: +.cmf4: +.cmf8: + move.l #18,-(sp) + jsr .trp + rts diff --git a/mach/m68k4/libem/printf.s b/mach/m68k4/libem/printf.s new file mode 100644 index 00000000..b0fcbe9d --- /dev/null +++ b/mach/m68k4/libem/printf.s @@ -0,0 +1,88 @@ +.define _printf +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .bss +_getal: + .space 12 +_char: + .space 1 + .align 4 +.sect .data +hexs: + .ascii "0123456789abcdef" + .align 4 +.sect .text +_printf: + movem.l d0/d1/d2/a0/a1/a2/a3/a4/a5/a6, -(sp) + lea 44(sp), a6 ! a6 <- address of arguments + move.l (a6)+, a5 ! a5 <- address of format +next: move.b (a5)+, d0 + beq out + cmp.b #'%', d0 + beq procnt +put: move.l d0, -(sp) + jsr _putchar ! long argument on stack + tst.l (sp)+ + bra next + +procnt: move.b (a5)+, d0 + cmp.b #'d', d0 ! NOTE: %d means unsigned. + beq digit + cmp.b #'x', d0 + beq hex + cmp.b #'s', d0 + beq string + cmp.b #'%', d0 ! second % has to be printed. + beq put + tst.b -(a5) ! normal char should be printed + bra next + +string: move.l (a6)+, a2 ! a2 <- address of string +sloop: move.b (a2)+, d0 + beq next + move.l d0, -(sp) + jsr _putchar ! long argument on stack + tst.l (sp)+ + bra sloop + +digit: move.l (a6)+, d1 ! d1 <- integer + move.l #_getal+12, a2 ! a2 <- ptr to last part of buf + clr.b -(a2) ! stringterminator +1: + move.l d1,-(sp) + move.l #10,-(sp) + jsr .dvu ! d1 <- qotient; d0 <- remainder + add.l #'0', d0 + move.b d0, -(a2) + tst.l d1 ! if quotient = 0 then ready + bne 1b + bra sloop ! print digitstring. + +hex: move.l (a6)+, d1 ! d1 <- integer + move.l #_getal+12, a2 ! a2 <- ptr to last part of buf + clr.b -(a2) ! stringterminator + move.l #7, d2 ! loop control +1: move.l d1, d0 + and.l #15, d0 + move.l #hexs,a0 + add.l d0,a0 + move.b (a0), -(a2) ! hex digit + asr.l #4, d1 + dbf d2, 1b + bra sloop + +out: + movem.l (sp)+, d0/d1/d2/a0/a1/a2/a3/a4/a5/a6 + rts + + +_putchar: + move.l #1, -(sp) + pea 11(sp) + move.l #1, -(sp) + jsr _write + lea 12(sp), sp + rts +.align 2 diff --git a/mach/m68k4/libem/sav.s b/mach/m68k4/libem/sav.s new file mode 100644 index 00000000..5f29178c --- /dev/null +++ b/mach/m68k4/libem/sav.s @@ -0,0 +1,13 @@ +.define .savd0 +.define .savret +.define .savreg + +.data +.savd0: + .long 0 +.savret: + .long 0 +.savreg: + .space 128 +.text +.align 2 diff --git a/mach/m68k4/libem/sys1.s b/mach/m68k4/libem/sys1.s new file mode 100644 index 00000000..49a3d759 --- /dev/null +++ b/mach/m68k4/libem/sys1.s @@ -0,0 +1,62 @@ +.extern _errno +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .data +_errno: +.extern _lseek +.short 0 +.sect .text +_lseek: +link a6,#-0 +.sect .data +_13: +.short 29561 +.short 29489 +.short 11875 +.short 0 +.sect .text +move.l #_13,.filn +move.w #8,.lino +move.w #0,-(sp) +move.w #0,-(sp) +move.l (sp)+,d0 +unlk a6 +rts +.extern _close +_close: +link a6,#-0 +move.l #_13,.filn +move.w #12,.lino +move.w #0,-(sp) +move.w (sp)+,d0 +unlk a6 +rts +.extern _ioctl +_ioctl: +link a6,#-0 +move.l #_13,.filn +move.w #18,.lino +move.w #0,-(sp) +move.w (sp)+,d0 +unlk a6 +rts +.extern _read +_read: +link a6,#-0 +move.l #_13,.filn +move.w #24,.lino +move.w #-1,-(sp) +move.w (sp)+,d0 +unlk a6 +rts +.extern _open +_open: +link a6,#-0 +move.l #_13,.filn +move.w #30,.lino +move.w #-1,-(sp) +move.w (sp)+,d0 +unlk a6 +rts diff --git a/mach/m68k4/libem/sys2.s b/mach/m68k4/libem/sys2.s new file mode 100644 index 00000000..661f2fb5 --- /dev/null +++ b/mach/m68k4/libem/sys2.s @@ -0,0 +1,11 @@ +.extern _exit +.sect .text +.sect .rom +.sect .data +.sect .bss +! Fake system call for 68000 running MACSBUG + +.sect .text + +_exit: + jmp 0x0200f6 diff --git a/mach/m68k4/libfp/Makefile b/mach/m68k4/libfp/Makefile new file mode 100644 index 00000000..370c22bc --- /dev/null +++ b/mach/m68k4/libfp/Makefile @@ -0,0 +1,22 @@ +EMHOME=../../.. +SUF=o +MAKEFILE=$(EMHOME)/mach/proto/fp/Makefile +MACHDEF="MACH=m68k4" "SUF=$(SUF)" "ASAR=aal" + +all: + make -f $(MAKEFILE) $(MACHDEF) all + +install: + make -f $(MAKEFILE) $(MACHDEF) install + +cmp: all + -../../compare FP_$(MACH).a tail_fp + +clean: + make -f $(MAKEFILE) $(MACHDEF) clean + +opr: + make pr | opr + +pr: + @pr Makefile diff --git a/mach/m68k4/libsys/Makefile b/mach/m68k4/libsys/Makefile new file mode 100644 index 00000000..142afee5 --- /dev/null +++ b/mach/m68k4/libsys/Makefile @@ -0,0 +1,29 @@ +# $Header$ +MACH=m68k4 +all: libmon_o.a head_em.o + +install: all + ../../install head_em.o head_em + ../../install libmon_o.a tail_mon + + +cmp: all + -../../compare head_em.o head_em + -../../compare libmon_o.a tail_mon + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +head_em.o: head_em.s + $(MACH) -I../../../h -c head_em.s + +clean: + rm -f *.o libmon_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/m68k4/libsys/compmodule b/mach/m68k4/libsys/compmodule new file mode 100755 index 00000000..d80f03d4 --- /dev/null +++ b/mach/m68k4/libsys/compmodule @@ -0,0 +1,4 @@ +if m68k4 -L -c $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/m68k4/ncg/Makefile b/mach/m68k4/ncg/Makefile new file mode 100644 index 00000000..f5e2bda6 --- /dev/null +++ b/mach/m68k4/ncg/Makefile @@ -0,0 +1,197 @@ +# $Header$ + +EMHOME=../../.. +#preprocessor flags for table +TABLEFLAGS= +#cgg options +CGGFLAGS= + +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/ncg +CGG=$(EMHOME)/lib/ncgg +CPP=$(EMHOME)/lib/cpp +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/label.c $(CDIR)/main.c \ + $(CDIR)/move.c $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c \ + $(CDIR)/salloc.c $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o label.o \ + main.o move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +label.o: $(CDIR)/label.c + $(CC) -c $(CFLAGS) $(CDIR)/label.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + $(EMHOME)/mach/install cg + +cmp: all + -$(EMHOME)/mach/compare cg + + +tables.c: table $(CGG) + $(CPP) $(TABLEFLAGS) table | $(CGG) $(CGGFLAGS) + -cmp tables.h tables.H || cp tables.H tables.h + +lint: $(CFILES) tables.c + lint $(LINTOPTS) $(PREFLAGS) -I$(CDIR) $(CFILES) tables.c +clean: + rm -f *.o tables.c tables.h debug.out cg tables.H + +distr: tables.c + rm -f tables1.c tables1.h + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + +codegen.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/label.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +label.o: $(CDIR)/label.h +label.o: $(CDIR)/param.h +label.o: tables.h +label.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +main.o: tables.h +move.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/mantra/cv/Makefile b/mach/mantra/cv/Makefile new file mode 100644 index 00000000..5b237fcf --- /dev/null +++ b/mach/mantra/cv/Makefile @@ -0,0 +1,30 @@ +EMHOME = ../../.. +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +INCLUDE = $(EMHOME)/h +CFLAGS = -I. -I$(INCLUDE) -O +TARGETS = cv Xcv + +all: $(TARGETS) + +install: all + ../../install cv + ../../install Xcv + +cmp: all + ../../compare cv + ../../compare Xcv + +cv: cv.o + $(CC) $(LDFLAGS) -o cv cv.o $(LIBOBJ) + +Xcv: Xcv.o + $(CC) $(LDFLAGS) -o Xcv Xcv.o $(LIBOBJ) + +clean: + rm -f $(TARGETS) *.o nohup.out Out + +pr: + @pr Makefile cv.c Xcv.c + +opr: + make pr | opr diff --git a/mach/mantra/int/Makefile b/mach/mantra/int/Makefile new file mode 100644 index 00000000..71ef3cc1 --- /dev/null +++ b/mach/mantra/int/Makefile @@ -0,0 +1,81 @@ +EMHOME=../../.. +INTS=em2_t--- em2_---- em2_t-cp em2_t-c- em2_t--p \ +em4_t--- em4_---- em4_t-cp em4_t-c- em4_t--p +P = mloop +FILES=deffile $P0 $P1 $P2 $P3 $P4 $P5 $P6 $P7 $P8 $P9 $Pa $Pb $Pc +CPP=$(EMHOME)/lib/cpp +b=$(EMHOME)/lib/em +CFLAGS=-I$(EMHOME)/h -O +FLTRAP= + +all: $(INTS) em + +em: em.c + $(CC) $(CFLAGS) -o em em.c + +tmp.s: $(FILES) + cat $(FILES) > tmp.s + +em2_t---: tmp.s compile con_float.o + ./compile -o em2_t--- -P $(FLTRAP) -Dopfreq=0 -Dlast=1 -Dcount=0 -Dtest=1 -Dflow=0 -Dprof=0 tmp.s con_float.o + +em2_----: tmp.s compile con_float.o + ./compile -o em2_---- -P $(FLTRAP) -Dopfreq=0 -Dlast=0 -Dcount=0 -Dtest=0 -Dflow=0 -Dprof=0 tmp.s con_float.o + +em2_t-cp: tmp.s compile con_float.o + ./compile -o em2_t-cp -P $(FLTRAP) -Dopfreq=0 -Dlast=1 -Dcount=1 -Dtest=1 -Dflow=0 -Dprof=1 tmp.s con_float.o + +em2_t-c-: tmp.s compile con_float.o + ./compile -o em2_t-c- -P $(FLTRAP) -Dopfreq=0 -Dlast=1 -Dcount=1 -Dtest=1 -Dflow=0 -Dprof=0 tmp.s con_float.o + +em2_t--p: tmp.s compile con_float.o + ./compile -o em2_t--p -P $(FLTRAP) -Dopfreq=0 -Dlast=1 -Dcount=0 -Dtest=1 -Dflow=0 -Dprof=1 tmp.s con_float.o + +em4_t---: tmp.s compile con_float.o + ./compile -o em4_t--- -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=1 -Dcount=0 -Dtest=1 -Dflow=0 -Dprof=0 tmp.s con_float.o + +em4_----: tmp.s compile con_float.o + ./compile -o em4_---- -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=0 -Dcount=0 -Dtest=0 -Dflow=0 -Dprof=0 tmp.s con_float.o + +em4_t-cp: tmp.s compile con_float.o + ./compile -o em4_t-cp -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=1 -Dcount=1 -Dtest=1 -Dflow=0 -Dprof=1 tmp.s con_float.o + +em4_t-c-:tmp.s compile con_float.o + ./compile -o em4_t-c- -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=1 -Dcount=1 -Dtest=1 -Dflow=0 -Dprof=0 tmp.s con_float.o + +em4_t--p: tmp.s compile con_float.o + ./compile -o em4_t--p -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=1 -Dcount=0 -Dtest=1 -Dflow=0 -Dprof=1 tmp.s con_float.o + +con_float.o: con_float.c + case `ack_sys` in m68k2|pmds) \ + acc -I$(EMHOME)/mach -mm68k4 -c -L -O con_float.c;; \ + *) acc -c -I$(EMHOME)/mach -L -O con_float.c;; \ + esac + +compile: Makefile + case `ack_sys` in sun*) MACH=`ack_sys`; AS=-Ras=../../../lib/m68k2/as;; pmds*) MACH=pmds4;; \ + m68_sysV_0) MACH=mantra;; \ + *) MACH=m68k4;; \ + esac ; echo $$MACH $$AS -r.c -.m -fp '$$*' > compile; chmod +x compile +install: all + -mkdir $b24 $b44 + ls em2_???? | sed 's:em2_\(.*\):cp & $b24/em_\1:' | sh + ls em4_???? | sed 's:em4_\(.*\):cp & $b44/em_\1:' | sh + cp em ../../../bin/em + cp em.1 ../../../man/em.1 + +cmp: all + ls em2_???? | sed 's:em2_\(.*\):cmp & $b24/em_\1:' | sh + ls em4_???? | sed 's:em4_\(.*\):cmp & $b44/em_\1:' | sh + -cmp em ../../../bin/em + -cmp em.1 ../../../man/em.1 + +clean: + -rm -f *.o *.old a.out em tmp.s $(INTS) compile + +opr: + make pr | opr + +pr: + @pr `pwd`/makefile + @pr `pwd`/deffile `pwd`/$P? diff --git a/mach/mantra/int/header b/mach/mantra/int/header new file mode 100644 index 00000000..ff0fa03e --- /dev/null +++ b/mach/mantra/int/header @@ -0,0 +1,8 @@ +!definitions +!#define lword +!#define FLTRAP +#define opfreq 0 +#define last 1 +#define test 1 +#define count 0 +#define flow 0 diff --git a/mach/mantra/int/mloope b/mach/mantra/int/mloope new file mode 100644 index 00000000..9507ea16 --- /dev/null +++ b/mach/mantra/int/mloope @@ -0,0 +1,11 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + .sect .text +end: + .sect .bss +endbss: + .sect .data +enddata: diff --git a/mach/mantra/int/prep b/mach/mantra/int/prep new file mode 100755 index 00000000..4f4c4199 --- /dev/null +++ b/mach/mantra/int/prep @@ -0,0 +1,3 @@ +rm -f temp.c +cat header deffile $1 >> temp.c +../../../lib/cpp -P temp.c >$2 diff --git a/mach/mantra/libsys/Makefile b/mach/mantra/libsys/Makefile new file mode 100644 index 00000000..142afee5 --- /dev/null +++ b/mach/mantra/libsys/Makefile @@ -0,0 +1,29 @@ +# $Header$ +MACH=m68k4 +all: libmon_o.a head_em.o + +install: all + ../../install head_em.o head_em + ../../install libmon_o.a tail_mon + + +cmp: all + -../../compare head_em.o head_em + -../../compare libmon_o.a tail_mon + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +head_em.o: head_em.s + $(MACH) -I../../../h -c head_em.s + +clean: + rm -f *.o libmon_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/mantra/libsys/compmodule b/mach/mantra/libsys/compmodule new file mode 100755 index 00000000..48038e37 --- /dev/null +++ b/mach/mantra/libsys/compmodule @@ -0,0 +1,4 @@ +if mantra -c -L $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/minix/libsys/Makefile b/mach/minix/libsys/Makefile new file mode 100644 index 00000000..9a200749 --- /dev/null +++ b/mach/minix/libsys/Makefile @@ -0,0 +1,40 @@ +# $Header$ +MACH=minix + +all: libsys_o.a end.o head_em.o + +install: all + ../../install libsys_o.a tail_mon + ../../install head_em.o head_em + ../../install end.o end_em + +cmp: all + -../../compare libsys_o.a tail_mon + -../../compare head_em.o head_em + -../../compare end.o end_em + + +end.o: end.s + $(MACH) -I../../../h -O -c end.s + +head_em.o: head_em.s + $(MACH) -I../../../h -O -c head_em.s + +libsys.a: libsys_s.a + ASAR=aal ; export ASAR ;\ + march . libsys.a + +libsys_o.a: libsys.a ../../../lib/i86/tail_em + mkdir X; cd X; aal x ../../../../lib/i86/tail_em; aal x ../libsys.a; aal rv ../libsys_o.a *.o ; cd .. + rm -rf X + +clean: + rm -f *.o libsys_o.a libsys.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libsys.a | pr -h `pwd`/libsys.a + @pr `pwd`/end.s diff --git a/mach/minix/libsys/access.c b/mach/minix/libsys/access.c new file mode 100644 index 00000000..23a22dd3 --- /dev/null +++ b/mach/minix/libsys/access.c @@ -0,0 +1,9 @@ +#include "lib.h" + +PUBLIC int access(name, mode) +char *name; +int mode; +{ + return callm3(FS, ACCESS, mode, name); + +} diff --git a/mach/minix/libsys/alarm.c b/mach/minix/libsys/alarm.c new file mode 100644 index 00000000..9be91a8d --- /dev/null +++ b/mach/minix/libsys/alarm.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int alarm(sec) +unsigned sec; +{ + return callm1(MM, ALARM, (int) sec, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minix/libsys/brk.c b/mach/minix/libsys/brk.c new file mode 100644 index 00000000..f6a03772 --- /dev/null +++ b/mach/minix/libsys/brk.c @@ -0,0 +1,34 @@ +#include "lib.h" + +extern char *brksize; + +PUBLIC char *brk(addr) +char *addr; +{ + int k; + + k = callm1(MM, BRK, 0, 0, 0, addr, NIL_PTR, NIL_PTR); + if (k == OK) { + brksize = M.m2_p1; + return(NIL_PTR); + } else { + return( (char*) -1 ); + } +} + + +PUBLIC char *sbrk(incr) +int incr; +{ + char *newsize, *oldsize; + + oldsize = brksize; + newsize = brksize + incr; + if (incr > 0 && newsize < oldsize || incr < 0 && newsize > oldsize) + return( (char *) -1); + if (brk(newsize) == 0) + return(oldsize); + else + return( (char *) -1 ); +} + diff --git a/mach/minix/libsys/chdir.c b/mach/minix/libsys/chdir.c new file mode 100644 index 00000000..357a979c --- /dev/null +++ b/mach/minix/libsys/chdir.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int chdir(name) +char *name; +{ + return callm3(FS, CHDIR, 0, name); + +} diff --git a/mach/minix/libsys/chmod.c b/mach/minix/libsys/chmod.c new file mode 100644 index 00000000..7ae3edad --- /dev/null +++ b/mach/minix/libsys/chmod.c @@ -0,0 +1,9 @@ +#include "lib.h" + +PUBLIC int chmod(name, mode) +char* name; +int mode; +{ + return callm3(FS, CHMOD, mode, name); + +} diff --git a/mach/minix/libsys/chown.c b/mach/minix/libsys/chown.c new file mode 100644 index 00000000..0846102c --- /dev/null +++ b/mach/minix/libsys/chown.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int chown(name, owner, grp) +char *name; +int owner, grp; +{ + return callm1(FS, CHOWN, len(name), owner, grp, name, NIL_PTR, NIL_PTR); +} diff --git a/mach/minix/libsys/chroot.c b/mach/minix/libsys/chroot.c new file mode 100644 index 00000000..520abaf1 --- /dev/null +++ b/mach/minix/libsys/chroot.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int chroot(name) +char* name; +{ + return callm3(FS, CHROOT, 0, name); + +} diff --git a/mach/minix/libsys/close.c b/mach/minix/libsys/close.c new file mode 100644 index 00000000..72698b0b --- /dev/null +++ b/mach/minix/libsys/close.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int close(fd) +int fd; +{ + return callm1(FS, CLOSE, fd, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + +} diff --git a/mach/minix/libsys/compmodule b/mach/minix/libsys/compmodule new file mode 100755 index 00000000..b622ec57 --- /dev/null +++ b/mach/minix/libsys/compmodule @@ -0,0 +1,4 @@ +if minix -c -L -LIB $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/minix/libsys/creat.c b/mach/minix/libsys/creat.c new file mode 100644 index 00000000..f9c13607 --- /dev/null +++ b/mach/minix/libsys/creat.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int creat(name, mode) +char* name; +int mode; +{ + return callm3(FS, CREAT, mode, name); +} diff --git a/mach/minix/libsys/dup.c b/mach/minix/libsys/dup.c new file mode 100644 index 00000000..f8683ea9 --- /dev/null +++ b/mach/minix/libsys/dup.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int dup(fd) +int fd; +{ + return callm1(FS, DUP, fd, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minix/libsys/dup2.c b/mach/minix/libsys/dup2.c new file mode 100644 index 00000000..67e7c3da --- /dev/null +++ b/mach/minix/libsys/dup2.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int dup2(fd, fd2) +int fd, fd2; +{ + return callm1(FS, DUP, fd+0100, fd2, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minix/libsys/end.s b/mach/minix/libsys/end.s new file mode 100644 index 00000000..6b9ce418 --- /dev/null +++ b/mach/minix/libsys/end.s @@ -0,0 +1,17 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define endtext,enddata,endbss +.define _end,_etext,_edata + + ! $Header$ + .sect .text +endtext: +_etext: + .align 2 + .sect .data +enddata: +_edata: + .align 2 +.sect .endsect +_end: +endbss: + .align 2 diff --git a/mach/minix/libsys/exec.c b/mach/minix/libsys/exec.c new file mode 100644 index 00000000..cb2be552 --- /dev/null +++ b/mach/minix/libsys/exec.c @@ -0,0 +1,103 @@ +#include "lib.h" + +extern char **environ; /* environment pointer */ + +#define PTRSIZE sizeof(char *) + +PUBLIC int execl(name, arg0) +char *name; +char *arg0; +{ + return execve(name, &arg0, environ); +} + +PUBLIC int execle(name, argv) +char *name, *argv; +{ + char **p; + p = (char **) &argv; + while (*p++) /* null statement */ ; + return execve(name, &argv, *p); +} + +PUBLIC int execv(name, argv) +char *name, *argv[]; +{ + return execve(name, argv, environ); +} + + +PUBLIC int execve(name, argv, envp) +char *name; /* pointer to name of file to be executed */ +char *argv[]; /* pointer to argument array */ +char *envp[]; /* pointer to environment */ +{ + char stack[MAX_ISTACK_BYTES]; + char **argorg, **envorg, *hp, **ap, *p; + int i, nargs, nenvps, stackbytes, offset; + extern errno; + + /* Count the argument pointers and environment pointers. */ + nargs = 0; + nenvps = 0; + argorg = argv; + envorg = envp; + while (*argorg++ != NIL_PTR) nargs++; + while (*envorg++ != NIL_PTR) nenvps++; + + /* Prepare to set up the initial stack. */ + hp = &stack[(nargs + nenvps + 3) * PTRSIZE]; + if (hp + nargs + nenvps >= &stack[MAX_ISTACK_BYTES]) { + errno = E2BIG; + return(-1); + } + ap = (char **) stack; + *ap++ = (char *) nargs; + + /* Prepare the argument pointers and strings. */ + for (i = 0; i < nargs; i++) { + offset = hp - stack; + *ap++ = (char *) offset; + p = *argv++; + while (*p) { + *hp++ = *p++; + if (hp >= &stack[MAX_ISTACK_BYTES]) { + errno = E2BIG; + return(-1); + } + } + *hp++ = (char) 0; + } + *ap++ = NIL_PTR; + + /* Prepare the environment pointers and strings. */ + for (i = 0; i < nenvps; i++) { + offset = hp - stack; + *ap++ = (char *) offset; + p = *envp++; + while (*p) { + *hp++ = *p++; + if (hp >= &stack[MAX_ISTACK_BYTES]) { + errno = E2BIG; + return(-1); + } + } + *hp++ = (char) 0; + } + *ap++ = NIL_PTR; + stackbytes = ( ( (int)(hp - stack) + PTRSIZE - 1)/PTRSIZE) * PTRSIZE; + return callm1(MM_PROC_NR, EXEC, len(name), stackbytes, 0,name, stack,NIL_PTR); +} + + +PUBLIC execn(name) +char *name; /* pointer to file to be exec'd */ +{ +/* Special version used when there are no args and no environment. This call + * is principally used by INIT, to avoid having to allocate MAX_ISTACK_BYTES. + */ + + static char stack[3 * PTRSIZE]; + + return callm1(MM_PROC_NR, EXEC, len(name), sizeof(stack), 0, name, stack, NIL_PTR); +} diff --git a/mach/minix/libsys/fork.c b/mach/minix/libsys/fork.c new file mode 100644 index 00000000..7d5c0fc5 --- /dev/null +++ b/mach/minix/libsys/fork.c @@ -0,0 +1,6 @@ +#include "lib.h" + +PUBLIC int fork() +{ + return callm1(MM, FORK, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minix/libsys/fstat.c b/mach/minix/libsys/fstat.c new file mode 100644 index 00000000..8fb6d665 --- /dev/null +++ b/mach/minix/libsys/fstat.c @@ -0,0 +1,10 @@ +#include "lib.h" + +PUBLIC int fstat(fd, buffer) +int fd; +char *buffer; +{ + int n; + n = callm1(FS, FSTAT, fd, 0, 0, buffer, NIL_PTR, NIL_PTR); + return(n); +} diff --git a/mach/minix/libsys/getegid.c b/mach/minix/libsys/getegid.c new file mode 100644 index 00000000..e4166916 --- /dev/null +++ b/mach/minix/libsys/getegid.c @@ -0,0 +1,9 @@ +#include "lib.h" + +PUBLIC gid getegid() +{ + int k; + k = callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (k < 0) return ( (gid) k); + return( (gid) M.m2_i1); +} diff --git a/mach/minix/libsys/geteuid.c b/mach/minix/libsys/geteuid.c new file mode 100644 index 00000000..172f3dfd --- /dev/null +++ b/mach/minix/libsys/geteuid.c @@ -0,0 +1,9 @@ +#include "lib.h" + +PUBLIC uid geteuid() +{ + int k; + k = callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (k < 0) return ( (uid) k); + return ((uid) M.m2_i1); +} diff --git a/mach/minix/libsys/getgid.c b/mach/minix/libsys/getgid.c new file mode 100644 index 00000000..78fc92ac --- /dev/null +++ b/mach/minix/libsys/getgid.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC gid getgid() +{ + int k; + k = callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + return( (gid) k); +} diff --git a/mach/minix/libsys/getpid.c b/mach/minix/libsys/getpid.c new file mode 100644 index 00000000..43ab9dda --- /dev/null +++ b/mach/minix/libsys/getpid.c @@ -0,0 +1,6 @@ +#include "lib.h" + +PUBLIC int getpid() +{ + return callm1(MM, GETPID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minix/libsys/getuid.c b/mach/minix/libsys/getuid.c new file mode 100644 index 00000000..44801a36 --- /dev/null +++ b/mach/minix/libsys/getuid.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC uid getuid() +{ + int k; + k = callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + return( (uid) k); +} diff --git a/mach/minix/libsys/gtty.c b/mach/minix/libsys/gtty.c new file mode 100644 index 00000000..8916d9b4 --- /dev/null +++ b/mach/minix/libsys/gtty.c @@ -0,0 +1,9 @@ +#include + +gtty(fd, argp) +int fd; +char *argp; +{ + return ioctl(fd, TIOCGETP, argp); +} + diff --git a/mach/minix/libsys/ioctl.c b/mach/minix/libsys/ioctl.c new file mode 100644 index 00000000..fbd0658f --- /dev/null +++ b/mach/minix/libsys/ioctl.c @@ -0,0 +1,68 @@ +#include "lib.h" +#include +#include + +PUBLIC int ioctl(fd, request, u) +int fd; +int request; +union { + struct sgttyb *argp; + struct tchars *argt; +} u; + +{ + int n, ispeed, ospeed; + long erase, kill, intr, quit, xon, xoff, eof, brk, speed; + + M.TTY_REQUEST = request; + M.TTY_LINE = fd; + + switch(request) { + case TIOCSETP: + erase = u.argp->sg_erase & BYTE; + kill = u.argp->sg_kill & BYTE; + M.TTY_SPEK = (erase << 8) | kill; + M.TTY_FLAGS = u.argp->sg_flags; + M.TTY_SPEED = (u.argp->sg_ospeed << 8) | u.argp->sg_ispeed; + n = callx(FS, IOCTL); + return(n); + + case TIOCSETC: + intr = u.argt->t_intrc & BYTE; + quit = u.argt->t_quitc & BYTE; + xon = u.argt->t_startc & BYTE; + xoff = u.argt->t_stopc & BYTE; + eof = u.argt->t_eofc & BYTE; + brk = u.argt->t_brkc & BYTE; /* not used at the moment */ + M.TTY_SPEK = (intr<<24) | (quit<<16) | (xon<<8) | (xoff<<0); + M.TTY_FLAGS = (eof<<8) | (brk<<0); + n = callx(FS, IOCTL); + return(n); + + case TIOCGETP: + n = callx(FS, IOCTL); + u.argp->sg_erase = (M.TTY_SPEK >> 8) & BYTE; + u.argp->sg_kill = (M.TTY_SPEK >> 0) & BYTE; + u.argp->sg_flags = M.TTY_FLAGS & 0xFFFF; + speed = (M.TTY_FLAGS >> 16) & 0xFFFFL; + u.argp->sg_ispeed = speed & BYTE; + u.argp->sg_ospeed = (speed >> 8) & BYTE; + return(n); + + case TIOCGETC: + n = callx(FS, IOCTL); + u.argt->t_intrc = (M.TTY_SPEK >> 24) & BYTE; + u.argt->t_quitc = (M.TTY_SPEK >> 16) & BYTE; + u.argt->t_startc = (M.TTY_SPEK >> 8) & BYTE; + u.argt->t_stopc = (M.TTY_SPEK >> 0) & BYTE; + u.argt->t_eofc = (M.TTY_FLAGS >> 8) & BYTE; + u.argt->t_brkc = (M.TTY_FLAGS >> 8) & BYTE; + return(n); + + default: + n = -1; + errno = -(EINVAL); + return(n); + } +} + diff --git a/mach/minix/libsys/kill.c b/mach/minix/libsys/kill.c new file mode 100644 index 00000000..db106541 --- /dev/null +++ b/mach/minix/libsys/kill.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int kill(proc, sig) +int proc; /* which process is to be sent the signal */ +int sig; /* signal number */ +{ + return callm1(MM, KILL, proc, sig, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minix/libsys/lib.h b/mach/minix/libsys/lib.h new file mode 100644 index 00000000..32c25c78 --- /dev/null +++ b/mach/minix/libsys/lib.h @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +extern message M; + +#define MM 0 +#define FS 1 + +extern int callm1(), callm3(), callx(), len(); +extern int errno; +extern int begsig(); /* interrupts all vector here */ diff --git a/mach/minix/libsys/link.c b/mach/minix/libsys/link.c new file mode 100644 index 00000000..9daee380 --- /dev/null +++ b/mach/minix/libsys/link.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int link(name, name2) +char *name, *name2; +{ + return callm1(FS, LINK, len(name), len(name2), 0, name, name2, NIL_PTR); +} diff --git a/mach/minix/libsys/lseek.c b/mach/minix/libsys/lseek.c new file mode 100644 index 00000000..ffcf165d --- /dev/null +++ b/mach/minix/libsys/lseek.c @@ -0,0 +1,15 @@ +#include "lib.h" + +PUBLIC long lseek(fd, offset, whence) +int fd; +long offset; +int whence; +{ + int k; + M.m2_i1 = fd; + M.m2_l1 = offset; + M.m2_i2 = whence; + k = callx(FS, LSEEK); + if (k != OK) return( (long) k); /* send itself failed */ + return(M.m2_l1); +} diff --git a/mach/minix/libsys/mknod.c b/mach/minix/libsys/mknod.c new file mode 100644 index 00000000..7dbfeca1 --- /dev/null +++ b/mach/minix/libsys/mknod.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int mknod(name, mode, addr) +char *name; +int mode, addr; +{ + return callm1(FS, MKNOD, len(name), mode, addr, name, NIL_PTR, NIL_PTR); +} diff --git a/mach/minix/libsys/mktemp.c b/mach/minix/libsys/mktemp.c new file mode 100644 index 00000000..e29e5c93 --- /dev/null +++ b/mach/minix/libsys/mktemp.c @@ -0,0 +1,20 @@ +/* mktemp - make a name for a temporary file */ + +char *mktemp(template) +char *template; +{ + int pid, k; + char *p; + + pid = getpid(); /* get process id as semi-unique number */ + p = template; + while (*p++) ; /* find end of string */ + p--; /* backup to last character */ + + /* Replace XXXXXX at end of template with pid. */ + while (*--p == 'X') { + *p = '0' + (pid % 10); + pid = pid/10; + } + return(template); +} diff --git a/mach/minix/libsys/mount.c b/mach/minix/libsys/mount.c new file mode 100644 index 00000000..258276b4 --- /dev/null +++ b/mach/minix/libsys/mount.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int mount(special, name, rwflag) +char *name, *special; +int rwflag; +{ + return callm1(FS, MOUNT, len(special), len(name), rwflag, special, name, NIL_PTR); +} diff --git a/mach/minix/libsys/open.c b/mach/minix/libsys/open.c new file mode 100644 index 00000000..228173d7 --- /dev/null +++ b/mach/minix/libsys/open.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int open(name, mode) +char* name; +int mode; +{ + return callm3(FS, OPEN, mode, name); +} diff --git a/mach/minix/libsys/pause.c b/mach/minix/libsys/pause.c new file mode 100644 index 00000000..2a0d1f69 --- /dev/null +++ b/mach/minix/libsys/pause.c @@ -0,0 +1,6 @@ +#include "lib.h" + +PUBLIC int pause() +{ + return callm1(MM, PAUSE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minix/libsys/pipe.c b/mach/minix/libsys/pipe.c new file mode 100644 index 00000000..05058808 --- /dev/null +++ b/mach/minix/libsys/pipe.c @@ -0,0 +1,14 @@ +#include "lib.h" + +PUBLIC int pipe(fild) +int fild[2]; +{ + int k; + k = callm1(FS, PIPE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (k >= 0) { + fild[0] = M.m1_i1; + fild[1] = M.m1_i2; + return(0); + } else + return(k); +} diff --git a/mach/minix/libsys/read.c b/mach/minix/libsys/read.c new file mode 100644 index 00000000..1619a4da --- /dev/null +++ b/mach/minix/libsys/read.c @@ -0,0 +1,11 @@ +#include "lib.h" + +PUBLIC int read(fd, buffer, nbytes) +int fd; +char *buffer; +int nbytes; +{ + int n; + n = callm1(FS, READ, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR); + return(n); +} diff --git a/mach/minix/libsys/setgid.c b/mach/minix/libsys/setgid.c new file mode 100644 index 00000000..823e8788 --- /dev/null +++ b/mach/minix/libsys/setgid.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int setgid(grp) +int grp; +{ + return callm1(MM, SETGID, grp, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minix/libsys/setuid.c b/mach/minix/libsys/setuid.c new file mode 100644 index 00000000..c53e0e3c --- /dev/null +++ b/mach/minix/libsys/setuid.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int setuid(usr) +int usr; +{ + return callm1(MM, SETUID, usr, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minix/libsys/signal.c b/mach/minix/libsys/signal.c new file mode 100644 index 00000000..4c5167cb --- /dev/null +++ b/mach/minix/libsys/signal.c @@ -0,0 +1,28 @@ +#include "lib.h" +#include + +int (*vectab[NSIG])(); /* array of functions to catch signals */ + +/* The definition of signal really should be + * PUBLIC int (*signal(signr, func))() + * but some compilers refuse to accept this, even though it is correct. + * The only thing to do if you are stuck with such a defective compiler is + * change it to + * PUBLIC int *signal(signr, func) + * and change ../h/signal.h accordingly. + */ + +PUBLIC int (*signal(signr, func))() +int signr; /* which signal is being set */ +int (*func)(); /* pointer to function that catches signal */ +{ + int r,(*old)(); + + old = vectab[signr - 1]; + vectab[signr - 1] = func; + M.m6_i1 = signr; + M.m6_f1 = ( (func == SIG_IGN || func == SIG_DFL) ? func : begsig); + r = callx(MM, SIGNAL); + if (r == 1) old = SIG_IGN; + return( (r < 0 ? (int (*)()) r : old) ); +} diff --git a/mach/minix/libsys/stat.c b/mach/minix/libsys/stat.c new file mode 100644 index 00000000..ae7b446f --- /dev/null +++ b/mach/minix/libsys/stat.c @@ -0,0 +1,10 @@ +#include "lib.h" + +PUBLIC int stat(name, buffer) +char *name; +char *buffer; +{ + int n; + n = callm1(FS, STAT, len(name), 0, 0, name, buffer, NIL_PTR); + return(n); +} diff --git a/mach/minix/libsys/stderr.c b/mach/minix/libsys/stderr.c new file mode 100644 index 00000000..7910f77e --- /dev/null +++ b/mach/minix/libsys/stderr.c @@ -0,0 +1,8 @@ +std_err(s) +char *s; +{ + char *p = s; + + while(*p != 0) p++; + write(2, s, (int)(p - s)); +} diff --git a/mach/minix/libsys/stime.c b/mach/minix/libsys/stime.c new file mode 100644 index 00000000..548ac37c --- /dev/null +++ b/mach/minix/libsys/stime.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int stime(top) +long *top; +{ + M.m2_l1 = *top; + return callx(FS, STIME); +} diff --git a/mach/minix/libsys/stty.c b/mach/minix/libsys/stty.c new file mode 100644 index 00000000..7dfe3db3 --- /dev/null +++ b/mach/minix/libsys/stty.c @@ -0,0 +1,9 @@ +#include + +stty(fd, argp) +int fd; +char *argp; +{ + return ioctl(fd, TIOCSETP, argp); +} + diff --git a/mach/minix/libsys/sync.c b/mach/minix/libsys/sync.c new file mode 100644 index 00000000..4592d28c --- /dev/null +++ b/mach/minix/libsys/sync.c @@ -0,0 +1,6 @@ +#include "lib.h" + +PUBLIC int sync() +{ + return callm1(FS, SYNC, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minix/libsys/time.c b/mach/minix/libsys/time.c new file mode 100644 index 00000000..e34e1f24 --- /dev/null +++ b/mach/minix/libsys/time.c @@ -0,0 +1,13 @@ +#include "lib.h" + +PUBLIC long time(tp) +long *tp; +{ + int k; + long l; + k = callm1(FS, TIME, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (M.m_type < 0 || k != OK) {errno = -M.m_type; return(-1L);} + l = M.m2_l1; + if (tp != (long *) 0) *tp = l; + return(l); +} diff --git a/mach/minix/libsys/times.c b/mach/minix/libsys/times.c new file mode 100644 index 00000000..77515d69 --- /dev/null +++ b/mach/minix/libsys/times.c @@ -0,0 +1,15 @@ +#include "lib.h" +#include +#include + +PUBLIC int times(buf) +struct tms *buf; +{ + int k; + k = callm1(FS, TIMES, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + buf->tms_utime = M.m4_l1; + buf->tms_stime = M.m4_l2; + buf->tms_cutime = M.m4_l3; + buf->tms_cstime = M.m4_l4; + return(k); +} diff --git a/mach/minix/libsys/trp.s b/mach/minix/libsys/trp.s new file mode 100644 index 00000000..1aac8b77 --- /dev/null +++ b/mach/minix/libsys/trp.s @@ -0,0 +1,114 @@ +.sect .text ; .sect .rom; .sect .data; .sect .bss +.define .trpdivz +.define .trpilin +.define .trpcase +.define .trprang +.define .trpset +.define .trpnofp +.define .trpheap +.define .trp +.define .stop + +.sect .text +.extern .trpdivz +.extern .trpilin +.extern .trpcase +.extern .trprang +.extern .trpset +.extern .trpnofp +.extern .trpheap +.extern .trp + +.trpdivz: +mov ax,6 +mov dx,.Mdivz +jmp .Trp +.trpilin: +mov ax,18 +mov dx,.Milin +jmp .Trp +.trpcase: +mov ax,20 +mov dx,.Mcase +jmp .Trp +.trprang: +mov ax,1 +mov dx,.Mrang +jmp .Trp +.trpset: +mov ax,2 +mov dx,.Mset +jmp .Trp +.trpnofp: +mov ax,18 +mov dx,.Mnofp +jmp .Trp +.trpheap: +mov ax,17 +mov dx,.Mheap +jmp .Trp + +.Trp: +xor bx,bx +.extern .trppc +xchg bx,(.trppc) +test bx,bx +jz 2f +push ax +call (bx) +pop ax +ret +2: +mov bx,22 +push bx +push dx +mov ax,2 +push ax +call _write +.stop: +call _exit + +.trp: +mov dx,ax +cmp dx,21 +jae 1f +sal dx,1 +mov bx,.Mtable +add bx,dx +mov bx,(bx) +test bx,bx +jz 1f +mov dx,bx +jmp 2f +1: +mov bx,.Mtrp+14 +mov cx,6 +mov dx,ax +1: +and dx,7 +add dx,'0' +movb (bx),dl +dec bx +sar dx,1 +sar dx,1 +sar dx,1 +loop 1b +mov dx,.Mtrp +2: +jmp .Trp + +.sect .rom +.Mtable: + .data2 0, .Mrang, .Mset, 0, 0, 0, .Mdivz, 0 + .data2 0, 0, 0, 0, 0, 0, 0, 0 + .data2 0, .Mheap, .Milin, .Milin, .Mcase + +.Mdivz: .asciz "Error: Division by 0 \n" +.Milin: .asciz "Illegal EM instruct'n\n" +.Mcase: .asciz "Err in EM case instr \n" +.Mrang: .asciz "Variable out of range\n" +.Mset: .asciz "Err in EM set instr \n" +.Mnofp: .asciz "Floating pt not impl.\n" +.Mheap: .asciz "Heap overflow \n" + +.Mtrp: .asciz "EM trap 0000000 octal\n" diff --git a/mach/minix/libsys/umask.c b/mach/minix/libsys/umask.c new file mode 100644 index 00000000..caeb0754 --- /dev/null +++ b/mach/minix/libsys/umask.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int umask(complmode) +int complmode; +{ + return callm1(FS, UMASK, complmode, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minix/libsys/umount.c b/mach/minix/libsys/umount.c new file mode 100644 index 00000000..d1fab6da --- /dev/null +++ b/mach/minix/libsys/umount.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int umount(name) +char* name; +{ + return callm3(FS, UMOUNT, 0, name); +} diff --git a/mach/minix/libsys/unlink.c b/mach/minix/libsys/unlink.c new file mode 100644 index 00000000..9c321ff2 --- /dev/null +++ b/mach/minix/libsys/unlink.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int unlink(name) +char *name; +{ + return callm3(FS, UNLINK, 0, name); +} diff --git a/mach/minix/libsys/utime.c b/mach/minix/libsys/utime.c new file mode 100644 index 00000000..0c9b4ef4 --- /dev/null +++ b/mach/minix/libsys/utime.c @@ -0,0 +1,12 @@ +#include "lib.h" + +PUBLIC int utime(name, timp) +char *name; +long timp[2]; +{ + M.m2_i1 = len(name); + M.m2_l1 = timp[0]; + M.m2_l2 = timp[1]; + M.m2_p1 = name; + return callx(FS, UTIME); +} diff --git a/mach/minix/libsys/wait.c b/mach/minix/libsys/wait.c new file mode 100644 index 00000000..2d8728fd --- /dev/null +++ b/mach/minix/libsys/wait.c @@ -0,0 +1,10 @@ +#include "lib.h" + +PUBLIC int wait(status) +int *status; +{ + int k; + k = callm1(MM, WAIT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (k >= 0 && status != 0) *status = M.m2_i1; + return(k); +} diff --git a/mach/minix/libsys/write.c b/mach/minix/libsys/write.c new file mode 100644 index 00000000..e08826b0 --- /dev/null +++ b/mach/minix/libsys/write.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int write(fd, buffer, nbytes) +char *buffer; +int nbytes; +{ + return callm1(FS, WRITE, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/cv/Makefile b/mach/minixST/cv/Makefile new file mode 100644 index 00000000..5cfa97a6 --- /dev/null +++ b/mach/minixST/cv/Makefile @@ -0,0 +1,25 @@ +EMHOME = ../../.. +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +INCLUDE = $(EMHOME)/h +CFLAGS = -I. -I$(INCLUDE) -O +TARGETS = cv + +all: $(TARGETS) + +install: all + ../../install cv + +cmp: all + ../../compare cv + +cv: cv.o + $(CC) $(LDFLAGS) -o cv cv.o $(LIBOBJ) + +clean: + rm -f $(TARGETS) *.o nohup.out Out + +pr: + @pr Makefile cv.c + +opr: + make pr | opr diff --git a/mach/minixST/libsys/Makefile b/mach/minixST/libsys/Makefile new file mode 100644 index 00000000..bf42930d --- /dev/null +++ b/mach/minixST/libsys/Makefile @@ -0,0 +1,40 @@ +# $Header$ +MACH=minixST + +all: libsys_o.a end.o head_em.o + +install: all + ../../install libsys_o.a tail_mon + ../../install head_em.o head_em + ../../install end.o end_em + +cmp: all + -../../compare libsys_o.a tail_mon + -../../compare head_em.o head_em + -../../compare end.o end_em + + +end.o: end.s + $(MACH) -I../../../h -O -c end.s + +head_em.o: head_em.s + $(MACH) -I../../../h -O -c head_em.s + +libsys.a: libsys_s.a + ASAR=aal ; export ASAR ;\ + march . libsys.a + +libsys_o.a: libsys.a ../../../lib/m68k2/tail_em + mkdir X; cd X; aal x ../libsys.a; aal x ../../../../lib/m68k2/tail_em; aal rv ../libsys_o.a *.o + rm -rf X + +clean: + rm -f *.o libsys_o.a libsys.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libsys.a | pr -h `pwd`/libsys.a + @pr `pwd`/end.s diff --git a/mach/minixST/libsys/_mktemp.c b/mach/minixST/libsys/_mktemp.c new file mode 100644 index 00000000..e655f9ce --- /dev/null +++ b/mach/minixST/libsys/_mktemp.c @@ -0,0 +1,31 @@ +#include +/* mktemp - make a name for a temporary file */ +#include +#define mktemp _mktemp +#define getpid _getpid +#define access _access +#include + +PUBLIC char *mktemp(char *template) +{ + register int pid, k; + register char *p; + + pid = getpid(); /* get process id as semi-unique number */ + p = template; + while (*p) p++; /* find end of string */ + + /* Replace XXXXXX at end of template with pid. */ + while (*--p == 'X') { + *p = '0' + (pid % 10); + pid /= 10; + } + p++; + for (k = 'a'; k <= 'z'; k++) { + *p = k; + if (access(template, 0) < 0) { + return template; + } + } + return("/"); +} diff --git a/mach/minixST/libsys/access.c b/mach/minixST/libsys/access.c new file mode 100644 index 00000000..23a22dd3 --- /dev/null +++ b/mach/minixST/libsys/access.c @@ -0,0 +1,9 @@ +#include "lib.h" + +PUBLIC int access(name, mode) +char *name; +int mode; +{ + return callm3(FS, ACCESS, mode, name); + +} diff --git a/mach/minixST/libsys/alarm.c b/mach/minixST/libsys/alarm.c new file mode 100644 index 00000000..9be91a8d --- /dev/null +++ b/mach/minixST/libsys/alarm.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int alarm(sec) +unsigned sec; +{ + return callm1(MM, ALARM, (int) sec, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/libsys/brk.c b/mach/minixST/libsys/brk.c new file mode 100644 index 00000000..f6a03772 --- /dev/null +++ b/mach/minixST/libsys/brk.c @@ -0,0 +1,34 @@ +#include "lib.h" + +extern char *brksize; + +PUBLIC char *brk(addr) +char *addr; +{ + int k; + + k = callm1(MM, BRK, 0, 0, 0, addr, NIL_PTR, NIL_PTR); + if (k == OK) { + brksize = M.m2_p1; + return(NIL_PTR); + } else { + return( (char*) -1 ); + } +} + + +PUBLIC char *sbrk(incr) +int incr; +{ + char *newsize, *oldsize; + + oldsize = brksize; + newsize = brksize + incr; + if (incr > 0 && newsize < oldsize || incr < 0 && newsize > oldsize) + return( (char *) -1); + if (brk(newsize) == 0) + return(oldsize); + else + return( (char *) -1 ); +} + diff --git a/mach/minixST/libsys/chdir.c b/mach/minixST/libsys/chdir.c new file mode 100644 index 00000000..357a979c --- /dev/null +++ b/mach/minixST/libsys/chdir.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int chdir(name) +char *name; +{ + return callm3(FS, CHDIR, 0, name); + +} diff --git a/mach/minixST/libsys/chmod.c b/mach/minixST/libsys/chmod.c new file mode 100644 index 00000000..7ae3edad --- /dev/null +++ b/mach/minixST/libsys/chmod.c @@ -0,0 +1,9 @@ +#include "lib.h" + +PUBLIC int chmod(name, mode) +char* name; +int mode; +{ + return callm3(FS, CHMOD, mode, name); + +} diff --git a/mach/minixST/libsys/chown.c b/mach/minixST/libsys/chown.c new file mode 100644 index 00000000..0846102c --- /dev/null +++ b/mach/minixST/libsys/chown.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int chown(name, owner, grp) +char *name; +int owner, grp; +{ + return callm1(FS, CHOWN, len(name), owner, grp, name, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/libsys/chroot.c b/mach/minixST/libsys/chroot.c new file mode 100644 index 00000000..520abaf1 --- /dev/null +++ b/mach/minixST/libsys/chroot.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int chroot(name) +char* name; +{ + return callm3(FS, CHROOT, 0, name); + +} diff --git a/mach/minixST/libsys/close.c b/mach/minixST/libsys/close.c new file mode 100644 index 00000000..72698b0b --- /dev/null +++ b/mach/minixST/libsys/close.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int close(fd) +int fd; +{ + return callm1(FS, CLOSE, fd, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + +} diff --git a/mach/minixST/libsys/compmodule b/mach/minixST/libsys/compmodule new file mode 100755 index 00000000..c0273039 --- /dev/null +++ b/mach/minixST/libsys/compmodule @@ -0,0 +1,4 @@ +if minixST -c -L -LIB $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/minixST/libsys/creat.c b/mach/minixST/libsys/creat.c new file mode 100644 index 00000000..f9c13607 --- /dev/null +++ b/mach/minixST/libsys/creat.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int creat(name, mode) +char* name; +int mode; +{ + return callm3(FS, CREAT, mode, name); +} diff --git a/mach/minixST/libsys/dup.c b/mach/minixST/libsys/dup.c new file mode 100644 index 00000000..f8683ea9 --- /dev/null +++ b/mach/minixST/libsys/dup.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int dup(fd) +int fd; +{ + return callm1(FS, DUP, fd, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/libsys/dup2.c b/mach/minixST/libsys/dup2.c new file mode 100644 index 00000000..67e7c3da --- /dev/null +++ b/mach/minixST/libsys/dup2.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int dup2(fd, fd2) +int fd, fd2; +{ + return callm1(FS, DUP, fd+0100, fd2, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/libsys/end.s b/mach/minixST/libsys/end.s new file mode 100644 index 00000000..f7462124 --- /dev/null +++ b/mach/minixST/libsys/end.s @@ -0,0 +1,16 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define endtext,enddata,endbss +.define _end,_etext,_edata + + .sect .text +endtext: +_etext: + .align 2 + .sect .data +enddata: +_edata: + .align 2 +.sect .endsect +_end: +endbss: + .align 2 diff --git a/mach/minixST/libsys/exec.c b/mach/minixST/libsys/exec.c new file mode 100644 index 00000000..cb2be552 --- /dev/null +++ b/mach/minixST/libsys/exec.c @@ -0,0 +1,103 @@ +#include "lib.h" + +extern char **environ; /* environment pointer */ + +#define PTRSIZE sizeof(char *) + +PUBLIC int execl(name, arg0) +char *name; +char *arg0; +{ + return execve(name, &arg0, environ); +} + +PUBLIC int execle(name, argv) +char *name, *argv; +{ + char **p; + p = (char **) &argv; + while (*p++) /* null statement */ ; + return execve(name, &argv, *p); +} + +PUBLIC int execv(name, argv) +char *name, *argv[]; +{ + return execve(name, argv, environ); +} + + +PUBLIC int execve(name, argv, envp) +char *name; /* pointer to name of file to be executed */ +char *argv[]; /* pointer to argument array */ +char *envp[]; /* pointer to environment */ +{ + char stack[MAX_ISTACK_BYTES]; + char **argorg, **envorg, *hp, **ap, *p; + int i, nargs, nenvps, stackbytes, offset; + extern errno; + + /* Count the argument pointers and environment pointers. */ + nargs = 0; + nenvps = 0; + argorg = argv; + envorg = envp; + while (*argorg++ != NIL_PTR) nargs++; + while (*envorg++ != NIL_PTR) nenvps++; + + /* Prepare to set up the initial stack. */ + hp = &stack[(nargs + nenvps + 3) * PTRSIZE]; + if (hp + nargs + nenvps >= &stack[MAX_ISTACK_BYTES]) { + errno = E2BIG; + return(-1); + } + ap = (char **) stack; + *ap++ = (char *) nargs; + + /* Prepare the argument pointers and strings. */ + for (i = 0; i < nargs; i++) { + offset = hp - stack; + *ap++ = (char *) offset; + p = *argv++; + while (*p) { + *hp++ = *p++; + if (hp >= &stack[MAX_ISTACK_BYTES]) { + errno = E2BIG; + return(-1); + } + } + *hp++ = (char) 0; + } + *ap++ = NIL_PTR; + + /* Prepare the environment pointers and strings. */ + for (i = 0; i < nenvps; i++) { + offset = hp - stack; + *ap++ = (char *) offset; + p = *envp++; + while (*p) { + *hp++ = *p++; + if (hp >= &stack[MAX_ISTACK_BYTES]) { + errno = E2BIG; + return(-1); + } + } + *hp++ = (char) 0; + } + *ap++ = NIL_PTR; + stackbytes = ( ( (int)(hp - stack) + PTRSIZE - 1)/PTRSIZE) * PTRSIZE; + return callm1(MM_PROC_NR, EXEC, len(name), stackbytes, 0,name, stack,NIL_PTR); +} + + +PUBLIC execn(name) +char *name; /* pointer to file to be exec'd */ +{ +/* Special version used when there are no args and no environment. This call + * is principally used by INIT, to avoid having to allocate MAX_ISTACK_BYTES. + */ + + static char stack[3 * PTRSIZE]; + + return callm1(MM_PROC_NR, EXEC, len(name), sizeof(stack), 0, name, stack, NIL_PTR); +} diff --git a/mach/minixST/libsys/fork.c b/mach/minixST/libsys/fork.c new file mode 100644 index 00000000..7d5c0fc5 --- /dev/null +++ b/mach/minixST/libsys/fork.c @@ -0,0 +1,6 @@ +#include "lib.h" + +PUBLIC int fork() +{ + return callm1(MM, FORK, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/libsys/fstat.c b/mach/minixST/libsys/fstat.c new file mode 100644 index 00000000..8fb6d665 --- /dev/null +++ b/mach/minixST/libsys/fstat.c @@ -0,0 +1,10 @@ +#include "lib.h" + +PUBLIC int fstat(fd, buffer) +int fd; +char *buffer; +{ + int n; + n = callm1(FS, FSTAT, fd, 0, 0, buffer, NIL_PTR, NIL_PTR); + return(n); +} diff --git a/mach/minixST/libsys/getegid.c b/mach/minixST/libsys/getegid.c new file mode 100644 index 00000000..e4166916 --- /dev/null +++ b/mach/minixST/libsys/getegid.c @@ -0,0 +1,9 @@ +#include "lib.h" + +PUBLIC gid getegid() +{ + int k; + k = callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (k < 0) return ( (gid) k); + return( (gid) M.m2_i1); +} diff --git a/mach/minixST/libsys/geteuid.c b/mach/minixST/libsys/geteuid.c new file mode 100644 index 00000000..172f3dfd --- /dev/null +++ b/mach/minixST/libsys/geteuid.c @@ -0,0 +1,9 @@ +#include "lib.h" + +PUBLIC uid geteuid() +{ + int k; + k = callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (k < 0) return ( (uid) k); + return ((uid) M.m2_i1); +} diff --git a/mach/minixST/libsys/getgid.c b/mach/minixST/libsys/getgid.c new file mode 100644 index 00000000..78fc92ac --- /dev/null +++ b/mach/minixST/libsys/getgid.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC gid getgid() +{ + int k; + k = callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + return( (gid) k); +} diff --git a/mach/minixST/libsys/getpid.c b/mach/minixST/libsys/getpid.c new file mode 100644 index 00000000..43ab9dda --- /dev/null +++ b/mach/minixST/libsys/getpid.c @@ -0,0 +1,6 @@ +#include "lib.h" + +PUBLIC int getpid() +{ + return callm1(MM, GETPID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/libsys/getuid.c b/mach/minixST/libsys/getuid.c new file mode 100644 index 00000000..44801a36 --- /dev/null +++ b/mach/minixST/libsys/getuid.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC uid getuid() +{ + int k; + k = callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + return( (uid) k); +} diff --git a/mach/minixST/libsys/gtty.c b/mach/minixST/libsys/gtty.c new file mode 100644 index 00000000..8916d9b4 --- /dev/null +++ b/mach/minixST/libsys/gtty.c @@ -0,0 +1,9 @@ +#include + +gtty(fd, argp) +int fd; +char *argp; +{ + return ioctl(fd, TIOCGETP, argp); +} + diff --git a/mach/minixST/libsys/ioctl.c b/mach/minixST/libsys/ioctl.c new file mode 100644 index 00000000..fbd0658f --- /dev/null +++ b/mach/minixST/libsys/ioctl.c @@ -0,0 +1,68 @@ +#include "lib.h" +#include +#include + +PUBLIC int ioctl(fd, request, u) +int fd; +int request; +union { + struct sgttyb *argp; + struct tchars *argt; +} u; + +{ + int n, ispeed, ospeed; + long erase, kill, intr, quit, xon, xoff, eof, brk, speed; + + M.TTY_REQUEST = request; + M.TTY_LINE = fd; + + switch(request) { + case TIOCSETP: + erase = u.argp->sg_erase & BYTE; + kill = u.argp->sg_kill & BYTE; + M.TTY_SPEK = (erase << 8) | kill; + M.TTY_FLAGS = u.argp->sg_flags; + M.TTY_SPEED = (u.argp->sg_ospeed << 8) | u.argp->sg_ispeed; + n = callx(FS, IOCTL); + return(n); + + case TIOCSETC: + intr = u.argt->t_intrc & BYTE; + quit = u.argt->t_quitc & BYTE; + xon = u.argt->t_startc & BYTE; + xoff = u.argt->t_stopc & BYTE; + eof = u.argt->t_eofc & BYTE; + brk = u.argt->t_brkc & BYTE; /* not used at the moment */ + M.TTY_SPEK = (intr<<24) | (quit<<16) | (xon<<8) | (xoff<<0); + M.TTY_FLAGS = (eof<<8) | (brk<<0); + n = callx(FS, IOCTL); + return(n); + + case TIOCGETP: + n = callx(FS, IOCTL); + u.argp->sg_erase = (M.TTY_SPEK >> 8) & BYTE; + u.argp->sg_kill = (M.TTY_SPEK >> 0) & BYTE; + u.argp->sg_flags = M.TTY_FLAGS & 0xFFFF; + speed = (M.TTY_FLAGS >> 16) & 0xFFFFL; + u.argp->sg_ispeed = speed & BYTE; + u.argp->sg_ospeed = (speed >> 8) & BYTE; + return(n); + + case TIOCGETC: + n = callx(FS, IOCTL); + u.argt->t_intrc = (M.TTY_SPEK >> 24) & BYTE; + u.argt->t_quitc = (M.TTY_SPEK >> 16) & BYTE; + u.argt->t_startc = (M.TTY_SPEK >> 8) & BYTE; + u.argt->t_stopc = (M.TTY_SPEK >> 0) & BYTE; + u.argt->t_eofc = (M.TTY_FLAGS >> 8) & BYTE; + u.argt->t_brkc = (M.TTY_FLAGS >> 8) & BYTE; + return(n); + + default: + n = -1; + errno = -(EINVAL); + return(n); + } +} + diff --git a/mach/minixST/libsys/kill.c b/mach/minixST/libsys/kill.c new file mode 100644 index 00000000..db106541 --- /dev/null +++ b/mach/minixST/libsys/kill.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int kill(proc, sig) +int proc; /* which process is to be sent the signal */ +int sig; /* signal number */ +{ + return callm1(MM, KILL, proc, sig, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/libsys/lib.h b/mach/minixST/libsys/lib.h new file mode 100644 index 00000000..32c25c78 --- /dev/null +++ b/mach/minixST/libsys/lib.h @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +extern message M; + +#define MM 0 +#define FS 1 + +extern int callm1(), callm3(), callx(), len(); +extern int errno; +extern int begsig(); /* interrupts all vector here */ diff --git a/mach/minixST/libsys/link.c b/mach/minixST/libsys/link.c new file mode 100644 index 00000000..9daee380 --- /dev/null +++ b/mach/minixST/libsys/link.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int link(name, name2) +char *name, *name2; +{ + return callm1(FS, LINK, len(name), len(name2), 0, name, name2, NIL_PTR); +} diff --git a/mach/minixST/libsys/lseek.c b/mach/minixST/libsys/lseek.c new file mode 100644 index 00000000..ffcf165d --- /dev/null +++ b/mach/minixST/libsys/lseek.c @@ -0,0 +1,15 @@ +#include "lib.h" + +PUBLIC long lseek(fd, offset, whence) +int fd; +long offset; +int whence; +{ + int k; + M.m2_i1 = fd; + M.m2_l1 = offset; + M.m2_i2 = whence; + k = callx(FS, LSEEK); + if (k != OK) return( (long) k); /* send itself failed */ + return(M.m2_l1); +} diff --git a/mach/minixST/libsys/mknod.c b/mach/minixST/libsys/mknod.c new file mode 100644 index 00000000..7dbfeca1 --- /dev/null +++ b/mach/minixST/libsys/mknod.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int mknod(name, mode, addr) +char *name; +int mode, addr; +{ + return callm1(FS, MKNOD, len(name), mode, addr, name, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/libsys/mktemp.c b/mach/minixST/libsys/mktemp.c new file mode 100644 index 00000000..e29e5c93 --- /dev/null +++ b/mach/minixST/libsys/mktemp.c @@ -0,0 +1,20 @@ +/* mktemp - make a name for a temporary file */ + +char *mktemp(template) +char *template; +{ + int pid, k; + char *p; + + pid = getpid(); /* get process id as semi-unique number */ + p = template; + while (*p++) ; /* find end of string */ + p--; /* backup to last character */ + + /* Replace XXXXXX at end of template with pid. */ + while (*--p == 'X') { + *p = '0' + (pid % 10); + pid = pid/10; + } + return(template); +} diff --git a/mach/minixST/libsys/mktemp.s b/mach/minixST/libsys/mktemp.s new file mode 100644 index 00000000..cc5b48b1 --- /dev/null +++ b/mach/minixST/libsys/mktemp.s @@ -0,0 +1,5 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define _mktemp +_mktemp: + jmp __mktemp diff --git a/mach/minixST/libsys/mount.c b/mach/minixST/libsys/mount.c new file mode 100644 index 00000000..258276b4 --- /dev/null +++ b/mach/minixST/libsys/mount.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int mount(special, name, rwflag) +char *name, *special; +int rwflag; +{ + return callm1(FS, MOUNT, len(special), len(name), rwflag, special, name, NIL_PTR); +} diff --git a/mach/minixST/libsys/open.c b/mach/minixST/libsys/open.c new file mode 100644 index 00000000..228173d7 --- /dev/null +++ b/mach/minixST/libsys/open.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int open(name, mode) +char* name; +int mode; +{ + return callm3(FS, OPEN, mode, name); +} diff --git a/mach/minixST/libsys/pause.c b/mach/minixST/libsys/pause.c new file mode 100644 index 00000000..2a0d1f69 --- /dev/null +++ b/mach/minixST/libsys/pause.c @@ -0,0 +1,6 @@ +#include "lib.h" + +PUBLIC int pause() +{ + return callm1(MM, PAUSE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/libsys/pipe.c b/mach/minixST/libsys/pipe.c new file mode 100644 index 00000000..05058808 --- /dev/null +++ b/mach/minixST/libsys/pipe.c @@ -0,0 +1,14 @@ +#include "lib.h" + +PUBLIC int pipe(fild) +int fild[2]; +{ + int k; + k = callm1(FS, PIPE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (k >= 0) { + fild[0] = M.m1_i1; + fild[1] = M.m1_i2; + return(0); + } else + return(k); +} diff --git a/mach/minixST/libsys/read.c b/mach/minixST/libsys/read.c new file mode 100644 index 00000000..1619a4da --- /dev/null +++ b/mach/minixST/libsys/read.c @@ -0,0 +1,11 @@ +#include "lib.h" + +PUBLIC int read(fd, buffer, nbytes) +int fd; +char *buffer; +int nbytes; +{ + int n; + n = callm1(FS, READ, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR); + return(n); +} diff --git a/mach/minixST/libsys/setgid.c b/mach/minixST/libsys/setgid.c new file mode 100644 index 00000000..823e8788 --- /dev/null +++ b/mach/minixST/libsys/setgid.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int setgid(grp) +int grp; +{ + return callm1(MM, SETGID, grp, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/libsys/setuid.c b/mach/minixST/libsys/setuid.c new file mode 100644 index 00000000..c53e0e3c --- /dev/null +++ b/mach/minixST/libsys/setuid.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int setuid(usr) +int usr; +{ + return callm1(MM, SETUID, usr, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/libsys/signal.c b/mach/minixST/libsys/signal.c new file mode 100644 index 00000000..4c5167cb --- /dev/null +++ b/mach/minixST/libsys/signal.c @@ -0,0 +1,28 @@ +#include "lib.h" +#include + +int (*vectab[NSIG])(); /* array of functions to catch signals */ + +/* The definition of signal really should be + * PUBLIC int (*signal(signr, func))() + * but some compilers refuse to accept this, even though it is correct. + * The only thing to do if you are stuck with such a defective compiler is + * change it to + * PUBLIC int *signal(signr, func) + * and change ../h/signal.h accordingly. + */ + +PUBLIC int (*signal(signr, func))() +int signr; /* which signal is being set */ +int (*func)(); /* pointer to function that catches signal */ +{ + int r,(*old)(); + + old = vectab[signr - 1]; + vectab[signr - 1] = func; + M.m6_i1 = signr; + M.m6_f1 = ( (func == SIG_IGN || func == SIG_DFL) ? func : begsig); + r = callx(MM, SIGNAL); + if (r == 1) old = SIG_IGN; + return( (r < 0 ? (int (*)()) r : old) ); +} diff --git a/mach/minixST/libsys/stat.c b/mach/minixST/libsys/stat.c new file mode 100644 index 00000000..ae7b446f --- /dev/null +++ b/mach/minixST/libsys/stat.c @@ -0,0 +1,10 @@ +#include "lib.h" + +PUBLIC int stat(name, buffer) +char *name; +char *buffer; +{ + int n; + n = callm1(FS, STAT, len(name), 0, 0, name, buffer, NIL_PTR); + return(n); +} diff --git a/mach/minixST/libsys/stderr.c b/mach/minixST/libsys/stderr.c new file mode 100644 index 00000000..7910f77e --- /dev/null +++ b/mach/minixST/libsys/stderr.c @@ -0,0 +1,8 @@ +std_err(s) +char *s; +{ + char *p = s; + + while(*p != 0) p++; + write(2, s, (int)(p - s)); +} diff --git a/mach/minixST/libsys/stime.c b/mach/minixST/libsys/stime.c new file mode 100644 index 00000000..548ac37c --- /dev/null +++ b/mach/minixST/libsys/stime.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int stime(top) +long *top; +{ + M.m2_l1 = *top; + return callx(FS, STIME); +} diff --git a/mach/minixST/libsys/stty.c b/mach/minixST/libsys/stty.c new file mode 100644 index 00000000..7dfe3db3 --- /dev/null +++ b/mach/minixST/libsys/stty.c @@ -0,0 +1,9 @@ +#include + +stty(fd, argp) +int fd; +char *argp; +{ + return ioctl(fd, TIOCSETP, argp); +} + diff --git a/mach/minixST/libsys/sync.c b/mach/minixST/libsys/sync.c new file mode 100644 index 00000000..4592d28c --- /dev/null +++ b/mach/minixST/libsys/sync.c @@ -0,0 +1,6 @@ +#include "lib.h" + +PUBLIC int sync() +{ + return callm1(FS, SYNC, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/libsys/time.c b/mach/minixST/libsys/time.c new file mode 100644 index 00000000..e34e1f24 --- /dev/null +++ b/mach/minixST/libsys/time.c @@ -0,0 +1,13 @@ +#include "lib.h" + +PUBLIC long time(tp) +long *tp; +{ + int k; + long l; + k = callm1(FS, TIME, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (M.m_type < 0 || k != OK) {errno = -M.m_type; return(-1L);} + l = M.m2_l1; + if (tp != (long *) 0) *tp = l; + return(l); +} diff --git a/mach/minixST/libsys/times.c b/mach/minixST/libsys/times.c new file mode 100644 index 00000000..77515d69 --- /dev/null +++ b/mach/minixST/libsys/times.c @@ -0,0 +1,15 @@ +#include "lib.h" +#include +#include + +PUBLIC int times(buf) +struct tms *buf; +{ + int k; + k = callm1(FS, TIMES, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + buf->tms_utime = M.m4_l1; + buf->tms_stime = M.m4_l2; + buf->tms_cutime = M.m4_l3; + buf->tms_cstime = M.m4_l4; + return(k); +} diff --git a/mach/minixST/libsys/umask.c b/mach/minixST/libsys/umask.c new file mode 100644 index 00000000..caeb0754 --- /dev/null +++ b/mach/minixST/libsys/umask.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int umask(complmode) +int complmode; +{ + return callm1(FS, UMASK, complmode, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/libsys/umount.c b/mach/minixST/libsys/umount.c new file mode 100644 index 00000000..d1fab6da --- /dev/null +++ b/mach/minixST/libsys/umount.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int umount(name) +char* name; +{ + return callm3(FS, UMOUNT, 0, name); +} diff --git a/mach/minixST/libsys/unlink.c b/mach/minixST/libsys/unlink.c new file mode 100644 index 00000000..9c321ff2 --- /dev/null +++ b/mach/minixST/libsys/unlink.c @@ -0,0 +1,7 @@ +#include "lib.h" + +PUBLIC int unlink(name) +char *name; +{ + return callm3(FS, UNLINK, 0, name); +} diff --git a/mach/minixST/libsys/utime.c b/mach/minixST/libsys/utime.c new file mode 100644 index 00000000..0c9b4ef4 --- /dev/null +++ b/mach/minixST/libsys/utime.c @@ -0,0 +1,12 @@ +#include "lib.h" + +PUBLIC int utime(name, timp) +char *name; +long timp[2]; +{ + M.m2_i1 = len(name); + M.m2_l1 = timp[0]; + M.m2_l2 = timp[1]; + M.m2_p1 = name; + return callx(FS, UTIME); +} diff --git a/mach/minixST/libsys/wait.c b/mach/minixST/libsys/wait.c new file mode 100644 index 00000000..2d8728fd --- /dev/null +++ b/mach/minixST/libsys/wait.c @@ -0,0 +1,10 @@ +#include "lib.h" + +PUBLIC int wait(status) +int *status; +{ + int k; + k = callm1(MM, WAIT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (k >= 0 && status != 0) *status = M.m2_i1; + return(k); +} diff --git a/mach/minixST/libsys/write.c b/mach/minixST/libsys/write.c new file mode 100644 index 00000000..e08826b0 --- /dev/null +++ b/mach/minixST/libsys/write.c @@ -0,0 +1,8 @@ +#include "lib.h" + +PUBLIC int write(fd, buffer, nbytes) +char *buffer; +int nbytes; +{ + return callm1(FS, WRITE, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR); +} diff --git a/mach/moon3/ncg/Makefile b/mach/moon3/ncg/Makefile new file mode 100644 index 00000000..f5e2bda6 --- /dev/null +++ b/mach/moon3/ncg/Makefile @@ -0,0 +1,197 @@ +# $Header$ + +EMHOME=../../.. +#preprocessor flags for table +TABLEFLAGS= +#cgg options +CGGFLAGS= + +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/ncg +CGG=$(EMHOME)/lib/ncgg +CPP=$(EMHOME)/lib/cpp +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/label.c $(CDIR)/main.c \ + $(CDIR)/move.c $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c \ + $(CDIR)/salloc.c $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o label.o \ + main.o move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +label.o: $(CDIR)/label.c + $(CC) -c $(CFLAGS) $(CDIR)/label.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + $(EMHOME)/mach/install cg + +cmp: all + -$(EMHOME)/mach/compare cg + + +tables.c: table $(CGG) + $(CPP) $(TABLEFLAGS) table | $(CGG) $(CGGFLAGS) + -cmp tables.h tables.H || cp tables.H tables.h + +lint: $(CFILES) tables.c + lint $(LINTOPTS) $(PREFLAGS) -I$(CDIR) $(CFILES) tables.c +clean: + rm -f *.o tables.c tables.h debug.out cg tables.H + +distr: tables.c + rm -f tables1.c tables1.h + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + +codegen.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/label.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +label.o: $(CDIR)/label.h +label.o: $(CDIR)/param.h +label.o: tables.h +label.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +main.o: tables.h +move.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/ns/as/Makefile b/mach/ns/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/ns/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/ns/libem/Makefile b/mach/ns/libem/Makefile new file mode 100644 index 00000000..9f7b50d8 --- /dev/null +++ b/mach/ns/libem/Makefile @@ -0,0 +1,29 @@ +# $Header$ +MACH=ns + +all: libem_o.a end.o + +install: all + ../../install libem_o.a tail_em + ../../install end.o end_em + +cmp: all + -../../compare libem_o.a tail_em + -../../compare end.o end_em + +end.o: end.s + $(MACH) -I../../../h -c end.s + +libem_o.a: libem_s.a + ASAR=aal ; export ASAR ;\ + march . libem_o.a + +clean: + rm -f *.o libem_o.a nohup.out Out + +opr : + make pr | opr + +pr: + @arch pv libem_s.a | pr -h `pwd`/libem_s.a + @pr `pwd`/end.s diff --git a/mach/ns/libem/compmodule b/mach/ns/libem/compmodule new file mode 100755 index 00000000..adf99cce --- /dev/null +++ b/mach/ns/libem/compmodule @@ -0,0 +1,4 @@ +if ns -c $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/ns/libem/end.s b/mach/ns/libem/end.s new file mode 100644 index 00000000..37e1cef2 --- /dev/null +++ b/mach/ns/libem/end.s @@ -0,0 +1,16 @@ +.define endtext,enddata,endbss,_etext,_edata,_end +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .end ! only for declaration of _end and endbss. + + .sect .text +endtext: +_etext: + .sect .data +enddata: +_edata: + .sect .end +_end: +endbss: diff --git a/mach/ns/libem/mon.s b/mach/ns/libem/mon.s new file mode 100644 index 00000000..31773656 --- /dev/null +++ b/mach/ns/libem/mon.s @@ -0,0 +1,58 @@ +.define .mon +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + + .sect .text + +.mon: + cmpd 1,4(sp) + beq 1f + cmpd 3,4(sp) + beq 3f + cmpd 4,4(sp) + beq 4f + cmpd 54,4(sp) + beq 5f + + movd .add1, tos + jsr @.prstr + movd 4(sp), tos + jsr @.print + movd .add2, tos + jsr @.prstr + ret 4 + +1: jump @.stop + +3: save [r0,r1,r2,r3] + movd 3,r0 + movd 28(sp),r1 + movd 32(sp),r2 + movd 0,r3 + svc + movd r2, 32(sp) + movd 0,28(sp) + restore [r0,r1,r2,r3] + ret 8 + +4: save [r0,r1,r2,r3] + movd 4,r0 + movd 28(sp),r1 + movd 32(sp),r2 + movd 0,r3 + svc + movd r2, 32(sp) + movd 0,28(sp) + restore [r0,r1,r2,r3] + ret 8 + +5: movd 0, 16(sp) + ret 12 + +.sect .data +.add1: .asciz "monitor call " +.add2: .asciz " not implemented\n" +.align diff --git a/mach/ns/libsys/Makefile b/mach/ns/libsys/Makefile new file mode 100644 index 00000000..955ce97d --- /dev/null +++ b/mach/ns/libsys/Makefile @@ -0,0 +1,28 @@ +# $Header$ +MACH=ns +all: libmon_o.a head_em.o + +install: all + ../../install head_em.o head_em + ../../install libmon_o.a tail_mon + +cmp: all + -../../compare head_em.o head_em + -../../compare libmon_o.a tail_mon + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +head_em.o: head_em.s + $(MACH) -I../../../h -c head_em.s + +clean: + rm -f *.o libmon_o.a nohup.out Out + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @ar pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/ns/libsys/compmodule b/mach/ns/libsys/compmodule new file mode 100755 index 00000000..e32bc096 --- /dev/null +++ b/mach/ns/libsys/compmodule @@ -0,0 +1,4 @@ +if ns -c -L $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/ns/ncg/Makefile b/mach/ns/ncg/Makefile new file mode 100644 index 00000000..f5e2bda6 --- /dev/null +++ b/mach/ns/ncg/Makefile @@ -0,0 +1,197 @@ +# $Header$ + +EMHOME=../../.. +#preprocessor flags for table +TABLEFLAGS= +#cgg options +CGGFLAGS= + +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/ncg +CGG=$(EMHOME)/lib/ncgg +CPP=$(EMHOME)/lib/cpp +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/label.c $(CDIR)/main.c \ + $(CDIR)/move.c $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c \ + $(CDIR)/salloc.c $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o label.o \ + main.o move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +label.o: $(CDIR)/label.c + $(CC) -c $(CFLAGS) $(CDIR)/label.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + $(EMHOME)/mach/install cg + +cmp: all + -$(EMHOME)/mach/compare cg + + +tables.c: table $(CGG) + $(CPP) $(TABLEFLAGS) table | $(CGG) $(CGGFLAGS) + -cmp tables.h tables.H || cp tables.H tables.h + +lint: $(CFILES) tables.c + lint $(LINTOPTS) $(PREFLAGS) -I$(CDIR) $(CFILES) tables.c +clean: + rm -f *.o tables.c tables.h debug.out cg tables.H + +distr: tables.c + rm -f tables1.c tables1.h + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + +codegen.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/label.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +label.o: $(CDIR)/label.h +label.o: $(CDIR)/param.h +label.o: tables.h +label.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +main.o: tables.h +move.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/pdp/as/Makefile b/mach/pdp/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/pdp/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/pdp/cg/Makefile b/mach/pdp/cg/Makefile new file mode 100644 index 00000000..22f5f603 --- /dev/null +++ b/mach/pdp/cg/Makefile @@ -0,0 +1,184 @@ +# $Header$ + +EMHOME=../../.. +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-hbxac +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/cg +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/main.c $(CDIR)/move.c \ + $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c $(CDIR)/salloc.c \ + $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o main.o\ + move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + ../../install cg + +cmp: all + -../../compare cg + +distr: tables.c + rm -f tables1.[ch] + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + + +tables.c: table + -mv tables.h tables.h.save + $(EMHOME)/lib/cpp -P table | $(EMHOME)/lib/cgg > debug.out + -if cmp -s tables.h.save tables.h; then mv tables.h.save tables.h; else exit 0; fi + -if cmp -s /dev/null tables.h; then mv tables.h.save tables.h; else exit 0; fi + +lint: $(CFILES) + lint $(LINTOPTS) $(PREFLAGS) $(CFILES) +clean: + rm -f *.o tables.c tables.h debug.out cg tables.h.save + +codegen.o: $(CDIR)/assert.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +move.o: $(CDIR)/assert.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/pdp/cg/peep.c b/mach/pdp/cg/peep.c new file mode 100644 index 00000000..32d0d040 --- /dev/null +++ b/mach/pdp/cg/peep.c @@ -0,0 +1,135 @@ +#ifndef NORCSID +static char rcsid[] = "$Header$"; +#endif + +#include + +/* + * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. + * + * This product is part of the Amsterdam Compiler Kit. + * + * Permission to use, sell, duplicate or disclose this software must be + * obtained in writing. Requests for such permissions may be sent to + * + * Dr. Andrew S. Tanenbaum + * Wiskundig Seminarium + * Vrije Universiteit + * Postbox 7161 + * 1007 MC Amsterdam + * The Netherlands + * + * Author: Hans van Staveren + */ + +char buf[512]; +char *index(); + +main() { + register n,sa; + register char *p; + + sa=0; + for (;;) { + getline(buf); + if (n=stackadjust()) { + sa += n; + continue; + } + if (nullinstruction()) + continue; + if (sa) { + if (buf[0]=='t' && buf[1]=='s' && buf[2]=='t' && buf[3]==' ') { + sa -= 2; + buf[0]='m'; + buf[1]='o'; + buf[2]='v'; + strcat(buf,",(sp)+"); + } else if (buf[0]=='m' && buf[1]=='o' && buf[2]=='v' && + buf[3]==' ' && (p=index(&buf[5],','))!=0 && + p[1]=='-' && p[2]=='(' && p[3]=='s') { + sa -= 2; + p[1]=' '; + } + } + switch(sa) { + case 0:break; + case 2:puts("tst (sp)+");sa=0;break; + case 4:puts("cmp (sp)+,(sp)+");sa=0;break; + case 6:puts("add $06,sp");sa=0;break; + } + puts(buf); + } +} + +getline(buf) register char *buf; { + register c; + + while ((c=getchar())==' ' || c=='\t') + ; + if (c==EOF) + exit(0); + do *buf++=c; + while ((c=getchar())!='\n'); + *buf=0; +} + +stackadjust() { + + if (buf[0]=='t' && + buf[1]=='s' && + buf[2]=='t' && + buf[3]==' ' && + buf[4]=='(' && + buf[5]=='s' && + buf[6]=='p' && + buf[7]==')' && + buf[8]=='+') return(2); + if (buf[0]=='c' && + buf[1]=='m' && + buf[2]=='p' && + buf[3]==' ' && + buf[4]=='(' && + buf[5]=='s' && + buf[6]=='p' && + buf[7]==')' && + buf[8]=='+' && + buf[9]==',' && + buf[10]=='(' && + buf[11]=='s' && + buf[12]=='p' && + buf[13]==')' && + buf[14]=='+') return(4); + if (buf[0]=='a' && + buf[1]=='d' && + buf[2]=='d' && + buf[3]==' ' && + buf[4]=='$' && + buf[5]=='0' && + buf[6]=='6' && + buf[7]==',' && + buf[8]=='s' && + buf[9]=='p' && + buf[10]==0) return(6); + return(0); +} + +nullinstruction() { + register char *p; + + if (buf[4]=='$' && buf[5]=='0' && buf[6]=='0' && buf[7]==',') { + p=index(buf,'-'); + if (p!=0 && p[1]=='(') + return(0); + p=index(buf,'+'); + if (p!=0 && p[-1]==')') + return(0); + if (buf[0]=='b' && buf[1]=='i' && (buf[2]=='s' || buf[2]=='c')) + return(1); + if (buf[0]=='a' && buf[1]=='d' && buf[2]=='d') + return(1); + if (buf[0]=='s' && buf[1]=='u' && buf[2]=='b') + return(1); + } + return(0); +} diff --git a/mach/pdp/cv/Makefile b/mach/pdp/cv/Makefile new file mode 100644 index 00000000..5cfa97a6 --- /dev/null +++ b/mach/pdp/cv/Makefile @@ -0,0 +1,25 @@ +EMHOME = ../../.. +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +INCLUDE = $(EMHOME)/h +CFLAGS = -I. -I$(INCLUDE) -O +TARGETS = cv + +all: $(TARGETS) + +install: all + ../../install cv + +cmp: all + ../../compare cv + +cv: cv.o + $(CC) $(LDFLAGS) -o cv cv.o $(LIBOBJ) + +clean: + rm -f $(TARGETS) *.o nohup.out Out + +pr: + @pr Makefile cv.c + +opr: + make pr | opr diff --git a/mach/pdp/int/Makefile b/mach/pdp/int/Makefile new file mode 100644 index 00000000..d689fb26 --- /dev/null +++ b/mach/pdp/int/Makefile @@ -0,0 +1,51 @@ +INTS=em_t--- em_---- em_tf-- em_t-c- em_t--p +b=../../../lib/em22 + +all: $(INTS) eminform em + +em: em.c + $(CC) -o em -I../../../h em.c + +eminform: eminform.s + as eminform.s;ld -i -o eminform a.out -lc + +em_t---: t+ f- c- p- em_int.s + as t+ f- c- p- em_int.s;ld -i -o em_t--- a.out -lc + +em_----: t- f- c- p- em_int.s + as t- f- c- p- em_int.s;ld -i -o em_---- a.out -lc + +em_tf--: t+ f+ c- p- em_int.s + as t+ f+ c- p- em_int.s;ld -i -o em_tf-- a.out -lc + +em_t-c-: t+ f- c+ p- em_int.s + as t+ f- c+ p- em_int.s;ld -i -o em_t-c- a.out -lc + +em_t--p: t+ f- c- p+ em_int.s + as t+ f- c- p+ em_int.s;ld -i -o em_t--p a.out -lc + +install: all + -mkdir $b + cp em_???? $b + cp em eminform ../../../bin + cp em.1 eminform.1 ../../../man + +cmp: all + -cmp em_t--- $b/em_t--- + -cmp em_---- $b/em_---- + -cmp em_tf-- $b/em_tf-- + -cmp em_t-c- $b/em_t-c- + -cmp em_t--p $b/em_t--p + -cmp em ../../../bin/em + -cmp eminform ../../../bin/eminform + -cmp em.1 ../../../man/em.1 + -cmp eminform.1 ../../../man/eminform.1 + +clean: + -rm -f *.o *.old a.out em eminform $(INTS) + +opr: + make pr | opr + +pr: + @pr em.c em_int.s eminform.s diff --git a/mach/pdp/libem/Makefile b/mach/pdp/libem/Makefile new file mode 100644 index 00000000..d4a42a35 --- /dev/null +++ b/mach/pdp/libem/Makefile @@ -0,0 +1,33 @@ +all: head_em.o libem_o.a end.o + +install: cp + +cp: all + ../../install head_em.o head_em + ../../install libem_o.a tail_em + ../../install end.o end_em + +cmp: all + -../../compare head_em.o head_em + -../../compare libem_o.a tail_em + -../../compare end.o end_em + + +head_em.o: head_em.s + pdp -c head_em.s + +end.o: end.s + pdp -c end.s + +libem_o.a: libem_s.a + ASAR=aal ; export ASAR ; march . libem_o.a + +clean: + rm -f *.o libem_o.a + +opr: + make pr | opr + +pr: + @pr `pwd`/Makefile `pwd`/head_em.s + @arch pv libem_s.a | pr -h `pwd`/libem_s.a diff --git a/mach/pdp/libem/blm.s b/mach/pdp/libem/blm.s new file mode 100644 index 00000000..ea55f5f1 --- /dev/null +++ b/mach/pdp/libem/blm.s @@ -0,0 +1,29 @@ +/ $Header$ +.globl blm~ +.globl save~,retu~ + +/ Size in r0 +blm~: + jsr pc,save~ + mov (sp)+,r2 + mov (sp)+,r3 + mov r0,r1 + asr r0 + beq 2f +/ Now avoid wrong copy. +/ The pieces may overlap ! + cmp r3,r2 + beq 2f + blt 3f +1: + mov (r3)+,(r2)+ + sob r0,1b +2: + jmp retu~ +3: + add r1,r3 + add r1,r2 +4: + mov -(r3),-(r2) + sob r0,4b + br 2b diff --git a/mach/pdp/libem/compmodule b/mach/pdp/libem/compmodule new file mode 100755 index 00000000..e6e7c76e --- /dev/null +++ b/mach/pdp/libem/compmodule @@ -0,0 +1,4 @@ +if pdp -c $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/pdp/libem/end.s b/mach/pdp/libem/end.s new file mode 100644 index 00000000..37e1cef2 --- /dev/null +++ b/mach/pdp/libem/end.s @@ -0,0 +1,16 @@ +.define endtext,enddata,endbss,_etext,_edata,_end +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .end ! only for declaration of _end and endbss. + + .sect .text +endtext: +_etext: + .sect .data +enddata: +_edata: + .sect .end +_end: +endbss: diff --git a/mach/pdp/libem/head_em.s b/mach/pdp/libem/head_em.s new file mode 100644 index 00000000..00900d17 --- /dev/null +++ b/mach/pdp/libem/head_em.s @@ -0,0 +1,75 @@ +# +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define LINO_AD,FILN_AD +.define ERANGE,ESET,EHEAP,EILLINS,ECASE +.define hol0,trppc~,trpim~,reghp~,.limhp +! $Header$ + +#define float 1 +#define hardfp 1 + +LINO_AD = 0 +FILN_AD = 4 + +ERANGE = 1 +ESET = 2 +EFOVFL = 4 +EFUNFL = 5 +EFDIVZ = 7 +EFUND = 011 +ECONV = 012 +EHEAP = 021 +EILLINS = 022 +ECASE = 024 + +#ifdef float +#ifndef hardfp +! sys 060;.data2 4,fptrap / if not commented it will appear as undefined +#endif + sys 060;.data2 010,sig8 + ldfps $07600 +#endif + mov 2(sp),r0 + clr -2(r0) + mov sp,r0 + sub $4,sp + mov 4(sp),(sp) + tst (r0)+ + mov r0,2(sp) +1: + tst (r0)+ + bne 1b + cmp r0,*2(sp) + blo 1f + tst -(r0) +1: + mov r0,4(sp) + jsr pc,__m_a_i_n +! next two lines for as long as tail needs printf +! mov r0,-(sp) +! jsr pc,*$_exit + sys 1 + + .sect .data +hol0: .data2 0,0 ! line no + .data2 0,0 ! file +trppc~: .data2 0 +trpim~: .data2 0 +reghp~: .data2 _end +.limhp: .data2 _end + + .sect .text +sig8: +#ifdef float + mov r0,-(sp) + stst r0 + mov 1f(r0),-(sp) + jsr pc,trp~ + sys 060;.data2 010,sig8 + mov (sp)+,r0 + rti + + .sect .data +1: .data2 EILLINS, EILLINS, EFDIVZ, ECONV, EFOVFL, EFUNFL, EFUND, EILLINS + .sect .text +#endif diff --git a/mach/pdp/libem/hlt.s b/mach/pdp/libem/hlt.s new file mode 100644 index 00000000..0fae864f --- /dev/null +++ b/mach/pdp/libem/hlt.s @@ -0,0 +1,12 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.sect .text +.define hlt~ +! $Header$ + +exit = 1 + +hlt~: + mov (sp)+,r0 + bne 1f + sys exit +1: .data2 4 diff --git a/mach/pdp/libem/sigtrp.s b/mach/pdp/libem/sigtrp.s new file mode 100644 index 00000000..214826a7 --- /dev/null +++ b/mach/pdp/libem/sigtrp.s @@ -0,0 +1,93 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.sect .text +.define sigtrp~ +.define trp~,save~,retu~ +! $Header$ + +indir = 0 +signal = 060 + +sig1: mov sig.trp+0,-(sp) + br 1f +sig2: mov sig.trp+2,-(sp) + br 1f +sig3: mov sig.trp+4,-(sp) + br 1f +sig4: mov sig.trp+6,-(sp) + br 1f +sig5: mov sig.trp+010,-(sp) + br 1f +sig6: mov sig.trp+012,-(sp) + br 1f +sig7: mov sig.trp+014,-(sp) + br 1f +sig10: mov sig.trp+022,-(sp) + br 1f +sig11: mov sig.trp+024,-(sp) + br 1f +sig12: mov sig.trp+026,-(sp) + br 1f +sig13: mov sig.trp+030,-(sp) + br 1f +sig14: mov sig.trp+032,-(sp) + br 1f +sig15: mov sig.trp+034,-(sp) + br 1f +sig16: mov sig.trp+036,-(sp) + br 1f +1: + jsr pc,trp~ + rti + +sigtrp~: + jsr pc,save~ + tst (sp)+ + mov (sp)+,r1 + mov (sp)+,r0 + ble sig.bad + cmp r0,$020 + bhi sig.bad + mov r0,call+02 + asl r0 + mov sig.trp-2(r0),r3 + cmp r1,$0400 + bhis 1f + mov sig.adr-2(r0),r2 + bne 2f +sig.bad: + mov $-1,r0 +sigbad: + mov r0,-(sp) + mov r0,-(sp) + jmp retu~ +1: cmp r1,$-3 + blo sig.bad + mov r1,r2 + inc r2 + inc r2 +2: mov r1,sig.trp-2(r0) + mov r2,call+04 + sys indir ; .data2 call + bcs sigbad + asr r0 + bcc 1f + mov $-3,-(sp) + clr -(sp) + jmp retu~ +1: mov r3,-(sp) + clr -(sp) + jmp retu~ + +.sect .data +call: sys signal + .data2 0, 0 +sig.trp: + .data2 -2, -2, -2, -2 + .data2 -2, -2, -2, -2 + .data2 -2, -2, -2, -2 + .data2 -2, -2, -2, -2 +sig.adr: + .data2 sig1, sig2, sig3, sig + .data2 sig5, sig6, sig7, 0 + .data2 0, sig10, sig11, sig12 + .data2 sig13, sig14, sig15, sig16 diff --git a/mach/pdp/libpc/makefile b/mach/pdp/libpc/makefile new file mode 100644 index 00000000..ddc6a8e6 --- /dev/null +++ b/mach/pdp/libpc/makefile @@ -0,0 +1,21 @@ +MAKEFILE=../../proto/libg/Makefile +MACHDEF="MACH=pdp -Rbe-p2" "SUF=s" "ASAR=ar" +PCDEF="PREF=pc" "SUB=" "SRC=lang/pc/libpc" +LIBDIR=../lib + +install: + make -f $(MAKEFILE) $(PCDEF) $(MACHDEF) cp + +cmp: + make -f $(MAKEFILE) $(PCDEF) $(MACHDEF) all + cmp head_pc $(LIBDIR)/head_pc + cmp tail_pc $(LIBDIR)/tail_pc + +clean: + -rm -f *.old *.[ce$(SUF)] tail* head* + +opr: + make pr | opr + +pr: + @pr Makefile diff --git a/mach/pdp/libsys/Makefile b/mach/pdp/libsys/Makefile new file mode 100644 index 00000000..7e194f03 --- /dev/null +++ b/mach/pdp/libsys/Makefile @@ -0,0 +1,24 @@ +# $Header$ +all: libmon_o.a + +install: cp + +cp: all + ../../install libmon_o.a tail_mon + +cmp: all + -../../compare libmon_o.a tail_mon + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +clean: + rm -f *.o libmon_o.a + +opr: + make pr | opr + +pr: + @pr `pwd`/Makefile + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/pdp/libsys/compmodule b/mach/pdp/libsys/compmodule new file mode 100755 index 00000000..da10f2f6 --- /dev/null +++ b/mach/pdp/libsys/compmodule @@ -0,0 +1,4 @@ +if pdp -L -O -c -I../../../h -I. $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/pdp/ncg/Makefile b/mach/pdp/ncg/Makefile new file mode 100644 index 00000000..f5e2bda6 --- /dev/null +++ b/mach/pdp/ncg/Makefile @@ -0,0 +1,197 @@ +# $Header$ + +EMHOME=../../.. +#preprocessor flags for table +TABLEFLAGS= +#cgg options +CGGFLAGS= + +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/ncg +CGG=$(EMHOME)/lib/ncgg +CPP=$(EMHOME)/lib/cpp +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/label.c $(CDIR)/main.c \ + $(CDIR)/move.c $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c \ + $(CDIR)/salloc.c $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o label.o \ + main.o move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +label.o: $(CDIR)/label.c + $(CC) -c $(CFLAGS) $(CDIR)/label.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + $(EMHOME)/mach/install cg + +cmp: all + -$(EMHOME)/mach/compare cg + + +tables.c: table $(CGG) + $(CPP) $(TABLEFLAGS) table | $(CGG) $(CGGFLAGS) + -cmp tables.h tables.H || cp tables.H tables.h + +lint: $(CFILES) tables.c + lint $(LINTOPTS) $(PREFLAGS) -I$(CDIR) $(CFILES) tables.c +clean: + rm -f *.o tables.c tables.h debug.out cg tables.H + +distr: tables.c + rm -f tables1.c tables1.h + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + +codegen.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/label.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +label.o: $(CDIR)/label.h +label.o: $(CDIR)/param.h +label.o: tables.h +label.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +main.o: tables.h +move.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/pdp/top/Makefile b/mach/pdp/top/Makefile new file mode 100644 index 00000000..57908427 --- /dev/null +++ b/mach/pdp/top/Makefile @@ -0,0 +1,42 @@ +EMHOME=../../.. +LIBS=$(EMHOME)/modules/lib/libstring.a +PREFLAGS=-I. +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O -DNDEBUG +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +CDIR=$(EMHOME)/mach/proto/top +CFILES=$(CDIR)/top.c $(CDIR)/queue.c +OFILES=top.o queue.o + +all: gen.c + make top + +top: $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) $(LIBS) -o top + +top.o: $(CDIR)/top.c gen.c + $(CC) -c $(CFLAGS) $(CDIR)/top.c + +queue.o: $(CDIR)/queue.c + $(CC) -c $(CFLAGS) $(CDIR)/queue.c + +install: all + $(EMHOME)/mach/install top + +cmp: all + -$(EMHOME)/mach/compare top + +gen.c: table + $(EMHOME)/lib/topgen table + +lint: $(CFILES) + lint $(LINTOPTS) $(PREFLAGS) $(CFILES) + +clean: + rm -f *.o gen.c gen.h top + +top.o: gen.h +top.o: $(CDIR)/top.h +top.o: $(CDIR)/queue.h +queue.o: $(CDIR)/queue.h diff --git a/mach/pmds/cv/Makefile b/mach/pmds/cv/Makefile new file mode 100644 index 00000000..b5bf144f --- /dev/null +++ b/mach/pmds/cv/Makefile @@ -0,0 +1,22 @@ +EMHOME=../../.. + +LDFLAGS = +CFLAGS=-O -I$(EMHOME)/h + +cv: cv.o + $(CC) -o cv $(LDFLAGS) cv.o $(EMHOME)/modules/lib/libobject.a + +install: cv + ../../install cv + +cmp: cv + -../../compare cv + +opr: + make pr | opr + +pr: + @pr `pwd`/cv.c + +clean: + -rm -f *.o *.old cv diff --git a/mach/pmds/cv/pdp_cv.c b/mach/pmds/cv/pdp_cv.c new file mode 100644 index 00000000..b11f6574 --- /dev/null +++ b/mach/pmds/cv/pdp_cv.c @@ -0,0 +1,41 @@ +/* The format of the a.out files produced by the assemblers + is machine dependent. + This program acts as a gateway between two machines and it's effect + is independent of the machine it executes on. + The a.out file is assumed to be made on a pdp-11 + while the target machine is a Philip Microcomputer Development system + +*/ + +#include + +main(argc,argv) char **argv ; { + char i_addr[4]; + short count; + char i_count[2]; + + if (argc != 3) { + fprintf(stderr,"Usage: %s pdp-a.out VU-pmds-a.out\n",argv[0]); + exit(-1); + } + if (freopen(argv[1],"r",stdin)==NULL) { + perror(argv[1]); + exit(-1); + } + if (freopen(argv[2],"w",stdout)==NULL) { + perror(argv[2]); + exit(-1); + } + while (fread(&i_addr,sizeof i_addr,1,stdin)==1) { + putchar(i_addr[1]) ; putchar(i_addr[0]) ; + putchar(i_addr[3]) ; putchar(i_addr[2]) ; + if (fread(&i_count,sizeof i_count,1,stdin)!=1) + exit(fprintf(stderr,"foo\n")); + putchar(i_count[1]) ; putchar(i_count[0]) ; + count= ((i_count[1]&0377)<<8) | (i_count[0]&0377) ; + while (count--) { + putchar(getchar()); + } + } + return 0; +} diff --git a/mach/pmds/cv/vax_cv.c b/mach/pmds/cv/vax_cv.c new file mode 100644 index 00000000..6e210f17 --- /dev/null +++ b/mach/pmds/cv/vax_cv.c @@ -0,0 +1,41 @@ +/* The format of the a.out files produced by the assemblers + is machine dependent. + This program acts as a gateway between two machines and it's effect + is independent of the machine it executes on. + The a.out file is assumed to be made on a vax-11 + while the target machine is a Philips Microcomputer Development system + +*/ + +#include + +main(argc,argv) char **argv ; { + char i_addr[4]; + short count; + char i_count[2]; + + if (argc != 3) { + fprintf(stderr,"Usage: %s vax-a.out VU-pmds-a.out\n",argv[0]); + exit(-1); + } + if (freopen(argv[1],"r",stdin)==NULL) { + perror(argv[1]); + exit(-1); + } + if (freopen(argv[2],"w",stdout)==NULL) { + perror(argv[2]); + exit(-1); + } + while (fread(&i_addr,sizeof i_addr,1,stdin)==1) { + putchar(i_addr[3]) ; putchar(i_addr[2]) ; + putchar(i_addr[1]) ; putchar(i_addr[0]) ; + if (fread(&i_count,sizeof i_count,1,stdin)!=1) + exit(fprintf(stderr,"foo\n")); + putchar(i_count[1]) ; putchar(i_count[0]) ; + count= ((i_count[1]&0377)<<8) | (i_count[0]&0377) ; + while (count--) { + putchar(getchar()); + } + } + return 0; +} diff --git a/mach/pmds/libsys/Makefile b/mach/pmds/libsys/Makefile new file mode 100644 index 00000000..1ae02d21 --- /dev/null +++ b/mach/pmds/libsys/Makefile @@ -0,0 +1,29 @@ +# $Header$ +MACH=pmds +all: libmon_o.a head_em.o + +install: all + ../../install head_em.o head_em + ../../install libmon_o.a tail_mon + + +cmp: all + -../../compare head_em.o head_em + -../../compare libmon_o.a tail_mon + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +head_em.o: head_em.s + $(MACH) -I../../../h -c head_em.s + +clean: + rm -f *.o libmon_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/pmds/libsys/compmodule b/mach/pmds/libsys/compmodule new file mode 100755 index 00000000..02a02173 --- /dev/null +++ b/mach/pmds/libsys/compmodule @@ -0,0 +1,4 @@ +if pmds -L -c $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/pmds4/libsys/Makefile b/mach/pmds4/libsys/Makefile new file mode 100644 index 00000000..c796c26e --- /dev/null +++ b/mach/pmds4/libsys/Makefile @@ -0,0 +1,29 @@ +# $Header$ +MACH=pmds4 +all: libmon_o.a head_em.o + +install: all + ../../install head_em.o head_em + ../../install libmon_o.a tail_mon + + +cmp: all + -../../compare head_em.o head_em + -../../compare libmon_o.a tail_mon + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +head_em.o: head_em.s + $(MACH) -I../../../h -c head_em.s + +clean: + rm -f *.o libmon_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/pmds4/libsys/compmodule b/mach/pmds4/libsys/compmodule new file mode 100755 index 00000000..8d98a6d8 --- /dev/null +++ b/mach/pmds4/libsys/compmodule @@ -0,0 +1,4 @@ +if pmds4 -L -c $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/proto/as/Makefile b/mach/proto/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/proto/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/proto/cg/Makefile b/mach/proto/cg/Makefile new file mode 100644 index 00000000..22f5f603 --- /dev/null +++ b/mach/proto/cg/Makefile @@ -0,0 +1,184 @@ +# $Header$ + +EMHOME=../../.. +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-hbxac +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/cg +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/main.c $(CDIR)/move.c \ + $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c $(CDIR)/salloc.c \ + $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o main.o\ + move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + ../../install cg + +cmp: all + -../../compare cg + +distr: tables.c + rm -f tables1.[ch] + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + + +tables.c: table + -mv tables.h tables.h.save + $(EMHOME)/lib/cpp -P table | $(EMHOME)/lib/cgg > debug.out + -if cmp -s tables.h.save tables.h; then mv tables.h.save tables.h; else exit 0; fi + -if cmp -s /dev/null tables.h; then mv tables.h.save tables.h; else exit 0; fi + +lint: $(CFILES) + lint $(LINTOPTS) $(PREFLAGS) $(CFILES) +clean: + rm -f *.o tables.c tables.h debug.out cg tables.h.save + +codegen.o: $(CDIR)/assert.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +move.o: $(CDIR)/assert.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/proto/fp/Makefile b/mach/proto/fp/Makefile new file mode 100644 index 00000000..eddf2062 --- /dev/null +++ b/mach/proto/fp/Makefile @@ -0,0 +1,282 @@ +EMHOME=../../.. +SUF=s +MACH=m68k4 +ASAR=arch +CFLAGS= +# must use -r option of make so that default rules +# are not loaded +# +# $Header$ +# +EMFLAGS= -L -LIB -I. -O $(CFLAGS) +# AS=ack -m$(MACH) -c.$(SUF) +# CC=ack -m$(MACH) -c.s +# CCFLAGS=$(EMFLAGS) +CDIR=$(EMHOME)/mach/proto/fp + +LIST = cff4.$(SUF) cff8.$(SUF)\ + cfu.$(SUF)\ + cmf4.$(SUF) cmf8.$(SUF)\ + cuf4.$(SUF) cuf8.$(SUF)\ + dvf4.$(SUF) dvf8.$(SUF)\ + fef4.$(SUF) fef8.$(SUF)\ + fif4.$(SUF) fif8.$(SUF)\ + cfi.$(SUF)\ + cif4.$(SUF) cif8.$(SUF)\ + mlf4.$(SUF) mlf8.$(SUF)\ + ngf4.$(SUF) ngf8.$(SUF)\ + sbf4.$(SUF) sbf8.$(SUF)\ + adf4.$(SUF) adf8.$(SUF)\ + zrf4.$(SUF) zrf8.$(SUF)\ + extend.$(SUF) compact.$(SUF)\ + add_ext.$(SUF) div_ext.$(SUF) mul_ext.$(SUF) nrm_ext.$(SUF)\ + sft_ext.$(SUF) sub_ext.$(SUF) zrf_ext.$(SUF)\ + adder.$(SUF) shifter.$(SUF) fptrp.$(SUF) +SLIST = cff4.s cff8.s\ + cfu.s\ + cmf4.s cmf8.s\ + cuf4.s cuf8.s\ + dvf4.s dvf8.s\ + fef4.s fef8.s\ + fif4.s fif8.s\ + cfi.s\ + cif4.s cif8.s\ + mlf4.s mlf8.s\ + ngf4.s ngf8.s\ + sbf4.s sbf8.s\ + adf4.s adf8.s\ + zrf4.s zrf8.s\ + extend.s compact.s\ + add_ext.s div_ext.s mul_ext.s nrm_ext.s\ + sft_ext.s sub_ext.s zrf_ext.s\ + adder.s shifter.s fptrp.s + +SRC = FP_bias.h FP_shift.h FP_trap.h FP_types.h adder.h get_put.h\ + cff4.c cff8.c\ + cfu.c\ + cmf4.c cmf8.c\ + cuf4.c cuf8.c\ + dvf4.c dvf8.c\ + fef4.c fef8.c\ + fif4.c fif8.c\ + cfi.c\ + cif4.c cif8.c\ + mlf4.c mlf8.c\ + ngf4.c ngf8.c\ + sbf4.c sbf8.c\ + adf4.c adf8.c\ + zrf4.c zrf8.c\ + extend.c compact.c\ + add_ext.c div_ext.c mul_ext.c nrm_ext.c\ + sft_ext.c sub_ext.c zrf_ext.c\ + adder.c shifter.c fptrp.e + +all: FP_$(MACH).a + +install: tail_fp + +tail_fp: FP_$(MACH).a + ../../install FP_$(MACH).a tail_fp + +clean: + rm -f $(LIST) FP_$(MACH).a + rm -f $(SLIST) + +opr: + make pr | opr + +pr: + @pr Makefile FP.script $(SRC) + +FP_$(MACH).a: $(LIST) + $(ASAR) rv $@ $? + +fptrp.$(SUF): $(CDIR)/fptrp.e + ack -m$(MACH) $(EMFLAGS) -c $(CDIR)/fptrp.e + +extend.$(SUF) compact.$(SUF): byte_order.h $(CDIR)/get_put.h + +cff4.$(SUF): $(CDIR)/cff4.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/cff4.c + ed - cff4.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) cff4.s + +cff8.$(SUF): $(CDIR)/cff8.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/cff8.c + ed - cff8.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) cff8.s + +cfu.$(SUF): $(CDIR)/cfu.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/cfu.c + ed - cfu.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) cfu.s + +cmf4.$(SUF): $(CDIR)/cmf4.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/cmf4.c + ed - cmf4.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) cmf4.s + +cmf8.$(SUF): $(CDIR)/cmf8.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/cmf8.c + ed - cmf8.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) cmf8.s + +cuf4.$(SUF): $(CDIR)/cuf4.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/cuf4.c + ed - cuf4.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) cuf4.s + +cuf8.$(SUF): $(CDIR)/cuf8.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/cuf8.c + ed - cuf8.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) cuf8.s + +dvf4.$(SUF): $(CDIR)/dvf4.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/dvf4.c + ed - dvf4.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) dvf4.s + +dvf8.$(SUF): $(CDIR)/dvf8.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/dvf8.c + ed - dvf8.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) dvf8.s + +fef4.$(SUF): $(CDIR)/fef4.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/fef4.c + ed - fef4.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) fef4.s + +fef8.$(SUF): $(CDIR)/fef8.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/fef8.c + ed - fef8.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) fef8.s + +fif4.$(SUF): $(CDIR)/fif4.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/fif4.c + ed - fif4.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) fif4.s + +fif8.$(SUF): $(CDIR)/fif8.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/fif8.c + ed - fif8.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) fif8.s + +cfi.$(SUF): $(CDIR)/cfi.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/cfi.c + ed - cfi.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) cfi.s + +cif4.$(SUF): $(CDIR)/cif4.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/cif4.c + ed - cif4.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) cif4.s + +cif8.$(SUF): $(CDIR)/cif8.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/cif8.c + ed - cif8.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) cif8.s + +mlf4.$(SUF): $(CDIR)/mlf4.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/mlf4.c + ed - mlf4.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) mlf4.s + +mlf8.$(SUF): $(CDIR)/mlf8.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/mlf8.c + ed - mlf8.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) mlf8.s + +ngf4.$(SUF): $(CDIR)/ngf4.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/ngf4.c + ed - ngf4.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) ngf4.s + +ngf8.$(SUF): $(CDIR)/ngf8.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/ngf8.c + ed - ngf8.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) ngf8.s + +sbf4.$(SUF): $(CDIR)/sbf4.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/sbf4.c + ed - sbf4.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) sbf4.s + +sbf8.$(SUF): $(CDIR)/sbf8.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/sbf8.c + ed - sbf8.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) sbf8.s + +adf4.$(SUF): $(CDIR)/adf4.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/adf4.c + ed - adf4.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) adf4.s + +adf8.$(SUF): $(CDIR)/adf8.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/adf8.c + ed - adf8.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) adf8.s + +zrf4.$(SUF): $(CDIR)/zrf4.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/zrf4.c + ed - zrf4.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) zrf4.s + +zrf8.$(SUF): $(CDIR)/zrf8.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/zrf8.c + ed - zrf8.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) zrf8.s + +extend.$(SUF): $(CDIR)/extend.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/extend.c + ed - extend.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) extend.s + +compact.$(SUF): $(CDIR)/compact.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/compact.c + ed - compact.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) compact.s + +add_ext.$(SUF): $(CDIR)/add_ext.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/add_ext.c + ed - add_ext.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) add_ext.s + +div_ext.$(SUF): $(CDIR)/div_ext.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/div_ext.c + ed - div_ext.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) div_ext.s + +mul_ext.$(SUF): $(CDIR)/mul_ext.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/mul_ext.c + ed - mul_ext.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) mul_ext.s + +nrm_ext.$(SUF): $(CDIR)/nrm_ext.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/nrm_ext.c + ed - nrm_ext.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) nrm_ext.s + +sft_ext.$(SUF): $(CDIR)/sft_ext.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/sft_ext.c + ed - sft_ext.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) sft_ext.s + +sub_ext.$(SUF): $(CDIR)/sub_ext.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/sub_ext.c + ed - sub_ext.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) sub_ext.s + +zrf_ext.$(SUF): $(CDIR)/zrf_ext.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/zrf_ext.c + ed - zrf_ext.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) zrf_ext.s + +adder.$(SUF): $(CDIR)/adder.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/adder.c + ed - adder.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) adder.s + +shifter.$(SUF): $(CDIR)/shifter.c + ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/shifter.c + ed - shifter.s <$(CDIR)/FP.script + ack -c -m$(MACH) $(EMFLAGS) shifter.s diff --git a/mach/proto/fp/adder.h b/mach/proto/fp/adder.h new file mode 100644 index 00000000..63823af2 --- /dev/null +++ b/mach/proto/fp/adder.h @@ -0,0 +1,15 @@ +/* + (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. + See the copyright notice in the ACK home directory, in the file "Copyright". +*/ + +/* $Header$ */ + +/* + * include file for 32 & 64 bit addition + */ + +typedef struct { + unsigned long h_32; /* higher 32 bits of 64 */ + unsigned long l_32; /* lower 32 bits of 64 */ +} B64; diff --git a/mach/proto/fp/prt_dbl.c b/mach/proto/fp/prt_dbl.c new file mode 100644 index 00000000..4453e412 --- /dev/null +++ b/mach/proto/fp/prt_dbl.c @@ -0,0 +1,32 @@ +/* + (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. + See the copyright notice in the ACK home directory, in the file "Copyright". +*/ + +/* $Header$ */ + +# include "FP_types.h" + +prt_dbl(dbl,size) +DOUBLE *dbl; +int size; +{ +#ifdef PRT_DBL + unsigned long *l; + + fprintf(stderr,"PRT_DBL SIZE = %d ",size); + fprintf(stderr,"_s.p1.fract = 0x%08X ",dbl->_s.p1.fract); + if (size == 8) + fprintf(stderr,"_s.p2 = 0x%08X",dbl->_s.p2); + l = (unsigned long *) dbl; +#ifdef PRT_LONG + fprintf(stderr,"\nl[0] = 0x%08X ",*l++); + if (size == 8) + fprintf(stderr,"l[1] = 0x%08X",*l); +#endif PRT_LONG + putc('\r',stderr); + putc('\n',stderr); + fflush(stderr); +#endif +} + diff --git a/mach/proto/fp/prt_ext.c b/mach/proto/fp/prt_ext.c new file mode 100644 index 00000000..243c7270 --- /dev/null +++ b/mach/proto/fp/prt_ext.c @@ -0,0 +1,30 @@ +/* + (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. + See the copyright notice in the ACK home directory, in the file "Copyright". +*/ + +/* $Header$ */ + +/********************************************************/ +/* + PRINT EXTENDED FORMAT AND MESSAGE + DEBUG ROUTINE +*/ +/********************************************************/ + +#include "FP_types.h" + +prt_ext(m,e) +char *m; +EXTEND *e; +{ +#ifdef PRT_EXT + fprintf(stderr,"%s ",m); + fprintf(stderr,"%c",(e->sign) ? '-' : '+'); + fprintf(stderr,"m1:0x%08X m2:0x%08X ^ %03d 0x%x\n", + e->m1,e->m2,e->exp,e->exp); + fprintf(stderr,"hit any key\n\r"); + fflush(stderr); + getchar(); +#endif +} diff --git a/mach/proto/fp/x b/mach/proto/fp/x new file mode 100644 index 00000000..e69de29b diff --git a/mach/proto/libg/Makefile b/mach/proto/libg/Makefile new file mode 100644 index 00000000..d476d9bb --- /dev/null +++ b/mach/proto/libg/Makefile @@ -0,0 +1,41 @@ +# $Header$ + +MACH=MACHINE +MACHFL=-c.$(SUF) -O -L +SUB = +PREF=pc +ASAR=arch +SRC=lang/pc/libpc +HOME = ../../.. +HEADSRC=$(HOME)/$(SRC)/head_$(PREF).e + +all: head tail + +head: head_$(PREF) + +tail: tail_$(PREF)$(SUB) + +headcp: head + ../../install head_$(PREF) + rm -f head_$(PREF) + +tailcp: tail + ../../install tail_$(PREF)$(SUB) + rm -f tail_$(PREF)$(SUB) + +cp: headcp tailcp + +head_$(PREF): $(HEADSRC) + cp $(HEADSRC) head_$(PREF).e + $(MACH) $(MACHFL) -I$(HOME)/h head_$(PREF).e + mv head_$(PREF).$(SUF) head_$(PREF) + -rm -f head_$(PREF).[ekm$(SUF)] + +tail_$(PREF)$(SUB): + @echo translation test + @$(MACH) $(MACHFL) $(HOME)/mach/proto/libg/barrier.c + @-rm -f barrier.[oeskm] barrier.so + @echo OK + -rm -f tail_$(PREF)$(SUB) + MACH="$(MACH)" MACHFL="$(MACHFL) -LIB" ASAR=$(ASAR) SRC=$(SRC) \ + march $(HOME)/$(SRC) tail_$(PREF)$(SUB) diff --git a/mach/proto/ncg/Makefile b/mach/proto/ncg/Makefile new file mode 100644 index 00000000..f5e2bda6 --- /dev/null +++ b/mach/proto/ncg/Makefile @@ -0,0 +1,197 @@ +# $Header$ + +EMHOME=../../.. +#preprocessor flags for table +TABLEFLAGS= +#cgg options +CGGFLAGS= + +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/ncg +CGG=$(EMHOME)/lib/ncgg +CPP=$(EMHOME)/lib/cpp +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/label.c $(CDIR)/main.c \ + $(CDIR)/move.c $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c \ + $(CDIR)/salloc.c $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o label.o \ + main.o move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +label.o: $(CDIR)/label.c + $(CC) -c $(CFLAGS) $(CDIR)/label.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + $(EMHOME)/mach/install cg + +cmp: all + -$(EMHOME)/mach/compare cg + + +tables.c: table $(CGG) + $(CPP) $(TABLEFLAGS) table | $(CGG) $(CGGFLAGS) + -cmp tables.h tables.H || cp tables.H tables.h + +lint: $(CFILES) tables.c + lint $(LINTOPTS) $(PREFLAGS) -I$(CDIR) $(CFILES) tables.c +clean: + rm -f *.o tables.c tables.h debug.out cg tables.H + +distr: tables.c + rm -f tables1.c tables1.h + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + +codegen.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/label.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +label.o: $(CDIR)/label.h +label.o: $(CDIR)/param.h +label.o: tables.h +label.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +main.o: tables.h +move.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h $(EMHOME)/h/cgg_cg.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h $(EMHOME)/h/cgg_cg.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/proto/top/Makefile b/mach/proto/top/Makefile new file mode 100644 index 00000000..57908427 --- /dev/null +++ b/mach/proto/top/Makefile @@ -0,0 +1,42 @@ +EMHOME=../../.. +LIBS=$(EMHOME)/modules/lib/libstring.a +PREFLAGS=-I. +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O -DNDEBUG +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +CDIR=$(EMHOME)/mach/proto/top +CFILES=$(CDIR)/top.c $(CDIR)/queue.c +OFILES=top.o queue.o + +all: gen.c + make top + +top: $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) $(LIBS) -o top + +top.o: $(CDIR)/top.c gen.c + $(CC) -c $(CFLAGS) $(CDIR)/top.c + +queue.o: $(CDIR)/queue.c + $(CC) -c $(CFLAGS) $(CDIR)/queue.c + +install: all + $(EMHOME)/mach/install top + +cmp: all + -$(EMHOME)/mach/compare top + +gen.c: table + $(EMHOME)/lib/topgen table + +lint: $(CFILES) + lint $(LINTOPTS) $(PREFLAGS) $(CFILES) + +clean: + rm -f *.o gen.c gen.h top + +top.o: gen.h +top.o: $(CDIR)/top.h +top.o: $(CDIR)/queue.h +queue.o: $(CDIR)/queue.h diff --git a/mach/s2650/as/Makefile b/mach/s2650/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/s2650/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/sparc/ce/ce.src/C_exp.c b/mach/sparc/ce/ce.src/C_exp.c new file mode 100644 index 00000000..e9c23889 --- /dev/null +++ b/mach/sparc/ce/ce.src/C_exp.c @@ -0,0 +1,13 @@ +#define CODE_EXPANDER +#include +#include "back.h" + +C_exp( s) +char *s; +{ + s = extnd_name( s); + set_global_visible(s); +#ifdef __solaris__ + fprint(codefile, "\t.type\t%s,#function\n", s); +#endif +} diff --git a/mach/sparc/libsys/fif.s b/mach/sparc/libsys/fif.s new file mode 100644 index 00000000..cdc6791e --- /dev/null +++ b/mach/sparc/libsys/fif.s @@ -0,0 +1,67 @@ +.global fif8, Fd0, Fd1, Fd80000000, Fs80000000, Fs0 + +.align 8 +Fd0: +.double 0r0 +Fd1: +.double 0r1 +FxE15: +.word 0x43300000, 0x0 ! magic const: (a.b + x) - x == a.0 +Fd80000000: +.align 8 +.double 0r4294967296 +Fs80000000: +.single 0r2147483648 +Fs0: +.single 0r0 + +fif8: + ld [%l0], %f0 + ld [%l0+4], %f1 + ld [%l0+8], %f2 + ld [%l0+12], %f3 + fmuld %f0, %f2, %f0 + fmovs %f0, %f6 + fmovs %f1, %f7 + set Fd0, %o0 + ldd [%o0], %f8 + fcmpd %f0, %f8 + nop + fbuge,a 1f + mov %g0, %o1 + set 1, %o1 + fnegs %f0, %f0 +1: + set FxE15, %o0 + ldd [%o0], %f10 + fcmpd %f0, %f10 + nop + fbuge 2f + nop + faddd %f0, %f10, %f4 + fsubd %f4, %f10, %f4 + fsubd %f0, %f4, %f2 + set Fd1, %o0 + ldd [%o0], %f12 +4: fcmpd %f2, %f12 + nop + fbge,a 4b + fsubd %f2, %f12, %f2 +5: fcmpd %f2, %f8 + nop + fbl,a 5b + faddd %f2, %f12, %f2 + fsubd %f0, %f2, %f0 +2: + tst %o1 + bz 3f + nop + fnegs %f0, %f0 +3: + fsubd %f6, %f0, %f2 + st %f0, [%l0] + st %f1, [%l0+4] + st %f2, [%l0+8] + st %f3, [%l0+12] + retl + nop diff --git a/mach/sparc/libsys/msync.s b/mach/sparc/libsys/msync.s new file mode 100644 index 00000000..397f934f --- /dev/null +++ b/mach/sparc/libsys/msync.s @@ -0,0 +1,3 @@ +#include "SYS.h" + +SYS_call_3(msync) diff --git a/mach/sun2/cv/Makefile b/mach/sun2/cv/Makefile new file mode 100644 index 00000000..dbb54a7c --- /dev/null +++ b/mach/sun2/cv/Makefile @@ -0,0 +1,25 @@ +EMHOME = ../../.. +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +INCLUDE = $(EMHOME)/h +CFLAGS = -I. -I$(INCLUDE) -O -DMACH=1 +TARGETS = cv + +all: $(TARGETS) + +install: all + ../../install cv + +cmp: all + ../../compare cv + +cv: cv.o + $(CC) $(LDFLAGS) -o cv cv.o $(LIBOBJ) + +clean: + rm -f $(TARGETS) *.o nohup.out Out + +pr: + @pr Makefile cv.c + +opr: + make pr | opr diff --git a/mach/sun2/libsys/Makefile b/mach/sun2/libsys/Makefile new file mode 100644 index 00000000..9132faab --- /dev/null +++ b/mach/sun2/libsys/Makefile @@ -0,0 +1,29 @@ +# $Header$ +MACH=sun2 +all: libmon_o.a head_em.o + +install: all + ../../install head_em.o head_em + ../../install libmon_o.a tail_mon + + +cmp: all + -../../compare head_em.o head_em + -../../compare libmon_o.a tail_mon + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +head_em.o: head_em.s + $(MACH) -I../../../h -c head_em.s + +clean: + rm -f *.o libmon_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/sun2/libsys/compmodule b/mach/sun2/libsys/compmodule new file mode 100755 index 00000000..0e6fe927 --- /dev/null +++ b/mach/sun2/libsys/compmodule @@ -0,0 +1,4 @@ +if sun2 -c -L $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/sun3/ce/Makefile b/mach/sun3/ce/Makefile new file mode 100644 index 00000000..9d1559ed --- /dev/null +++ b/mach/sun3/ce/Makefile @@ -0,0 +1,38 @@ +EMHOME=../../.. +BACK=$(EMHOME)/lib/ceg/ce_back +CEG = $(EMHOME)/lib/ceg/util +AR = ar + +all: back.a + make -f $(CEG)/make_own + +install: back.a + make -f $(CEG)/make_own install + +cmp: back.a + -make -f $(CEG)/make_own cmp + +pr: + @pr Makefile EM_table mach.h mach.c as_table as.h as.c \ + Make.back do_close.c do_open.c end_back.c misc.c output.c relocation.c + +opr: + make pr | opr + +# total cleanup +clean: + make -f $(CEG)/make_own clean + rm -rf back back.a + +# only remove ce, ceg, and back directories +dclean: + make -f $(CEG)/make_own dclean + rm -rf back + +back.a: do_close.c do_open.c end_back.c misc.c output.c relocation.c + -mkdir back + cp $(BACK)/obj_back/*h back + cp Make.back back/Makefile + cd back; make ; cd .. + $(AR) r back.a back/*o; + -sh -c 'ranlib back.a' diff --git a/mach/sun3/cv/Makefile b/mach/sun3/cv/Makefile new file mode 100644 index 00000000..7dc412a9 --- /dev/null +++ b/mach/sun3/cv/Makefile @@ -0,0 +1,28 @@ +EMHOME = ../../.. +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +INCLUDE = $(EMHOME)/h +CFLAGS = -I. -I$(INCLUDE) -O -DMACH=2 +TARGETS = cv + +all: $(TARGETS) + +install: all + ../../install cv + +cmp: all + ../../compare cv + +cv: cv.o + $(CC) $(LDFLAGS) -o cv cv.o $(LIBOBJ) + +Xcv: Xcv.o + $(CC) $(LDFLAGS) -o Xcv Xcv.o $(LIBOBJ) + +clean: + rm -f $(TARGETS) *.o nohup.out Out + +pr: + @pr Makefile cv.c + +opr: + make pr | opr diff --git a/mach/sun3/libce/Makefile b/mach/sun3/libce/Makefile new file mode 100644 index 00000000..fa471e2f --- /dev/null +++ b/mach/sun3/libce/Makefile @@ -0,0 +1,42 @@ +# $Header$ + +EMHOME=../../.. + +EMOBJ = aar.o cii.o cmi.o cms.o cmu.o csa.o csb.o cuu.o dia.o exg.o fat.o \ + inn.o lar.o los.o mon.o nop.o sar.o set.o shp.o sts.o trp.o trpstr.o + +FOBJ = adf4.o adf8.o cff.o cfi.o cfu.o cif.o cmf4.o cmf8.o cuf.o dvf4.o \ + dvf8.o fef4.o fef8.o fif4.o fif8.o mlf4.o mlf8.o sbf4.o sbf8.o vars.o + +OBJ = $(EMOBJ) $(FOBJ) + +all: libext.a head_em.sun.o + +.s.o: + sun3 -c $*.s + +libext.a: $(OBJ) + for i in $(OBJ) ; do ../../../lib/sun3/cv -u $$i $$i.X ; mv $$i.X $$i ; done + ar rv libext.a $(OBJ) + ranlib libext.a + +head_em.sun.o: head_em.o + ../../../lib/sun3/cv -u head_em.o head_em.sun.o + +install: all + ../../install libext.a tail_ext + ../../install head_em.sun.o head_ext + +cmp: all + -../../compare libext.a tail_ext + -../../compare head_em.sun.o head_ext + +clean: + rm -f *.[oa] + +pr: + +opr: + +$(EMOBJ): $(EMHOME)/lib/m68020/tail_em + aal x $(EMHOME)/lib/m68020/tail_em $(EMOBJ) diff --git a/mach/sun3/libsys/Makefile b/mach/sun3/libsys/Makefile new file mode 100644 index 00000000..5861ef1d --- /dev/null +++ b/mach/sun3/libsys/Makefile @@ -0,0 +1,29 @@ +# $Header$ +MACH=m68020 +all: libmon_o.a head_em.o + +install: all + ../../install head_em.o head_em + ../../install libmon_o.a tail_mon + + +cmp: all + -../../compare head_em.o head_em + -../../compare libmon_o.a tail_mon + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +head_em.o: head_em.s + $(MACH) -I../../../h -c head_em.s + +clean: + rm -f *.o libmon_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/sun3/libsys/Xstat.c b/mach/sun3/libsys/Xstat.c new file mode 100644 index 00000000..b4c68899 --- /dev/null +++ b/mach/sun3/libsys/Xstat.c @@ -0,0 +1,58 @@ +#include +#include + +static Xcvt(); + +int +stat(path, buf) + char *path; + struct stat *buf; +{ + char Xbuf[100]; + int retval; + + retval = _stat(path, Xbuf); + Xcvt(Xbuf, (char *)buf); + return retval; +} + +int +lstat(path, buf) + char *path; + struct stat *buf; +{ + char Xbuf[100]; + int retval; + + retval = _lstat(path, Xbuf); + Xcvt(Xbuf, (char *)buf); + return retval; +} + +int +fstat(fd, buf) + int fd; + struct stat *buf; +{ + char Xbuf[100]; + int retval; + + retval = __fstat(fd, Xbuf); + Xcvt(Xbuf, (char *)buf); + return retval; +} + +static +Xcvt(buf, statbuf) + char *buf, *statbuf; +{ + register char *s, *t; + register int i; + + s = buf; t = statbuf; + *t++ = *s++; *t++ = *s++; + *t++ = 0; *t++ = 0; + for (i = 14; i; i--) *t++ = *s++; + *t++ = 0; *t++ = 0; + for (i = 44; i; i--) *t++ = *s++; +} diff --git a/mach/sun3/libsys/_Xstat.c b/mach/sun3/libsys/_Xstat.c new file mode 100644 index 00000000..ac8ad0e8 --- /dev/null +++ b/mach/sun3/libsys/_Xstat.c @@ -0,0 +1,32 @@ +#include +#include + +static Xcvt(); + +int +_fstat(fd, buf) + int fd; + struct stat *buf; +{ + char Xbuf[100]; + int retval; + + retval = __fstat(fd, Xbuf); + Xcvt(Xbuf, (char *)buf); + return retval; +} + +static +Xcvt(buf, statbuf) + char *buf, *statbuf; +{ + register char *s, *t; + register int i; + + s = buf; t = statbuf; + *t++ = *s++; *t++ = *s++; + *t++ = 0; *t++ = 0; + for (i = 14; i; i--) *t++ = *s++; + *t++ = 0; *t++ = 0; + for (i = 44; i; i--) *t++ = *s++; +} diff --git a/mach/sun3/libsys/compmodule b/mach/sun3/libsys/compmodule new file mode 100755 index 00000000..253624cc --- /dev/null +++ b/mach/sun3/libsys/compmodule @@ -0,0 +1,4 @@ +if sun3 -c -L $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/vax4/as/Makefile b/mach/vax4/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/vax4/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/vax4/ce/Makefile b/mach/vax4/ce/Makefile new file mode 100644 index 00000000..badc8d8a --- /dev/null +++ b/mach/vax4/ce/Makefile @@ -0,0 +1,38 @@ +EMHOME=../../.. +BACK=$(EMHOME)/lib/ceg/ce_back +CEG = $(EMHOME)/lib/ceg/util +AR = ar + +all: back.a + make -f $(CEG)/make_own + +install: back.a + make -f $(CEG)/make_own install + +cmp: back.a + -make -f $(CEG)/make_own cmp + +pr: + @pr Makefile EM_table mach.h mach.c as_table as.h as.c \ + Make.back do_close.c do_open.c end_back.c misc.c output.c relocation.c + +opr: + make pr | opr + +# total cleanup +clean: + make -f $(CEG)/make_own clean + rm -rf back back.a + +# only remove ce, ceg, and back directories +dclean: + make -f $(CEG)/make_own dclean + rm -rf back + +back.a: do_close.c do_open.c end_back.c output.c relocation.c + -mkdir back + cp $(BACK)/obj_back/*h back + cp Make.back back/Makefile + cd back; make ; cd .. + $(AR) r back.a back/*o; + -sh -c 'ranlib back.a' diff --git a/mach/vax4/cg/Makefile b/mach/vax4/cg/Makefile new file mode 100644 index 00000000..22f5f603 --- /dev/null +++ b/mach/vax4/cg/Makefile @@ -0,0 +1,184 @@ +# $Header$ + +EMHOME=../../.. +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-hbxac +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/cg +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/main.c $(CDIR)/move.c \ + $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c $(CDIR)/salloc.c \ + $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o main.o\ + move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + ../../install cg + +cmp: all + -../../compare cg + +distr: tables.c + rm -f tables1.[ch] + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + + +tables.c: table + -mv tables.h tables.h.save + $(EMHOME)/lib/cpp -P table | $(EMHOME)/lib/cgg > debug.out + -if cmp -s tables.h.save tables.h; then mv tables.h.save tables.h; else exit 0; fi + -if cmp -s /dev/null tables.h; then mv tables.h.save tables.h; else exit 0; fi + +lint: $(CFILES) + lint $(LINTOPTS) $(PREFLAGS) $(CFILES) +clean: + rm -f *.o tables.c tables.h debug.out cg tables.h.save + +codegen.o: $(CDIR)/assert.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +move.o: $(CDIR)/assert.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/vax4/cv/Makefile b/mach/vax4/cv/Makefile new file mode 100644 index 00000000..5cfa97a6 --- /dev/null +++ b/mach/vax4/cv/Makefile @@ -0,0 +1,25 @@ +EMHOME = ../../.. +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +INCLUDE = $(EMHOME)/h +CFLAGS = -I. -I$(INCLUDE) -O +TARGETS = cv + +all: $(TARGETS) + +install: all + ../../install cv + +cmp: all + ../../compare cv + +cv: cv.o + $(CC) $(LDFLAGS) -o cv cv.o $(LIBOBJ) + +clean: + rm -f $(TARGETS) *.o nohup.out Out + +pr: + @pr Makefile cv.c + +opr: + make pr | opr diff --git a/mach/vax4/libbsd4_1a/Makefile b/mach/vax4/libbsd4_1a/Makefile new file mode 100644 index 00000000..b38eda1a --- /dev/null +++ b/mach/vax4/libbsd4_1a/Makefile @@ -0,0 +1,30 @@ +# $Header$ +all: head_em.o libmon_o.a + +install: cp + +cp: all + ../../install head_em.o head_em + ../../install libmon_o.a tail_mon + +cmp: all + -../../compare head_em.o head_em + -../../compare libmon_o.a tail_mon + + +head_em.o: head_em.s + vax4 -I../../../h -c head_em.s + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +clean: + rm -f *.o libmon_o.a + +opr: + make pr | opr + +pr: + @pr `pwd`/Makefile `pwd`/head_em.s + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/vax4/libbsd4_1a/compmodule b/mach/vax4/libbsd4_1a/compmodule new file mode 100755 index 00000000..67777e8a --- /dev/null +++ b/mach/vax4/libbsd4_1a/compmodule @@ -0,0 +1,4 @@ +if vax4 -O -c -I../../../h -I. $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/vax4/libbsd4_2/Makefile b/mach/vax4/libbsd4_2/Makefile new file mode 100644 index 00000000..ff816bd1 --- /dev/null +++ b/mach/vax4/libbsd4_2/Makefile @@ -0,0 +1,27 @@ +# $Header$ +install: cp + +cp: all + ../../install head_em.o head_em + ../../install tail_mon + +cmp: all + -../../compare head_em.o head_em + -../../compare tail_mon + +all: head_em tail_mon + +head_em: head_em.s + vax4 -I../../../h -c head_em.s + +tail_mon: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . tail_mon + +clean: + rm -f *.o tail_mon +opr: + make pr | opr +pr: + @pr `pwd`/Makefile `pwd`/head_em.s + @pr -l33 `tail +1 LIST|sort` diff --git a/mach/vax4/libbsd4_2/compmodule b/mach/vax4/libbsd4_2/compmodule new file mode 100755 index 00000000..3b054dea --- /dev/null +++ b/mach/vax4/libbsd4_2/compmodule @@ -0,0 +1,4 @@ +if vax4 -O -c -L -I../../../h -I. $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/vax4/libem/Makefile b/mach/vax4/libem/Makefile new file mode 100644 index 00000000..7588a8ea --- /dev/null +++ b/mach/vax4/libem/Makefile @@ -0,0 +1,33 @@ +# $Header$ +MACH=vax4 +ASAR=aal +all: libem_o.a end.a + +install: all + ../../install libem_o.a tail_em + ../../install end.a end_em + +cmp: all + -../../compare libem_o.a tail_em + -../../compare end.a end_em + +end.a: em_end.s etext.s edata.s end.s + $(MACH) -I../../../h -c em_end.s + $(MACH) -I../../../h -c edata.s + $(MACH) -I../../../h -c etext.s + $(MACH) -I../../../h -c end.s + $(ASAR) cr end.a em_end.o etext.o edata.o end.o + +libem_o.a: libem_s.a + ASAR=$(ASAR) ; export ASAR ;\ + march . libem_o.a + +clean: + rm -f *.o libem_o.a end.a + +opr : + make pr | opr + +pr: + @arch pv libem_s.a | pr -h `pwd`/libem_s.a + @pr `pwd`/em_end.s `pwd`/edata.s `pwd`/etext.s `pwd`/end.s diff --git a/mach/vax4/libem/compmodule b/mach/vax4/libem/compmodule new file mode 100755 index 00000000..67777e8a --- /dev/null +++ b/mach/vax4/libem/compmodule @@ -0,0 +1,4 @@ +if vax4 -O -c -I../../../h -I. $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/vax4/libem/edata.s b/mach/vax4/libem/edata.s new file mode 100644 index 00000000..f53adc10 --- /dev/null +++ b/mach/vax4/libem/edata.s @@ -0,0 +1,9 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _edata +.sect .data + .align 4 + .sect .data +_edata: diff --git a/mach/vax4/libem/em_end.s b/mach/vax4/libem/em_end.s new file mode 100644 index 00000000..a062368d --- /dev/null +++ b/mach/vax4/libem/em_end.s @@ -0,0 +1,22 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define endtext,enddata,endbss,__end +.sect .text + .align 4 +.sect .rom + .align 4 +.sect .data + .align 4 +.sect .bss + .align 4 +.sect .end ! only for declaration of _end, __end and endbss. + + .sect .text +endtext: + .sect .data +enddata: + .sect .end +__end: +endbss: diff --git a/mach/vax4/libem/end.s b/mach/vax4/libem/end.s new file mode 100644 index 00000000..93a1e6e0 --- /dev/null +++ b/mach/vax4/libem/end.s @@ -0,0 +1,7 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _end +.sect .end ! only for declaration of _end, __end and endbss. +_end: diff --git a/mach/vax4/libem/etext.s b/mach/vax4/libem/etext.s new file mode 100644 index 00000000..8c7453cb --- /dev/null +++ b/mach/vax4/libem/etext.s @@ -0,0 +1,9 @@ +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _etext +.sect .text + .align 4 + .sect .text +_etext: diff --git a/mach/vax4/libem/head_em.s b/mach/vax4/libem/head_em.s new file mode 100644 index 00000000..2124e04b --- /dev/null +++ b/mach/vax4/libem/head_em.s @@ -0,0 +1,93 @@ +#include "system.h" +#include "em_abs.h" +#ifdef BSD42 +#include "/usr/include/syscall.h" +#endif BSD42 + + # $Header$ + +.globl hol0 +.globl .reghp +.globl .trppc +.globl .trpim + + # run time startoff + .word 0 + bispsw $0100 # set FU(0100) + movl 4(sp),r0 + clrl -4(r0) + movl sp,r0 + movl (r0)+,r1 + movl r0,r2 +a1: + tstl (r0)+ + bneq a1 + cmpl r0,(r2) + blssu a2 + tstl -(r0) +a2: + pushl r0 + pushl r2 + pushl r1 + movl $m1,ap + chmk (ap)+ # catch floating point exception + calls $3,_m_a_i_n + movl $m2,ap + movl r0,6(ap) + chmk (ap)+ + halt + + .align 1 +sig8: + .word 0x0000 + pushl 8(ap) + movl (sp)+,ap + pushl tab [ap] + jsb .trp + movl $m1,ap + chmk (ap)+ + ret + + .data +#ifdef BSD42 +m1: + .word SYS_sigvec + .long 3 + .long 8 + .long m1a + .long 0 +m1a: + .long sig8 + .long 0 + .long 0 +#else BSD42 +m1: + .word 48 + .long 2 + .long 8 + .long sig8 +#endif BSD42 +m2: + .word 1 + .long 1 + .long 0 +.reghp: + .long _end +hol0: + .space 8 +.trppc: + .space 4 +.trpim: + .long 0 +tab: + .long 0 + .long EIOVFL + .long EIDIVZ + .long EFOVFL + .long EFDIVZ + .long EFUNFL + .long EILLINS + .long EARRAY + .long EFOVFL + .long EFDIVZ + .long EFUNFL diff --git a/mach/vax4/libem/system.h b/mach/vax4/libem/system.h new file mode 100644 index 00000000..56ac7fac --- /dev/null +++ b/mach/vax4/libem/system.h @@ -0,0 +1,4 @@ +/* $Header$ */ +/*#define BSD42 */ +/*#define BSD41c */ +#define BSD41a diff --git a/mach/vax4/libem/vars.s b/mach/vax4/libem/vars.s new file mode 100644 index 00000000..cafb1743 --- /dev/null +++ b/mach/vax4/libem/vars.s @@ -0,0 +1,15 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .data +.define hol0 +.define .reghp +.define .trppc +.define .trpim + +hol0: + .space 8 +.trppc: + .space 4 +.trpim: + .data4 0 +.reghp: + .data4 __end diff --git a/mach/vax4/libsysV_2/Makefile b/mach/vax4/libsysV_2/Makefile new file mode 100644 index 00000000..b38eda1a --- /dev/null +++ b/mach/vax4/libsysV_2/Makefile @@ -0,0 +1,30 @@ +# $Header$ +all: head_em.o libmon_o.a + +install: cp + +cp: all + ../../install head_em.o head_em + ../../install libmon_o.a tail_mon + +cmp: all + -../../compare head_em.o head_em + -../../compare libmon_o.a tail_mon + + +head_em.o: head_em.s + vax4 -I../../../h -c head_em.s + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +clean: + rm -f *.o libmon_o.a + +opr: + make pr | opr + +pr: + @pr `pwd`/Makefile `pwd`/head_em.s + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/vax4/libsysV_2/compmodule b/mach/vax4/libsysV_2/compmodule new file mode 100755 index 00000000..3b054dea --- /dev/null +++ b/mach/vax4/libsysV_2/compmodule @@ -0,0 +1,4 @@ +if vax4 -O -c -L -I../../../h -I. $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/vax4/top/Makefile b/mach/vax4/top/Makefile new file mode 100644 index 00000000..57908427 --- /dev/null +++ b/mach/vax4/top/Makefile @@ -0,0 +1,42 @@ +EMHOME=../../.. +LIBS=$(EMHOME)/modules/lib/libstring.a +PREFLAGS=-I. +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O -DNDEBUG +LDFLAGS=$(PFLAGS) +LINTOPTS=-bx +CDIR=$(EMHOME)/mach/proto/top +CFILES=$(CDIR)/top.c $(CDIR)/queue.c +OFILES=top.o queue.o + +all: gen.c + make top + +top: $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) $(LIBS) -o top + +top.o: $(CDIR)/top.c gen.c + $(CC) -c $(CFLAGS) $(CDIR)/top.c + +queue.o: $(CDIR)/queue.c + $(CC) -c $(CFLAGS) $(CDIR)/queue.c + +install: all + $(EMHOME)/mach/install top + +cmp: all + -$(EMHOME)/mach/compare top + +gen.c: table + $(EMHOME)/lib/topgen table + +lint: $(CFILES) + lint $(LINTOPTS) $(PREFLAGS) $(CFILES) + +clean: + rm -f *.o gen.c gen.h top + +top.o: gen.h +top.o: $(CDIR)/top.h +top.o: $(CDIR)/queue.h +queue.o: $(CDIR)/queue.h diff --git a/mach/xenix3/cv/Makefile b/mach/xenix3/cv/Makefile new file mode 100644 index 00000000..2d6afc8c --- /dev/null +++ b/mach/xenix3/cv/Makefile @@ -0,0 +1,30 @@ +EMHOME = ../../.. +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +INCLUDE = $(EMHOME)/h +CFLAGS = -I. -I$(INCLUDE) -O +TARGETS = cv chstack + +all: $(TARGETS) + +install: all + ../../install cv + ../../install chstack + +cmp: all + -../../compare cv + -../../compare chstack + +cv: cv.o + $(CC) $(LDFLAGS) -o cv cv.o $(LIBOBJ) + +chstack: chstack.o + $(CC) $(LDFLAGS) -o chstack chstack.o + +clean: + rm -f $(TARGETS) *.o nohup.out Out + +pr: + @pr Makefile cv.c chstack.c + +opr: + make pr | opr diff --git a/mach/xenix3/libsys/Makefile b/mach/xenix3/libsys/Makefile new file mode 100644 index 00000000..8585991a --- /dev/null +++ b/mach/xenix3/libsys/Makefile @@ -0,0 +1,27 @@ +# $Header$ +MACH=xenix3 +all: libmon_o.a head_em.o + +install: all + ../../install libmon_o.a tail_mon + ../../install head_em.o head_em + +cmp: all + -../../compare libmon_o.a tail_mon + -../../compare head_em.o head_em + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +head_em.o: head_em.s + $(MACH) -O -c head_em.s +clean: + rm -f *.o libmon_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/xenix3/libsys/_pipe.s b/mach/xenix3/libsys/_pipe.s new file mode 100644 index 00000000..e01d6c13 --- /dev/null +++ b/mach/xenix3/libsys/_pipe.s @@ -0,0 +1,13 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define __pipe +.sect .text +__pipe: + mov ax,42 + call syscal + mov dx,bx + jae 1f + mov (_errno),ax + mov ax,-1 + cwd +1: + ret diff --git a/mach/xenix3/libsys/_wait.s b/mach/xenix3/libsys/_wait.s new file mode 100644 index 00000000..274857b8 --- /dev/null +++ b/mach/xenix3/libsys/_wait.s @@ -0,0 +1,13 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define __wait +.sect .text +__wait: + mov ax,7 + call syscal + mov dx,bx + jae 1f + mov (_errno),ax + mov ax,-1 + cwd +1: + ret diff --git a/mach/xenix3/libsys/compmodule b/mach/xenix3/libsys/compmodule new file mode 100755 index 00000000..d963eafb --- /dev/null +++ b/mach/xenix3/libsys/compmodule @@ -0,0 +1,4 @@ +if xenix3 -c -L $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/z80/as/Makefile b/mach/z80/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/z80/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/z80/cg/Makefile b/mach/z80/cg/Makefile new file mode 100644 index 00000000..22f5f603 --- /dev/null +++ b/mach/z80/cg/Makefile @@ -0,0 +1,184 @@ +# $Header$ + +EMHOME=../../.. +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-hbxac +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/cg +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/main.c $(CDIR)/move.c \ + $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c $(CDIR)/salloc.c \ + $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o main.o\ + move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + ../../install cg + +cmp: all + -../../compare cg + +distr: tables.c + rm -f tables1.[ch] + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + + +tables.c: table + -mv tables.h tables.h.save + $(EMHOME)/lib/cpp -P table | $(EMHOME)/lib/cgg > debug.out + -if cmp -s tables.h.save tables.h; then mv tables.h.save tables.h; else exit 0; fi + -if cmp -s /dev/null tables.h; then mv tables.h.save tables.h; else exit 0; fi + +lint: $(CFILES) + lint $(LINTOPTS) $(PREFLAGS) $(CFILES) +clean: + rm -f *.o tables.c tables.h debug.out cg tables.h.save + +codegen.o: $(CDIR)/assert.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +move.o: $(CDIR)/assert.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/z80/int/Makefile b/mach/z80/int/Makefile new file mode 100644 index 00000000..179c4658 --- /dev/null +++ b/mach/z80/int/Makefile @@ -0,0 +1,44 @@ +EMHOME=../../.. +SRC = em.s atof.s fpp.s mli4.s dvu4.s dvi4.s eb.s +OBJ = em.o atof.o fpp.o mli4.o dvu4.o dvi4.o eb.o +DLSRC = dl.c dlbin.c +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +LDFLAGS = + +CFLAGS = -O -I$(EMHOME)/h + +.s.o: + z80 -c -I$(EMHOME)/h $*.s + +all: int.hex dl dlbin cv + +install: all + @echo "nothing is installed" + +cmp: all + @echo "nothing is compared" + +clean: + rm -f *.o a.out dl dlbin *.hex cv + +pr: + @pr Makefile $(SRC) $(DLSRC) cv.c + +opr: + make pr | opr + +a.out: $(OBJ) + $(EMHOME)/lib/em_led -b0:0x100 -a0:2 -a1:2 -a2:2 -a3:2 $(OBJ) + +int.hex: a.out dlbin + ./dlbin a.out > int.hex + ./dosort int.hex + +dl: dl.o + $(CC) $(LDFLAGS) -o dl dl.o + +dlbin: dlbin.o + $(CC) $(LDFLAGS) -o dlbin dlbin.o $(LIBOBJ) + +cv: cv.o + $(CC) $(LDFLAGS) -o cv cv.o diff --git a/mach/z80/int/dlbin.c b/mach/z80/int/dlbin.c new file mode 100644 index 00000000..bdf6fc7e --- /dev/null +++ b/mach/z80/int/dlbin.c @@ -0,0 +1,167 @@ +/* + * Download Z80 load module into the RC702 + * + * Adapted (untested) to new ack.out format by + * Ceriel Jacobs, Vrije Universiteit, Amsterdam + */ +#include +#include +#include + +int disp = 0; + +char hex[] = "0123456789ABCDEF"; + +#define DATTYPE 0 +#define EOFTYPE 1 +#define SEGTYPE 2 +#define PCTYPE 3 + +#define MAXBYTE 32 + +char *progname; + +struct outhead ohead; +struct outsect sect[MAXSECT]; + +long pc; + +main(argc,argv) char **argv; { + register unsigned nd; + register char *s; + int first = 1; + int i; + + progname = argv[0]; + while (argc > 1 && argv[1][0] == '-') { + switch (argv[1][1]) { + case 'd': + /* displacement at load time */ + disp = atoi(&argv[1][2]); + break; + } + argc--; + argv++; + } + s = "a.out"; + if (argc == 2) + s = argv[1]; + else if (argc != 1) { + fprintf(stderr,"usage: %s [flags] [object file]\n",progname); + exit(-1); + } + if (! rd_open(s)) { + fprintf(stderr,"%s: can't open %s\n",progname,s); + exit(-1); + } + rd_ohead(&ohead); + if (ohead.oh_flags & HF_LINK) { + fprintf(stderr,"%s: %s contains unresolved references\n",progname,s); + exit(-1); + } + rd_sect(sect, ohead.oh_nsect); + for (i = 0; i < ohead.oh_nsect; i++) { + rd_outsect(i); + pc = sect[i].os_base; + if (first) { + first = 0; + putchar('L'); + putchar('S'); + } + segment(i); + while (sect[i].os_size) { + unsigned int sz = 8096, fl; + extern char *calloc(); + register char *buf; + char *pbuf; + + if (sz > sect[i].os_size) sz = sect[i].os_size; + sect[i].os_size -= sz; + pbuf = buf = calloc(sz, 1); + if (fl = sect[i].os_flen) { + if (fl > sz) fl = sz; + sect[i].os_flen -= fl; + + rd_emit(buf, (long) fl); + } + while (sz >= MAXBYTE) { + data(MAXBYTE, (int) pc, buf); + sz -= MAXBYTE; + buf += MAXBYTE; + pc += MAXBYTE; + } + if (sz > 0) { + data(sz, (int) pc, buf); + } + free(pbuf); + } + } + if (first == 0) eof(); + exit(0); +} + +segment(sg) { + + newline(2,0,SEGTYPE); + word(sg); + endline(); +} + +data(nd,pc,buf) + register char *buf; + int pc; +{ + register i; + + newline(nd, pc+disp, DATTYPE); + for (i = 0; i < nd; i++) { + byte(*buf++); + } + endline(); +} + +int check, bytecount; + +newline(n,pc,typ) { + + check = 0; + bytecount = n+5; + putchar('\n'); /* added instruction */ + putchar(':'); + byte(n); + word(pc); + byte(typ); +} + +endline() { + + byte(-check); + assert(bytecount == 0); +} + +word(w) { + + byte(w>>8); + byte(w); +} + +byte(b) { + + check += b; + bytecount--; + putchar(hex[(b>>4) & 017]); + putchar(hex[b & 017]); +} + +rd_fatal() +{ + fprintf(stderr, "%s: Read error\n", progname); + exit(-1); +} + +eof() { + + newline(0,0,EOFTYPE); + byte(0xFF); + putchar('\n'); +} diff --git a/mach/z80/int/int22 b/mach/z80/int/int22 new file mode 100644 index 00000000..62e8802e --- /dev/null +++ b/mach/z80/int/int22 @@ -0,0 +1,31 @@ +# $Revision$ +var w=2 +var p=2 +var s=2 +var l=4 +var f=4 +var d=4 +var M=int +var NAME=int22 +var LIB=lib/int22/tail_ +var RT=lib/int22/head_ +var SIZE_FLAG=-sm +var CPP_F=-DCPM=CPM +var INCLUDES=-I{EM}/include/_tail_cc -I{EM}/include/_tail_mon +name asld + from .k.m.a.g + to .out + outfile e.out + program {EM}/lib/em_ass + mapflag -l* LNAME={EM}/{LIB}* + mapflag -+* ASS_F={ASS_F?} -+* + mapflag --* ASS_F={ASS_F?} --* + mapflag -s* SIZE_FLAG=-s* + args {SIZE_FLAG} \ + ({RTS}:.b.c={EM}/{RT}cc) ({RTS}:.p={EM}/{RT}pc) -o > < \ + (.p:{TAIL}={EM}/{LIB}pc) \ + (.b:{TAIL}={EM}/{LIB}bc) \ + (.b.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \ + (.b.c.p:{TAIL}={EM}/{LIB}mon) + linker +end diff --git a/mach/z80/libem/Makefile b/mach/z80/libem/Makefile new file mode 100644 index 00000000..3529a29a --- /dev/null +++ b/mach/z80/libem/Makefile @@ -0,0 +1,29 @@ +# $Header$ +MACH=z80 +all: libem_o.a end.o + +install: all + ../../install end.o end_em + ../../install libem_o.a tail_em + + +cmp: all + -../../compare end.o end_em + -../../compare libem_o.a tail_em + +libem_o.a: libem_s.a + ASAR=aal ; export ASAR ;\ + march . libem_o.a + +end.o: end.s + $(MACH) -I../../../h -c end.s + +clean: + rm -f *.o libem_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/end.s + @arch pv libem_s.a | pr -h `pwd`/libem_s.a diff --git a/mach/z80/libem/compmodule b/mach/z80/libem/compmodule new file mode 100755 index 00000000..ec9d18f3 --- /dev/null +++ b/mach/z80/libem/compmodule @@ -0,0 +1,4 @@ +if z80 -c $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/z80/libem/end.s b/mach/z80/libem/end.s new file mode 100644 index 00000000..6b9ce418 --- /dev/null +++ b/mach/z80/libem/end.s @@ -0,0 +1,17 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define endtext,enddata,endbss +.define _end,_etext,_edata + + ! $Header$ + .sect .text +endtext: +_etext: + .align 2 + .sect .data +enddata: +_edata: + .align 2 +.sect .endsect +_end: +endbss: + .align 2 diff --git a/mach/z80/libem/pstrng.s b/mach/z80/libem/pstrng.s new file mode 100644 index 00000000..d9ebc558 --- /dev/null +++ b/mach/z80/libem/pstrng.s @@ -0,0 +1,21 @@ +.define pstrng +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + + +! print a string of characters to the console +! entry: DE points to string +! string terminator is 0x00 +! exit: DE points to string terminator +pstrng: push af +1: ld a,(de) + or a + jr z,2f + call putchar + inc de + jr 1b +2: pop af + ret diff --git a/mach/z80/libem/tail.s b/mach/z80/libem/tail.s new file mode 100644 index 00000000..aead4997 --- /dev/null +++ b/mach/z80/libem/tail.s @@ -0,0 +1,15 @@ +.define endtext,enddata,endbss +.define _end,_etext,_edata + + .text +endtext: +_etext: + .align 2 + .data +enddata: +_edata: + .align 2 + .bss +_end: +endbss: + .align 2 diff --git a/mach/z80/libmon/Makefile b/mach/z80/libmon/Makefile new file mode 100644 index 00000000..f7baeca8 --- /dev/null +++ b/mach/z80/libmon/Makefile @@ -0,0 +1,50 @@ +TAIL=libhermac_o.a +# Other possibilities are: tail.nascom and tail.cpm +MACH=z80 + +all: head_em.o libhermac_o.a libnascom_o.a libcpm_o.a + +install: head_em.o $(TAIL) + ../../install head_em.o head_em + ../../install $(TAIL) tail_sys + +cmp: head_em.o $(TAIL) + -../../compare head_em.o head_em + -../../compare $(TAIL) tail_sys + +head_em.o: head_em.s + $(MACH) -I../../../h -c head_em.s + +libcpm_o.a: libcpm_s.a + ASAR=aal ; export ASAR; march . libcpm_o.a + +libnascom_o.a: libnascom_s.a + ASAR=aal ; export ASAR; march . libnascom_o.a + +libhermac_o.a: libhermac_s.a + ASAR=aal ; export ASAR; march . libhermac_o.a + +libcpm_s.a: + @echo Warning: untested, this is an example + arch cr libcpm_s.a mon.cpm.s + echo libcpm_s.a > LIST + arch t libcpm_s.a >> LIST + +libnascom_s.a: + arch cr libnascom_s.a mon.s char.nas.s + echo libnascom_s.a > LIST + arch t libnascom_s.a >> LIST + +libhermac_s.a: + arch cr libhermac_s.a mon.s char.her.s + echo libhermac_s.a > LIST + arch t libhermac_s.a >> LIST + +clean: + rm -f *.o *_o.a out nohup.out Out + +opr: + make pr | opr +pr: + @pr `pwd`/Makefile `pwd`/head_em.s + @pr `pwd`/mon.s `pwd`/mon.cpm.s `pwd`/char.nas.s `pwd`/char.her.s diff --git a/mach/z80/libmon/compmodule b/mach/z80/libmon/compmodule new file mode 100755 index 00000000..97ebc569 --- /dev/null +++ b/mach/z80/libmon/compmodule @@ -0,0 +1,4 @@ +if z80 -c -L $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/z80/libmon/putchr.nas.s b/mach/z80/libmon/putchr.nas.s new file mode 100644 index 00000000..e66a6891 --- /dev/null +++ b/mach/z80/libmon/putchr.nas.s @@ -0,0 +1,33 @@ +.define putchr +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text +! output routine in monitor +CRT = 0x013B +! output a charcter +! entry: ascii character in a +putchr: + push hl + push bc + ld hl,tab + ld b,5 +1: cp (hl) + jr z,fetch + inc hl + inc hl + djnz 1b +2: call CRT + pop bc + pop hl + ret +fetch: inc hl + ld a,(hl) + jr 2b +! conversion table for nascom characters +tab: .data1 0x0D,0x00 + .data1 0x1B,0x1E + .data1 0x08,0x1D + .data1 0x0A,0x1F + .data1 0x7F,0x00 diff --git a/mach/z80/libmon/putchr.s b/mach/z80/libmon/putchr.s new file mode 100644 index 00000000..898db469 --- /dev/null +++ b/mach/z80/libmon/putchr.s @@ -0,0 +1,26 @@ +.define putchr +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +putchr: + push hl + push de + push bc + cp 0x0A + jr nz,1f + ld a,0x1F +1: + ld c,a +2: + in a,0xF1 + and 4 + jr z,2b + ld a,c + out 0xF0,a + pop bc + pop de + pop hl + ret diff --git a/mach/z80/libmon/subr.s b/mach/z80/libmon/subr.s new file mode 100644 index 00000000..d82ca4f9 --- /dev/null +++ b/mach/z80/libmon/subr.s @@ -0,0 +1,202 @@ +.define _read,_write,_ioctl,_getpid,_open,_close,_exit,_errno +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text +_read: + ld (savebc),bc + push af + pop bc + ld (saveaf),bc ! save all registers in savereg + ld (savede),de + ld (savehl),hl + ld (saveix),ix + ex (sp),hl ! return address in hl + pop bc ! skip return address + pop bc ! get fd + ld a,b ! check fd = 0 + or c + jr nz,errrd + pop de ! get buffer + pop bc ! get count + ld ix,0 ! reset counter + push bc + push de + push ix + push hl ! return address + ex de,hl ! buffer to hl +1: ld a,b + or c + jr z,done ! done if count = 0 + call getchr + ld (hl),a + inc hl ! increment pointer + inc ix ! increment char counter + dec bc ! decrement count + cp 0xA + jr nz,1b ! done if char = CR +done: + ld bc,(saveaf) + push bc + pop af + ld bc,(savebc) + ld de,(savede) + ld hl,(savehl) + ld ix,(saveix) + ret +errrd: + push bc + push hl ! return address + ld bc,(saveaf) + push bc + pop af + ld bc,(savebc) + ld de,(savede) + ld hl,(savehl) + ld ix,(saveix) + ld ix,-1 + ret + +_write: + ld (savebc),bc + push af + pop bc + ld (saveaf),bc ! save all registers in savereg + ld (savede),de + ld (savehl),hl + ld (saveix),ix + ex (sp),hl ! return address in hl + pop de ! skip return address + pop de ! get fd + ld a,e ! check for fd = 1 + cp 1 + jr nz,errwr + ld a,d + or a + jr nz,errwr + pop de ! buffer in de + pop bc ! count in bc + push bc + push de + push de + push hl + ex de,hl ! buffer in hl + ld e,c + ld d,b ! count also in de +1: ld a,b + or c + jr z,exit + ld a,(hl) + call putchr + inc hl + dec bc + jr 1b +errwr: + push de + push hl + ld bc,(saveaf) + push bc + pop af + ld bc,(savebc) + ld de,(savede) + ld hl,(savehl) + ld ix,(saveix) + ld ix,-1 ! error in fd + ret +exit: + push de ! count on stack + ld bc,(saveaf) + push bc + pop af + ld bc,(savebc) + ld de,(savede) + ld hl,(savehl) + ld ix,(saveix) + pop ix ! return count to caller + ret + +_ioctl: + ret +_getpid: + ret + +! open return a file descriptor (0,1,2) +! depending on 'mode' +! mode 2 doesn't work!! +_open: + ld (savebc),bc + push af + pop bc + ld (saveaf),bc ! save all registers in savereg + ld (savede),de + ld (savehl),hl + ld (saveix),ix + pop bc ! return address + pop de ! name pointer + pop ix ! mode (0 for read, + ! 1 for write) + push ix + push de + push bc + ld bc,(saveaf) + push bc + pop af + ld bc,(savebc) + ld de,(savede) + ld hl,(savehl) + ld ix,(saveix) + ret ! return fd = 0 for read + ! fd = 1 for write + +_close: + ld ix,0 ! return succes + ret +_exit: +jp 0x38 +.sect .data +_errno: + .data2 0 +! output routine in monitor +CRT = 0x013B +! output a charcter +! entry: ascii character in a +.sect .text +!putchr: +! push hl +! push bc +! ld hl,tab +! ld b,5 +!1: cp (hl) +! jr z,fetch +! inc hl +! inc hl +! djnz 1b +!2: call CRT +! pop bc +! pop hl +! ret +!fetch: inc hl +! ld a,(hl) +! jr 2b +!! conversion table for nascom characters +!tab: .data1 0x0D,0x00 +! .data1 0x1B,0x1E +! .data1 0x08,0x1D +! .data1 0x0A,0x1F +! .data1 0x7F,0x00 + +KBD = 0x69 +! get character from keyboard +getchr: + call KBD + jr nc,getchr + cp 0x1F + jr z,CR + cp 0x1D + jr z,BS + ret +CR: ld a,0xA + ret +BS: ld a,0x8 + ret diff --git a/mach/z80/libsys/Makefile b/mach/z80/libsys/Makefile new file mode 100644 index 00000000..f7baeca8 --- /dev/null +++ b/mach/z80/libsys/Makefile @@ -0,0 +1,50 @@ +TAIL=libhermac_o.a +# Other possibilities are: tail.nascom and tail.cpm +MACH=z80 + +all: head_em.o libhermac_o.a libnascom_o.a libcpm_o.a + +install: head_em.o $(TAIL) + ../../install head_em.o head_em + ../../install $(TAIL) tail_sys + +cmp: head_em.o $(TAIL) + -../../compare head_em.o head_em + -../../compare $(TAIL) tail_sys + +head_em.o: head_em.s + $(MACH) -I../../../h -c head_em.s + +libcpm_o.a: libcpm_s.a + ASAR=aal ; export ASAR; march . libcpm_o.a + +libnascom_o.a: libnascom_s.a + ASAR=aal ; export ASAR; march . libnascom_o.a + +libhermac_o.a: libhermac_s.a + ASAR=aal ; export ASAR; march . libhermac_o.a + +libcpm_s.a: + @echo Warning: untested, this is an example + arch cr libcpm_s.a mon.cpm.s + echo libcpm_s.a > LIST + arch t libcpm_s.a >> LIST + +libnascom_s.a: + arch cr libnascom_s.a mon.s char.nas.s + echo libnascom_s.a > LIST + arch t libnascom_s.a >> LIST + +libhermac_s.a: + arch cr libhermac_s.a mon.s char.her.s + echo libhermac_s.a > LIST + arch t libhermac_s.a >> LIST + +clean: + rm -f *.o *_o.a out nohup.out Out + +opr: + make pr | opr +pr: + @pr `pwd`/Makefile `pwd`/head_em.s + @pr `pwd`/mon.s `pwd`/mon.cpm.s `pwd`/char.nas.s `pwd`/char.her.s diff --git a/mach/z80/libsys/compmodule b/mach/z80/libsys/compmodule new file mode 100755 index 00000000..97ebc569 --- /dev/null +++ b/mach/z80/libsys/compmodule @@ -0,0 +1,4 @@ +if z80 -c -L $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/z80/libsys/putchr.nas.s b/mach/z80/libsys/putchr.nas.s new file mode 100644 index 00000000..e66a6891 --- /dev/null +++ b/mach/z80/libsys/putchr.nas.s @@ -0,0 +1,33 @@ +.define putchr +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text +! output routine in monitor +CRT = 0x013B +! output a charcter +! entry: ascii character in a +putchr: + push hl + push bc + ld hl,tab + ld b,5 +1: cp (hl) + jr z,fetch + inc hl + inc hl + djnz 1b +2: call CRT + pop bc + pop hl + ret +fetch: inc hl + ld a,(hl) + jr 2b +! conversion table for nascom characters +tab: .data1 0x0D,0x00 + .data1 0x1B,0x1E + .data1 0x08,0x1D + .data1 0x0A,0x1F + .data1 0x7F,0x00 diff --git a/mach/z80/libsys/putchr.s b/mach/z80/libsys/putchr.s new file mode 100644 index 00000000..898db469 --- /dev/null +++ b/mach/z80/libsys/putchr.s @@ -0,0 +1,26 @@ +.define putchr +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +putchr: + push hl + push de + push bc + cp 0x0A + jr nz,1f + ld a,0x1F +1: + ld c,a +2: + in a,0xF1 + and 4 + jr z,2b + ld a,c + out 0xF0,a + pop bc + pop de + pop hl + ret diff --git a/mach/z80/libsys/subr.s b/mach/z80/libsys/subr.s new file mode 100644 index 00000000..d82ca4f9 --- /dev/null +++ b/mach/z80/libsys/subr.s @@ -0,0 +1,202 @@ +.define _read,_write,_ioctl,_getpid,_open,_close,_exit,_errno +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text +_read: + ld (savebc),bc + push af + pop bc + ld (saveaf),bc ! save all registers in savereg + ld (savede),de + ld (savehl),hl + ld (saveix),ix + ex (sp),hl ! return address in hl + pop bc ! skip return address + pop bc ! get fd + ld a,b ! check fd = 0 + or c + jr nz,errrd + pop de ! get buffer + pop bc ! get count + ld ix,0 ! reset counter + push bc + push de + push ix + push hl ! return address + ex de,hl ! buffer to hl +1: ld a,b + or c + jr z,done ! done if count = 0 + call getchr + ld (hl),a + inc hl ! increment pointer + inc ix ! increment char counter + dec bc ! decrement count + cp 0xA + jr nz,1b ! done if char = CR +done: + ld bc,(saveaf) + push bc + pop af + ld bc,(savebc) + ld de,(savede) + ld hl,(savehl) + ld ix,(saveix) + ret +errrd: + push bc + push hl ! return address + ld bc,(saveaf) + push bc + pop af + ld bc,(savebc) + ld de,(savede) + ld hl,(savehl) + ld ix,(saveix) + ld ix,-1 + ret + +_write: + ld (savebc),bc + push af + pop bc + ld (saveaf),bc ! save all registers in savereg + ld (savede),de + ld (savehl),hl + ld (saveix),ix + ex (sp),hl ! return address in hl + pop de ! skip return address + pop de ! get fd + ld a,e ! check for fd = 1 + cp 1 + jr nz,errwr + ld a,d + or a + jr nz,errwr + pop de ! buffer in de + pop bc ! count in bc + push bc + push de + push de + push hl + ex de,hl ! buffer in hl + ld e,c + ld d,b ! count also in de +1: ld a,b + or c + jr z,exit + ld a,(hl) + call putchr + inc hl + dec bc + jr 1b +errwr: + push de + push hl + ld bc,(saveaf) + push bc + pop af + ld bc,(savebc) + ld de,(savede) + ld hl,(savehl) + ld ix,(saveix) + ld ix,-1 ! error in fd + ret +exit: + push de ! count on stack + ld bc,(saveaf) + push bc + pop af + ld bc,(savebc) + ld de,(savede) + ld hl,(savehl) + ld ix,(saveix) + pop ix ! return count to caller + ret + +_ioctl: + ret +_getpid: + ret + +! open return a file descriptor (0,1,2) +! depending on 'mode' +! mode 2 doesn't work!! +_open: + ld (savebc),bc + push af + pop bc + ld (saveaf),bc ! save all registers in savereg + ld (savede),de + ld (savehl),hl + ld (saveix),ix + pop bc ! return address + pop de ! name pointer + pop ix ! mode (0 for read, + ! 1 for write) + push ix + push de + push bc + ld bc,(saveaf) + push bc + pop af + ld bc,(savebc) + ld de,(savede) + ld hl,(savehl) + ld ix,(saveix) + ret ! return fd = 0 for read + ! fd = 1 for write + +_close: + ld ix,0 ! return succes + ret +_exit: +jp 0x38 +.sect .data +_errno: + .data2 0 +! output routine in monitor +CRT = 0x013B +! output a charcter +! entry: ascii character in a +.sect .text +!putchr: +! push hl +! push bc +! ld hl,tab +! ld b,5 +!1: cp (hl) +! jr z,fetch +! inc hl +! inc hl +! djnz 1b +!2: call CRT +! pop bc +! pop hl +! ret +!fetch: inc hl +! ld a,(hl) +! jr 2b +!! conversion table for nascom characters +!tab: .data1 0x0D,0x00 +! .data1 0x1B,0x1E +! .data1 0x08,0x1D +! .data1 0x0A,0x1F +! .data1 0x7F,0x00 + +KBD = 0x69 +! get character from keyboard +getchr: + call KBD + jr nc,getchr + cp 0x1F + jr z,CR + cp 0x1D + jr z,BS + ret +CR: ld a,0xA + ret +BS: ld a,0x8 + ret diff --git a/mach/z8000/as/Makefile b/mach/z8000/as/Makefile new file mode 100644 index 00000000..7455a482 --- /dev/null +++ b/mach/z8000/as/Makefile @@ -0,0 +1,67 @@ +# $Header$ +EMHOME = ../../.. +h = $(EMHOME)/h +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +CDIR = $(EMHOME)/mach/proto/as +CPP = $(EMHOME)/lib/cpp +DEF = + +FFLAG = +INCL = -I. -I$h $(DEF) +CFLAGS = $(FFLAG) -O $(INCL) +YFLAGS = -d +LDFLAGS = $(FFLAG) + +CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \ + $(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c +COBJ = comm3.o comm4.o comm5.o \ + comm6.o comm7.o comm8.o +MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c +COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC) + +all: as + +install:all + ../../install as + +cmp: + -../../compare as + +clean: + rm -f *.o as as.[cy] y.tab.h + +pr: $(MACH) + @pr -n $(MACH) + +opr: + make pr | opr +as: $(COBJ) as.o + $(CC) $(LDFLAGS) $(COBJ) as.o $(LIBOBJ) -o as + +as.y: $(CDIR)/comm2.y + $(CPP) -P -I. -I$h $(DEF) $(CDIR)/comm2.y >as.y + -@if test -f Expect ; then cat Expect ; else echo "expect 1 shift/reduce conflict"; fi + +lint: $(CSRC) as.c + lint $(INCL) $(CSRC) as.c + +y.tab.h: as.c +$(COBJ): y.tab.h +$(COBJ) as.y: $(CDIR)/comm0.h mach0.c +$(COBJ) as.y: $(CDIR)/comm1.h mach1.c +as.y: mach2.c +comm3.o: mach3.c +as.y: mach4.c +comm8.o: mach5.c +comm3.o: $(CDIR)/comm3.c + $(CC) -c $(CFLAGS) $(CDIR)/comm3.c +comm4.o: $(CDIR)/comm4.c + $(CC) -c $(CFLAGS) $(CDIR)/comm4.c +comm5.o: $(CDIR)/comm5.c + $(CC) -c $(CFLAGS) $(CDIR)/comm5.c +comm6.o: $(CDIR)/comm6.c + $(CC) -c $(CFLAGS) $(CDIR)/comm6.c +comm7.o: $(CDIR)/comm7.c + $(CC) -c $(CFLAGS) $(CDIR)/comm7.c +comm8.o: $(CDIR)/comm8.c + $(CC) -c $(CFLAGS) $(CDIR)/comm8.c diff --git a/mach/z8000/cg/Makefile b/mach/z8000/cg/Makefile new file mode 100644 index 00000000..22f5f603 --- /dev/null +++ b/mach/z8000/cg/Makefile @@ -0,0 +1,184 @@ +# $Header$ + +EMHOME=../../.. +PREFLAGS=-I$(EMHOME)/h -I. -I$(EMHOME)/mach -I$(EMHOME)/modules/h -DNDEBUG +PFLAGS= +CFLAGS=$(PREFLAGS) $(PFLAGS) -O +LDFLAGS=$(PFLAGS) +LINTOPTS=-hbxac +LIBS=$(EMHOME)/lib/em_data.a $(EMHOME)/modules/lib/libflt.a +CDIR=$(EMHOME)/mach/proto/cg +CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \ + $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/main.c $(CDIR)/move.c \ + $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c $(CDIR)/salloc.c \ + $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c +OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o main.o\ + move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o + +all: tables.c + make "EMHOME="$(EMHOME) cg + +cg: tables.o $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg + +tables.o: tables.c + $(CC) -c $(PREFLAGS) -I$(CDIR) tables.c + +codegen.o: $(CDIR)/codegen.c + $(CC) -c $(CFLAGS) $(CDIR)/codegen.c +compute.o: $(CDIR)/compute.c + $(CC) -c $(CFLAGS) $(CDIR)/compute.c +equiv.o: $(CDIR)/equiv.c + $(CC) -c $(CFLAGS) $(CDIR)/equiv.c +fillem.o: $(CDIR)/fillem.c + $(CC) -c $(CFLAGS) $(CDIR)/fillem.c +gencode.o: $(CDIR)/gencode.c + $(CC) -c $(CFLAGS) $(CDIR)/gencode.c +glosym.o: $(CDIR)/glosym.c + $(CC) -c $(CFLAGS) $(CDIR)/glosym.c +main.o: $(CDIR)/main.c + $(CC) -c $(CFLAGS) $(CDIR)/main.c +move.o: $(CDIR)/move.c + $(CC) -c $(CFLAGS) $(CDIR)/move.c +nextem.o: $(CDIR)/nextem.c + $(CC) -c $(CFLAGS) $(CDIR)/nextem.c +reg.o: $(CDIR)/reg.c + $(CC) -c $(CFLAGS) $(CDIR)/reg.c +regvar.o: $(CDIR)/regvar.c + $(CC) -c $(CFLAGS) $(CDIR)/regvar.c +salloc.o: $(CDIR)/salloc.c + $(CC) -c $(CFLAGS) $(CDIR)/salloc.c +state.o: $(CDIR)/state.c + $(CC) -c $(CFLAGS) $(CDIR)/state.c +subr.o: $(CDIR)/subr.c + $(CC) -c $(CFLAGS) $(CDIR)/subr.c +var.o: $(CDIR)/var.c + $(CC) -c $(CFLAGS) $(CDIR)/var.c + +install: all + ../../install cg + +cmp: all + -../../compare cg + +distr: tables.c + rm -f tables1.[ch] + cp tables.c tables1.c + cp tables.h tables1.h + chmod -w tables1.[ch] + + +tables.c: table + -mv tables.h tables.h.save + $(EMHOME)/lib/cpp -P table | $(EMHOME)/lib/cgg > debug.out + -if cmp -s tables.h.save tables.h; then mv tables.h.save tables.h; else exit 0; fi + -if cmp -s /dev/null tables.h; then mv tables.h.save tables.h; else exit 0; fi + +lint: $(CFILES) + lint $(LINTOPTS) $(PREFLAGS) $(CFILES) +clean: + rm -f *.o tables.c tables.h debug.out cg tables.h.save + +codegen.o: $(CDIR)/assert.h +codegen.o: $(CDIR)/data.h +codegen.o: $(CDIR)/equiv.h +codegen.o: $(CDIR)/extern.h +codegen.o: $(CDIR)/param.h +codegen.o: $(CDIR)/result.h +codegen.o: $(CDIR)/state.h +codegen.o: tables.h +codegen.o: $(CDIR)/types.h +compute.o: $(CDIR)/assert.h +compute.o: $(CDIR)/data.h +compute.o: $(CDIR)/extern.h +compute.o: $(CDIR)/glosym.h +compute.o: $(CDIR)/param.h +compute.o: $(CDIR)/result.h +compute.o: tables.h +compute.o: $(CDIR)/types.h +equiv.o: $(CDIR)/assert.h +equiv.o: $(CDIR)/data.h +equiv.o: $(CDIR)/equiv.h +equiv.o: $(CDIR)/extern.h +equiv.o: $(CDIR)/param.h +equiv.o: $(CDIR)/result.h +equiv.o: tables.h +equiv.o: $(CDIR)/types.h +fillem.o: $(CDIR)/assert.h +fillem.o: $(CDIR)/data.h +fillem.o: $(CDIR)/extern.h +fillem.o: mach.c +fillem.o: mach.h +fillem.o: $(CDIR)/param.h +fillem.o: $(CDIR)/regvar.h +fillem.o: $(CDIR)/result.h +fillem.o: tables.h +fillem.o: $(CDIR)/types.h +gencode.o: $(CDIR)/assert.h +gencode.o: $(CDIR)/data.h +gencode.o: $(CDIR)/extern.h +gencode.o: $(CDIR)/param.h +gencode.o: $(CDIR)/result.h +gencode.o: tables.h +gencode.o: $(CDIR)/types.h +glosym.o: $(CDIR)/glosym.h +glosym.o: $(CDIR)/param.h +glosym.o: tables.h +glosym.o: $(CDIR)/types.h +main.o: $(CDIR)/param.h +move.o: $(CDIR)/assert.h +move.o: $(CDIR)/data.h +move.o: $(CDIR)/extern.h +move.o: $(CDIR)/param.h +move.o: $(CDIR)/result.h +move.o: tables.h +move.o: $(CDIR)/types.h +nextem.o: $(CDIR)/assert.h +nextem.o: $(CDIR)/data.h +nextem.o: $(CDIR)/extern.h +nextem.o: $(CDIR)/param.h +nextem.o: $(CDIR)/result.h +nextem.o: tables.h +nextem.o: $(CDIR)/types.h +reg.o: $(CDIR)/assert.h +reg.o: $(CDIR)/data.h +reg.o: $(CDIR)/extern.h +reg.o: $(CDIR)/param.h +reg.o: $(CDIR)/result.h +reg.o: tables.h +reg.o: $(CDIR)/types.h +regvar.o: $(CDIR)/assert.h +regvar.o: $(CDIR)/data.h +regvar.o: $(CDIR)/extern.h +regvar.o: $(CDIR)/param.h +regvar.o: $(CDIR)/regvar.h +regvar.o: $(CDIR)/result.h +regvar.o: tables.h +regvar.o: $(CDIR)/types.h +salloc.o: $(CDIR)/assert.h +salloc.o: $(CDIR)/data.h +salloc.o: $(CDIR)/extern.h +salloc.o: $(CDIR)/param.h +salloc.o: $(CDIR)/result.h +salloc.o: tables.h +salloc.o: $(CDIR)/types.h +state.o: $(CDIR)/assert.h +state.o: $(CDIR)/data.h +state.o: $(CDIR)/extern.h +state.o: $(CDIR)/param.h +state.o: $(CDIR)/result.h +state.o: $(CDIR)/state.h +state.o: tables.h +state.o: $(CDIR)/types.h +subr.o: $(CDIR)/assert.h +subr.o: $(CDIR)/data.h +subr.o: $(CDIR)/extern.h +subr.o: $(CDIR)/param.h +subr.o: $(CDIR)/result.h +subr.o: tables.h +subr.o: $(CDIR)/types.h +var.o: $(CDIR)/data.h +var.o: $(CDIR)/param.h +var.o: $(CDIR)/result.h +var.o: tables.h +var.o: $(CDIR)/types.h diff --git a/mach/z8000/libem/Makefile b/mach/z8000/libem/Makefile new file mode 100644 index 00000000..b2c179d9 --- /dev/null +++ b/mach/z8000/libem/Makefile @@ -0,0 +1,21 @@ +all: + +install: + ../../install head_em.s head_em + ../../install libem_s.a tail_em + ../../install end.s end_em + +cmp: + -../../compare head_em.s head_em + -../../compare libem_s.a tail_em + -../../compare end.s end_em + +clean: + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libem_s.a | pr -h `pwd`/libem_s.a + @pr `pwd`/end.s diff --git a/mach/z8000/libem/end.s b/mach/z8000/libem/end.s new file mode 100644 index 00000000..37e1cef2 --- /dev/null +++ b/mach/z8000/libem/end.s @@ -0,0 +1,16 @@ +.define endtext,enddata,endbss,_etext,_edata,_end +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .end ! only for declaration of _end and endbss. + + .sect .text +endtext: +_etext: + .sect .data +enddata: +_edata: + .sect .end +_end: +endbss: diff --git a/mach/z8000/libem/head_em.s b/mach/z8000/libem/head_em.s new file mode 100644 index 00000000..5be73c5f --- /dev/null +++ b/mach/z8000/libem/head_em.s @@ -0,0 +1,62 @@ +.define EXIT, F_DUM +.define ERANGE, ESET, EHEAP, EILLINS, EODDZ, ECASE, EBADMON +.define hol0, trppc, trpim, reghp, argv, envp +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +EXIT = 0 +F_DUM = 0 + +ERANGE = 1 +ESET = 2 +EHEAP = 17 +EILLINS = 18 +EODDZ = 19 +ECASE = 20 +EBADMON = 25 + +.sect .text + !clear .sect .bss + ldk R2, $0 + ld R3, $endbss + ld R0, R3 + sub R0, $begbss + jr EQ, 1f + sra R0 + push *RR2, $0 + dec R0 + jr EQ, 1f + ldl RR4, RR2 + dec R5, $2 + lddr *RR4, *RR2, R0 +1: + ldb RL0, $10 ! echo newline + sc $4 + ldl RR14, $0 + push *RR14, envp + push *RR14, argv + push *RR14, $1 + calr __m_a_i_n + ldl RR14, $0xC00017FC + sc $0 + +.sect .bss +begbss: +.sect .data +hol0: + .data2 0,0 ! line no + .data2 0,0 ! file +trppc: + .data2 0 +trpim: + .data2 0 +argv: +envp: + .data2 1f + .data2 0 +1: .asciz "program" +reghp: + .data2 endbss diff --git a/mach/z8000/libem/mon.s b/mach/z8000/libem/mon.s new file mode 100644 index 00000000..407a9c57 --- /dev/null +++ b/mach/z8000/libem/mon.s @@ -0,0 +1,88 @@ +.define mon +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +mon: + popl saveret, *RR14 + pop R0, *RR14 ! iocode + cp R0, $1 ! exit + jr NE, read + inc R15, $2 + sc $EXIT +read: cp R0, $3 ! read + jr NE, write + pop R0, *RR14 ! dummy; all input from stdin + pop R1, *RR14 ! ptr to buffer + pop R2, *RR14 ! nr of bytes to be read + ld R3, R1 + cp R2, $0 + jr EQ, 6f +1: sc $2 ! read character into RL0 + cpb RL0, $004 ! \^D + jr EQ, 6f + cpb RL0, $015 ! \cr + jr NE, 2f + ldb RL0, $012 +2: sc $4 ! echo + cpb RL0, $010 ! \^H + jr NE, 3f + cp R1, R3 + jr EQ, 5f + dec R1 + jr 5f +3: cpb RL0, $0100 ! \@ + jr NE, 4f + ld R1, R3 + ldb RL0, $012 + sc $4 + jr 5f +4: ldb 0(R1), RL0 + inc R1 + cpb RL0, $012 ! \nl + jr EQ, 6f +5: djnz R2, 1b +6: sub R1, R3 ! nr of bytes read + push *RR14, R1 + push *RR14, $0 + jr retu +write: cp R0, $4 ! write + jr NE, open + pop R0, *RR14 ! dummy; all output to stdout + pop R1, *RR14 ! ptr to buffer + pop R2, *RR14 ! nr of bytes to be written + ld R3, R2 + cp R2, $0 + jr EQ, 8f +9: ld R0, $5000 ! counter to delay printing a little +7: djnz R0, 7b + ldb RL0, 0(R1) + sc $4 + inc R1 + djnz R2, 9b +8: sub R3, R2 ! nr of bytes written + push *RR14, R3 + push *RR14, $0 + jr retu +open: cp R0, $5 ! open + jr close + jr NE, close + ld *RR14, $0 + ld 2(R15), $0 + jr retu +close: cp R0, $6 ! close + jr NE, ioctl + ld *RR14, $0 + jr retu +ioctl: cp R0, $54 ! ioctl + jr NE, err + inc R15, $4 + ld *RR14, $0 +retu: ldl RR2, saveret + jp *RR2 +err: push *RR14, saveret + push *RR14, $EBADMON + calr trp + ret diff --git a/man/6500_as.1 b/man/6500_as.1 new file mode 100644 index 00000000..1c8b43fb --- /dev/null +++ b/man/6500_as.1 @@ -0,0 +1,66 @@ +.\" $Header$ +.TH 6500_AS 1ACK +.SH NAME +6500_as \- assembler for Mostek 6500 +.SH SYNOPSIS +~em/lib/6500/as [options] argument ... +.SH DESCRIPTION +This assembler is made with the general framework +described in \fIuni_ass\fP(6). It is an assembler-loader. +.SH "SECTIONS and TYPES" +An additional section, the \fIzeropage\fP, can be started by the +\&\fI.sect .zero\fP pseudo-instruction. +Some adressing-modes require an address between 0 and 255. +Such an address must be defined with the means of the \fI.sect .zero\fP +pseudo-instruction. +A plain number between 0 and 255 is not allowed. +The assembler will complain that it must be a zero page expression. +.IP example +\&.sect .zero +.br +answer: .space 1 +.br +\&.text +.br +and (answer, x) +.SH SYNTAX +.IP expressions +An two-byte expression followed by the pseudo-operator \fI.h\fP (\fI.l\fP) +has the value of the higher (lower) byte of the expression. +\&\fI.h\fP and \fI.l\fP bind stronger than all other operators. +E.g. -1.h parses as -[1.h] which has value 0. +You have to write [-1].h to get 0xFF. +.IP "addressing modes" +.nf +.ta 16n 24n 32n 40n 48n +syntax meaning (name) + +#expr 8-bit value (immediate) + +expr address (direct) + +expr, x expr + contents of x + or or +expr, y expr + contents of y + yields address (indexed) + +(expr) address of address (only with JMP) (indirect) +.fi + +In the next two addressing modes \fIexpr\fP has to be +a zeropage expression. + +.nf +(expr, x) expr + contents of x + yields address (pre-indexed indirect) + +(expr), y contents of expr + contents of y + yields address (post-indexed indirect) +.fi +.IP instructions +There are two mnemonics that do not map onto one machine-instruction: +\fIadd\fP and \fIsub\fP. \fIAdd mode\fP maps onto \fIclc; adc mode\fP. +\fISub mode\fP maps onto \fIsec; sbc mode\fP. +.SH "SEE ALSO" +uni_ass(6), +ack(1) diff --git a/man/6800_as.1 b/man/6800_as.1 new file mode 100644 index 00000000..08791a50 --- /dev/null +++ b/man/6800_as.1 @@ -0,0 +1,55 @@ +.\" $Header$ +.TH 6800_AS 1 +.ad +.SH NAME +6800_as \- assembler for Motorola 6800 +.SH SYNOPSIS +/usr/em/lib/6800_as [options] argument ... +.SH DESCRIPTION +This assembler is made with the general framework +described in \fIuni_ass\fP(6). +.SH SYNTAX +.IP registers +The 6800 has two accumulator registers, A and B. An instruction that refers +to accumulator A, has an "a" as last character. In the same way a "b" means +that the instruction uses B as accumulator. +.IP "addressing modes" +.nf +.ta 8n 16n 24n 32n 40n 48n +syntax meaning (name) + +#expr with cpx, ldx, lds a 2-byte value, + otherwise a 1-byte value (immediate) + +expr 2-byte address. Allowed in the register + memory group. (extended) +expr 1-byte address if appropriate, 2-byte + in other cases. (auto-direct/extended) +,x indexed with zero offset. (indexed) +expr,x indexed with 16 bit offset. (indexed-2) +expr,x indexed with the shortest possible off- + set. (auto indexed) +bit,expr bit number and direct address. + (bit set/clear) +bit,expr,tag bit number, direct address and branch + tag. Automatically changed to reversed + condition branch and jump if appropri- + ate. (bit test and branch) +tag branch tag. Converted to reversed con- + dition branch and jump if appropriate. + (branch) +.fi +.IP "PSEUDO INSTRUCTIONS" + + .dram use the zero page ram/io segment. + .dprom use the zero page (ep)rom segment. + .cmos assemble cmos version instructions. +.SH "SEE ALSO" +uni_ass(6), +ack(1), +.br +M6805 HMOS, M146805 CMOS family, Motorola, +Prentice-Hall, Inc., 1983, (ISBN 0-13-541375-3). +.SH EXAMPLE +An example of Motorola 6805 assembly code. +.sp 2 +.nf +.ta 8n 16n 32n 40n 48n 56n 64n + .dram + one: .space 1 ! a-port + .dprom + c1: .byte 1 + .text + start: ldx #c1 ! load address of c1 + txa + sta one + add c1 ! add one + brset 1,one,whoop ! jif bit one of aport + bset 1,one ! set it now + .data + .ascii "unused string" + .text + whoop: nop + .org 0xff8 + .word start ! set vector address + .text + nop ! resume code +.fi +.SH AUTHOR +Written by Gijs Mos. +Not a member of the ACK group. +.SH BUGS +The assembler has not been well tested. diff --git a/man/6809_as.1 b/man/6809_as.1 new file mode 100644 index 00000000..10e38c1a --- /dev/null +++ b/man/6809_as.1 @@ -0,0 +1,147 @@ +.\" $Header$ +.TH 6809_AS 1 +.ad +.SH NAME +6809_as \- assembler for 6809 +.SH SYNOPSIS +/usr/em/lib/6809_as [options] argument ... +.SH DESCRIPTION +This assembler is made with the general framework +described in \fIuni_ass\fP(6). +.SH SYNTAX +.IP registers +The 6809 contains four 8-bit registers registers: +two accumulators (a and b), +a direct page register (dp), +and a condition code register (cc), +and five 16-bit registers: +two index registers (x and y), +a user an a hardware stack pointer (u resp. s), +and a program counter (pc). +The index registers and the stack pointers are indexable. +Accumulators a and b can be concatenated to form +the double accumulator d, +of which a is the high and b is the low byte. +An instruction that refers to accumulator a +has an "a" as last character. +In the same way a "b" means that the instruction +uses b as accumulator. +.IP "pseudo instructions" +The 6809 assembler recognizes one additional instruction +that is not translated into a machine instruction: setdp. +It expects an expression as argument. +This is used for efficient address encoding of some addressing +mode (see below). +.IP "addressing modes" +.nf +.ta 8n 16n 24n 32n 40n 48n +syntax meaning (name) + +reg The operand of the instruction is in \fIreg\fP. + +reglist \fIreglist\fP is a either list of registers, seperated + by ','s, or the word "all". It encodes in a register + save mask, where "all" means all registers, that can + be used by the push-pull instructions pshs, pshu, + puls, and pulu. + +expr The two-byte value of \fIexpr\fP is the exact memory + address. Not that this mode always requires one + byte more than "expr". + (relative for branch-instructions) + +#expr The value of \fIexpr\fP is one- or two-byte immediate + data. (immediate) + +(expr) The value of \fIexpr\fP is a pointer to the address + of the operand. (indirect) + +expr, reg The value of \fIexpr\fP added to the contents of \fIreg\fP + (which must be a 16-bit register) yields the + effective address of the operand. + (constant-offset indexed) + +, ireg The contents of \fIireg\fP (which must be indexable) + yields the effective address of the operand. + (constant-offset indexed) + +(expr, reg) The value of \fIexpr\fP added to the contents of \fIreg\fP + (which must be a 16-bit register) yields a pointer + to the effective address of the operand. + (constant-offset indexed indirect) + +(, ireg) The contents of \fIireg\fP (which must be indexable) + yields a pointer to the effective address of the + operand. (constant-offset indexed indirect) + +ac, ireg The contents of \fIac\fP (which must be an accumulator) + added to the contents of \fIireg\fP (which must be + indexable) yields the effective address of the + operand. (accumulator indexed) + +(ac, ireg) The contents of \fIac\fP (which must be an accumulator) + added to the contents of \fIireg\fP (which must be + indexable) yields a pointer to the effective address + of the operand. (accumulator indexed indirect) + +,ireg+ +,ireg++ The contents of \fIireg\fP (which must be indexable) is + used as effective address of the operand. After that + it is incremented by 1 (+) or 2 (++). + (auto-increment) + +(,ireg++) The contents of \fIireg\fP (which must be indexable) is + used as a pointer to the effective address of the + operand. After that it is incremented by 2. + (auto-increment indirect) + +,-ireg +,--ireg \fIireg\fP (which must be indexable) is decremented + by 1 (-) or 2 (--). After that, its contents is used + as effective address of the operand. + (auto-decrement) + +(,--ireg) \fIireg\fP (which must be indexable) is decremented by 2. + After that, its contents is used as a pointer to the + effective address of the operand. + (auto-decrement indirect) + +.fi +.SH "SEE ALSO" +uni_ass(6), +ack(1), +.br +MC6809 preliminary programming manual, Motorola Inc., First Edition, 1979 +.SH EXAMPLE +An example of 6809 assembly code. +.nf +.ta 8n 16n 24n 32n 40n 48n + contby = 80 + + compgo: lda #contby + ldx #table - 2 !start of table + + clrb + co1: addb #2 + lsra + bcc co1 + jmp (b, x) !accumulator offset indirect +.fi diff --git a/man/8080_as.1 b/man/8080_as.1 new file mode 100644 index 00000000..4a156362 --- /dev/null +++ b/man/8080_as.1 @@ -0,0 +1,36 @@ +.\" $Header$ +.TH 8080_AS 1 +.ad +.SH NAME +8080_as \- assembler for Intel 8080 and 8085 +.SH SYNOPSIS +/usr/em/lib/8080_as [options] argument ... +.SH DESCRIPTION +This assembler is made with the general framework +described in \fIuni_ass\fP(6). +.SH SYNTAX +.IP registers +The 8080 has seven one-byte registers: a, b, c, d, e, h, l; +and two two-byte registers: sp and psw, respectively the stack pointer +and the processor status word. +.IP "addressing modes" +.nf +.ta 8n 16n 24n 32n 40n 48n +syntax meaning + +expr one- or two-byte address or immediate + data, depending on the instruction. + +a,b,c,d,e,h,l +sp,psw (lower byte) of register + +b,d,h register-pair b-c, d-e, or h-l + +m register-pair h-l is address of + (one or two byte) operand +.fi +.SH "SEE ALSO" +uni_ass(1), +ack(1), +.br +System 80/20-4 microcomputer hardware reference manual, 1978 Intel corporation diff --git a/man/Makefile b/man/Makefile new file mode 100644 index 00000000..f8cce12e --- /dev/null +++ b/man/Makefile @@ -0,0 +1,30 @@ +# $Header$ + +NROFF=nroff +MANDIR=/usr/man +SUF=opr + +all: + for i in *.[1-8] ; do \ + $(NROFF) -man head $$i > $$i.$(SUF) ; \ + done + +install: + for i in *.[1-8] ; do \ + num=`expr $$i : '.*\.\([1-8]\)'` ; \ + if test -f $(MANDIR)/man$$num/$$i ; \ + then cat head $$i > $(MANDIR)/man$$num/em_$$i ; \ + else cat head $$i > $(MANDIR)/man$$num/$$i ; \ + fi ; \ + done + +opr: + make pr | opr + +pr: + @make all >make.pr.out 2>&1 & + @cat *.opr + +clean: + -rm -f *.opr *.out + -rm -f *.$(SUF) diff --git a/man/a.out.5 b/man/a.out.5 new file mode 100644 index 00000000..25cc6b5b --- /dev/null +++ b/man/a.out.5 @@ -0,0 +1,46 @@ +.\" $Header$ +.TH A.OUT 5 +.SH NAME +a.out \- universal assembler load format +.SH DESCRIPTION +The load files produced by the universal assemblers look very +much alike. +These load files consist of sequences of variable length +records, each describing a part of the initialized memory. +Bss type memory is left uninitialized by the universal assembler +and has to be initialized at run-time. +The EM header em_head will perform this task on most systems. +Each record consists of a \fIcount\fP, an \fIaddress\fP and +\fIcount\fP bytes. +The first byte should be placed at \fIaddress\fP, the second at +\fIaddress+1\fP, etc. + +.nf +struct loadf { + unsigned short l_addr[2] ; /* address */ + short l_cnt ; /* count */ + unsigned char data[] ; /* data */ +} ; +.fi + +This representation is machine dependent in two ways. +First, the byte order in the first three fields is the byte order +of the machine the universal assembler is running. +Second, the format of the address differs from machine to machine. +.br +For example, for the Intel 8086 the first entry contains a +16-bit offset and the second entry a segment number. +The segment number has to be multiplied by 16 and added to +the addres to obtain the address of the first byte to be +initialized. +.br +The PDP 11 version stores the address in l_addr[0] and the type +of the initialized memory in l_addr[1]. +Types 1 and 3 are absolute, 4 is text, 5 is data and 6 BSS. +.br +For all other currently available machines the +array of shorts is 'replaced' by a long. +This long contains the 32-bit address. +.SH "SEE ALSO" +uni_ass(VI) +.SH BUGS diff --git a/man/arch.1 b/man/arch.1 new file mode 100644 index 00000000..4d675b62 --- /dev/null +++ b/man/arch.1 @@ -0,0 +1,135 @@ +.\" $Header$ +.TH ARCH 1 +.SH NAME +arch \- archive and library maintainer +.SH SYNOPSIS +.B arch +key [ posname ] afile name ... +.SH DESCRIPTION +.I Arch +maintains groups of files +combined into a single archive file. +Its main use +is to create and update library files as used by a linker. +It can be used, though, for any similar purpose. +The Amsterdam compiler kit provides its own archiver with a +fixed, machine-independent format, much like the UNIX-V7 +archive format. +EM programs using libraries assume archives in EM format. +.PP +.I Key +is one character from the set +.B drqtpmx, +optionally concatenated with +one or more of +.B vuaibcl. +.I Afile +is the archive file. +The +.I names +are constituent files in the archive file. +The meanings of the +.I key +characters are: +.TP +.B d +Delete the named files from the archive file. +.TP +.B r +Replace the named files in the archive file. +If the optional character +.B u +is used with +.B r, +then only those files with +modified dates later than +the archive files are replaced. +If an optional positioning character from the set +.B abi +is used, then the +.I posname +argument must be present +and specifies that new files are to be placed +after +.RB ( a ) +or before +.RB ( b +or +.BR i ) +.IR posname . +Otherwise +new files are placed at the end. +.TP +.B q +Quickly append the named files to the end of the archive file. +Optional positioning characters are invalid. +The command does not check whether the added members +are already in the archive. +Useful only to avoid quadratic behavior when creating a large +archive piece-by-piece. +.TP +.B t +Print a table of contents of the archive file. +If no names are given, all files in the archive are tabled. +If names are given, only those files are tabled. +.TP +.B p +Print the named files in the archive. +.TP +.B m +Move the named files to the end of the archive. +If a positioning character is present, +then the +.I posname +argument must be present and, +as in +.B r, +specifies where the files are to be moved. +.TP +.B x +Extract the named files. +If no names are given, all files in the archive are +extracted. +In neither case does +.B x +alter the archive file. +.TP +.B v +Verbose. +Under the verbose option, +.I arch +gives a file-by-file +description of the making of a +new archive file from the old archive and the constituent files. +When used with +.B t, +it gives a long listing of all information about the files. +When used with +.BR p , +it precedes each file with a name. +.TP +.B c +Create. +Normally +.I arch +will create +.I afile +when it needs to. +The create option suppresses the +normal message that is produced when +.I afile +is created. +.TP +.B l +Local. +Normally +.I arch +places its temporary files in the directory /tmp. +This option causes them to be placed in the local directory. +.SH FILES +/tmp/v* temporaries +.SH "SEE ALSO" +em_ass(I), arch(V), +.SH BUGS +If the same file is mentioned twice in an argument list, +it may be put in the archive twice. diff --git a/man/arch.5 b/man/arch.5 new file mode 100644 index 00000000..32ce7004 --- /dev/null +++ b/man/arch.5 @@ -0,0 +1,52 @@ +.\" $Header$ +.TH ARCH 5 +.SH NAME +arch \- archive (library) file format +.SH SYNOPSIS +.B #include "/usr/em/h/arch.h" +.SH DESCRIPTION +The archive command +.I arch +is used to combine several files into +one. +Archives are used mainly as libraries to be searched +by the EM assembler/linker em_ass(VI) or the universal +assembler/linker em_unias(VI). +.PP +A file produced by +.I arch +has a magic number at the start, +followed by the constituent files, each preceded by a file header. +The magic number and header layout as described in the +include file are: +.RS +.PP +.nf +.ta \w'#define 'u +\w'ARMAG 'u +.so ../h/arch.h +.fi +.RE +.LP +The name is a null-terminated string; +The sizes of the other entries are determined as follows: +long's are 4 bytes in PDP-11 order, int are 2 bytes, low order +byte first, char's are 1 byte. +The date is in the +form of +.IR time (2); +the user ID and group ID are numbers; the mode is a bit pattern +per +.IR chmod (2); +the size is counted in bytes. +.PP +Each file begins on a even offset; +a null byte is inserted between files if necessary. +Nevertheless the size given reflects the +actual size of the file exclusive of padding. +.PP +Notice there is no provision for empty areas in an archive +file. +.SH "SEE ALSO" +arch(I), em_ass(VI), em_unias(VI) +.SH BUGS +Coding user and group IDs as characters is a botch. diff --git a/man/em.1 b/man/em.1 new file mode 100644 index 00000000..f8ed40c5 --- /dev/null +++ b/man/em.1 @@ -0,0 +1,87 @@ +.\" $Header$ +.TH EM I +.ad +.SH NAME +em \- calling program for em interpreters +.SH SYNOPSIS +em [-t] [+fcp] [loadfile [args ... ...] ] +.SH DESCRIPTION +The loadfile ("e.out" if not specified) is opened to read the first 8 word header. +The format of this header is explained in e.out(V). +One of these 8 words is a flag word +specifying the interpreter options requested at compile time. +The usual setting of these options is +t -f -c -p. +One of these options may be overridden at run time +by the corresponding flag of em. +Based on these options the name of the appropriate interpreter +is constructed. +.PP +This interpreter is first searched for in /usr/em/mach/pdp/int, then in the current +directory. +.PP +The flags control the following options that can be turned off +or on by prepending them with - or + respectively: +.IP t +run time tests for undefined variables, array bounds etc... +This option costs a small amount of memory and some time. +However, it is very useful for debugging. +.IP p +profiling of the entire program. The interpreter maintain tables containing +an estimate of the number of memory cycles used per source line. +This option is expensive in time as well as in memory space. +The result tables made at run time are dumped onto a file named +em_runinf. This file is converted to human readable format +by the program eminform(I) which writes the profiling information +on a file called em_profile. +.IP f +maintain a bit map of all source lines that have been executed. +This map is written also onto the file em_runinf and can be interpreted by eminform(I) which writes in this case the file em_flow. +This option is almost free in time and space. +.IP c +count line usage in tables that +contains for every source line the number of times it +was entered. +These tables are also written onto em_runinf. +Eminform(I) can be used to convert this information into the +file em_count. +Cheap in time, expensive in memory space. +.PP +These flags +give rise to 5 different interpreters which are in the +directory /usr/em/mach/pdp/int +.PP +If the interpreter exits with a non-zero exit status, then the line numbers +of the 64 last executed source lines are dumped on the file +em_runinf +in the current directory. Eminform(I) writes this information +on the human readable file em_last. +.SH "FILES" +.IP /usr/em/mach/pdp/int/em_???? 35 +interpreters proper +.PD 0 +.IP /usr/em/lib/pdp_int/em_???? +source of interpreter +.IP /usr/em/mach/pdp/int/?+ +positive option switch +.IP /usr/em/mach/pdp/int/?- +negative option switch +.IP em_runinf +memory dump containing runtime information +.IP em_profile +profile data +.IP em_count +source line count data +.IP em_flow +source line flow data +.IP em_last +last lines executed +.PD +.SH "SEE ALSO" +eminform(I), ack(I), int(I) +.SH BUGS +Most error messages are self explanatory. +The interpreter stops in case of lack of space with an error +message SEGVIO stack overflow. +If runtime flags are turned on it is advisable to try again +with the default options. +Bugs should be reported to Evert Wattel. diff --git a/man/em_decode.6 b/man/em_decode.6 new file mode 100644 index 00000000..d1901baa --- /dev/null +++ b/man/em_decode.6 @@ -0,0 +1,40 @@ +.\" $Header$ +.TH EM_DECODE VI +.ad +.SH NAME +em_decode,em_encode \- compact to readable EM and v.v. +.SH SYNOPSIS +/usr/em/lib/em_decode [ inputfile [ outputfile ] ] +.br +/usr/em/lib/em_encode [ inputfile [ outputfile ] ] +.SH DESCRIPTION +Most programs involved with the EM project only produce and accept +EM programs in compact form. +These files are only machine readable. +A description of this compact form can be found in [1]. +To inspect the code produced by compilers or to patch them for one reason +or another, you need human readable assembly code. +Em_decode will do the job for you. +.PP +Em_decode accepts the normal compact form in both optimized and +unoptimized form +.PP +Sometimes you have to make some special routines directly +in EM, for instance the routines implementing the system calls. +At these times you may use em_encode to produce compact routines +out of these human readable assembly modules. +.PP +The first argument is the input file. +The second argument is the output file. +Both programs can act as a filter. +.SH "SEE ALSO" +.IP [1] +A.S.Tanenbaum, Ed Keizer, Hans van Staveren & J.W.Stevenson +"Description of a machine architecture for use of +block structured languages" Informatica rapport IR-81. +.IP [2] +ack(I) +.SH DIAGNOSTICS +Error messages are intended to be self-explanatory. +.SH AUTHOR +Johan Stevenson, Vrije Universiteit. diff --git a/man/eminform.1 b/man/eminform.1 new file mode 100644 index 00000000..18e5dc14 --- /dev/null +++ b/man/eminform.1 @@ -0,0 +1,51 @@ +.\" $Header$ +.tr ~ +.TH EMINFORM I +.ad +.SH NAME +eminform \- converts runtime information of interpreted em to +human readable form. +.SH SYNOPSIS +eminform +.SH DESCRIPTION +The EM interpreter, em(I), has several debugging features built in. +They can be activated by flag options to em(I). +The EM interpreter collects the information while it runs the program. +When the program is terminated, the interpreter dumps this information onto +a file called em_runinf. +Eminform converts this information in human readable form onto +a set of files with fixed names, the file em_runinf itself is unlinked. +.PP +.in +15 +.ti -13 +~~em_last~~~~A circular buffer is used to keep track of +the last collection of executed source lines. +.ti -13 +~~em_flow~~~~A bit map for all source lines tells which lines +are executed. +.ti -13 +~~em_count~~~Count the number of times each source line was entered. +.ti -13 +~~em_profile~Estimate the number of memory cycles +spent on each source line. +.in -15 +.LP +The most common use of eminform is to print the numbers of the last executed +source lines if an execution error occurred. +No arguments are needed in this case. +.LP +Eminform will create only those files for which there were +interpreter flags turned on. If no runtime error occurred and +no flag was turned on the file em_runinf is not created. In +this case eminform will give the error message "read header +failed". +.SH FILES +em_runinf, em_last, em_flow, em_count, em_profile +.SH "SEE ALSO" +ack(I), int(I), em(I). +.SH BUGS +If an entire procedure is not touched, the the file name in +which this procedure occured is unknown. +If no em_runinf is available the error message is "read header +failed" and a core dump is created. +Bugs should be reported to Evert Wattel diff --git a/man/i86_as.1 b/man/i86_as.1 new file mode 100644 index 00000000..9f694715 --- /dev/null +++ b/man/i86_as.1 @@ -0,0 +1,145 @@ +.\" $Header$ +.TH I86_AS 1 +.ad +.SH NAME +i86_as \- assembler for Intel 8086 +.SH SYNOPSIS +/usr/em/lib/i86_as [options] argument ... +.SH DESCRIPTION +This assembler is made with the general framework +described in \fIuni_ass\fP(6). +.SH SYNTAX +.IP segments +An address on the Intel 8086 consists of two pieces: +a segment number and an offset. A memory address is computed as +the segment number shifted left 4 bits + the offset. +Assembly language addresses only give the offset, with the exception of +the address of an inter-segment jump or call (see \fIaddressing modes\fP +below). +For each segment type (.org, .text, .data, or .bss) the segment number +must be given with the .sbase pseudo-instruction. +The syntax is: +.br + .sbase expression +.br +with segment-id one of .org, .text, .data, or .bss. +Example: +.br + .sbase .text 0x1000 + +.IP registers +The Intel 8086 has the following 16-bit registers: +.br +Four general registers: ax (accumulator), bx (base), cx (count), and dx (data). +The upper halves and lower halves of these registers are separately +addressable as ah, bh, ch, dh, and al, bl, cl, dl respectively. +.br +Two pointer registers: sp (stack pointer) and bp (base pointer). +.br +Two index registers: si (source index) and di (destination index). +.br +Four segment registers: cs (code), ds (data), ss (stack), and es (extra). +.IP "addressing modes" +.nf +.ta 8n 16n 24n 32n 40n 48n +syntax meaning + +expr the value of \fIexpr\fP is immediate data or + an address offset. There is no special + notation for immediate data. + +register one of the aforementioned general registers + or their upper or lower halves, or one of the + four segment registers. + +(expr) the value of expr is the address of the operand. + +(reg) +expr (reg) the value of \fIexpr\fP (if present) + the contents of + \fIreg\fP (which must be a pointer or an index register) + is the address of the operand. + +(preg) (ireg) +expr (preg) (ireg) + the value of \fIexpr\fP (if present) + the contents of + \fIpreg\fP (which must be a pointer register) + the + contents of \fIireg\fP (which must be an index register) + is the address of the operand. + +The next addressing mode is only allowed with the instructions +"callf" or "jmpf". + +expr : expr the value of the first \fIexpr\fP is a segment number, + the value of the second \fIexpr\fP is an address offset. + The (absolute) address of the operand is computed + as described above. +.fi + +.IP instructions +Each time an address is computed the assembler decide which segment register +to use. You can override the assembler's choice by prefixing the instruction +with one of eseg, cseg, sseg, or dseg; these prefixes indicate that the +assembler should choose es, cs, ss, or ds instead. +.br +Example: +.ti +8 +dseg movs +.SH "SEE ALSO" +uni_ass(6), +ack(1), +.br +MCS-86 assembly language reference manual, 1978, Intel Corporation +.SH EXAMPLE +.nf +.ta 8n 16n 24n 32n 40n 48n +An example of Intel 8086 assembly language: + + _panic: + push bp + mov bp,sp + .data + _35: + .word 24944 + .word 26990 + .word 14947 + .word 32 + .text + call _disable + mov ax,_35 + push ax + call _str + pop si + push 4(bp) + call _str + pop si + call _nlcr + call _exit + mov sp,bp + pop bp + ret + .extern _nopanic + _nopanic: + push bp + mov bp,sp + .data + _38: + .word 28526 + .word 24944 + .word 26990 + .word 14947 + .word 32 + .text + mov ax,_38 + push ax + call _str + pop si + push 4(bp) + call _str + pop si + push 6(bp) + call _octal + pop si + mov sp,bp + pop bp + ret +.fi diff --git a/man/m68k2_as.1 b/man/m68k2_as.1 new file mode 100644 index 00000000..77ef9308 --- /dev/null +++ b/man/m68k2_as.1 @@ -0,0 +1,100 @@ +.\" $Header$ +.TH M68K2_AS 1 +.ad +.SH NAME +m68k2_as \- assembler for Motorola 68000 +.SH SYNOPSIS +/usr/em/lib/m68k2_as [options] argument ... +.br +/usr/em/lib/m68k4_as [options] argument ... +.SH DESCRIPTION +This assembler is made with the general framework +described in \fIuni_ass\fP(6). +.SH SYNTAX +.IP registers +The 68000 has the following registers: +seven data-registers (d1 - d7), seven address-registers (a1 - a6, sp) +of which sp is the system stack pointer, a program counter (pc), +a status register (sr), and a condition codes register (ccr) which is actually +just the low order byte of the status register. +.IP "addressing modes" +.nf +.ta 8n 16n 24n 32n 40n 48n +syntax meaning (name) + +reg contents of \fIreg\fP is operand, where \fIreg\fP is + one of the registers mentioned above (register direct) + +(areg) contents of \fIareg\fP is address of operand, where + \fIareg\fP is an address-register + (address register indirect) + +(areg)+ same as (areg), but after the address is used, + \fIareg\fP is incremented by the operand length + (postincrement) + +-(areg) same as (areg), but before the address is used, + \fIareg\fP is decremented by the operand length + (predecrement) + +expr(areg) +expr(pc) \fIexpr\fP + the contents of the register yields the + address of the operand (displacement) + +expr(areg, ireg) +expr(pc, ireg) \fIexpr\fP + the contents of the register + the contents + of \fIireg\fP yields the address of the operand. \fIireg\fP is + an address- or a data-register. + \fIireg\fP may be followed by .w or .l indicating whether + the size of the index is a word or a long + (displacement with index) + +expr \fIexpr\fP is the address of the operand + (absolute address) + +#expr \fIexpr\fP is the operand (immediate) +.fi + +Some instructions have as operand a register list. This list consists of +one or more ranges of registers separated by '/'s. A register range consists +of either one register (e.g. d3) or two registers separated by a '-' +(e.g. a2-a4, or d4-d5). The two registers must be in the same set (address- +or data-registers) and the first must have a lower number than the second. +.IP instructions +Some instructions can have a byte, word, or longword operand. +This may be indicated by prepending the mnemonic with .b, .w, or .l +respectively. Default is .w. +.SH "SEE ALSO" +uni_ass(6), +ack(1), +.br +MC68000 16-bit microprocessor User's manual, Motorola Inc, 1979 +.SH EXAMPLE +.sp 2 +.nf +.ta 8n 16n 24n 32n 40n 48n 56n 64n + .define .cii + + .text + .cii: + movem.l a0/d0/d1,.savreg + move.l (sp)+,a0 ! return address + move (sp)+,d0 ! destination size + sub (sp)+,d0 ! destination - source size + bgt 1f + sub d0,sp ! pop extra bytes + bra 3f + 1: + move (sp),d1 + ext.l d1 + swap d1 + asr #1,d0 + 2: + move.w d1,-(sp) + sub #1,d0 + bgt 2b + 3: + move.l a0,-(sp) + movem.l .savreg,a0/d0/d1 + rts +.fi diff --git a/man/m68k_int.1 b/man/m68k_int.1 new file mode 100644 index 00000000..9948e4e7 --- /dev/null +++ b/man/m68k_int.1 @@ -0,0 +1,96 @@ +.\" $Header$ +.TH EM I +.ad +.SH NAME +em \- calling program for em interpreters +.SH SYNOPSIS +em [-t] [+fcp] [loadfile [args ... ...] ] +.SH DESCRIPTION +The loadfile ("e.out" if not specified) is opened to read the first 8 word header. +The format of this header is explained in e.out(V). +One of these 8 words is a flag word +specifying the interpreter options requested at compile time. +The usual setting of these options is +t -f -c -p. +These options may be overridden at runtime as follows: +em -t turns the test option of; em +c turns count on ; em +p turns profile +on ; em +c +p turns both count and profile on. +Based on these options the name of the appropriate interpreter +is constructed. +Two versions exist, one for two byte words and four byte pointers and +one for four byte words and pointers. +The information in the header of the e.out file is used by em to select the +right interpreter for the word size of used in the e.out file. +.PP +This interpreter is searched for in /usr/em/lib/int[24]4. +.PP +The flags control the following options that can be turned off +or on by prepending them with - or + respectively: +.IP t +run time tests for undefined variables, array bounds etc... +This option costs a small amount of memory and some time. +However, it is very useful for debugging. +.IP p +profiling of the entire program. The interpreter maintains tables containing +an estimate of the number of processor state cycles used per source line. +A processor state cycle is equal to two internal clock cycles. +This option is expensive in time as well as in memory space. +The result tables made at run time are dumped in a human readable +format onto a file named +em_profile. +.IP f +maintain a bit map of all source lines that have been executed. +This map is written onto a file em_flow . +This option is almost free in time and space. +The file is not easy to read. +Of each procedure only the lines between the first statement and the last +statement are represented in the bit map. +Currently this option is not installed in the em tree. +.IP c +count line usage in tables that +contains for every source line the number of times it +was entered. +These tables are written onto em_count, a human readable file . +This option is cheap in time, but costs some in memory space. +.IP l +dump the line numbers of the last 64 lines entered onto a file named +em_last. +This file will be in a human readable format. +This option is used simultaneously with the test option. +.PP +These flags +give rise to 5 different interpreters which are in the +directory /usr/em/lib/int24 or in /usr/em/lib/int44 +for the two byte word or the four byte word options, respectively. +.PP +.SH "FILES" +.IP /usr/em/lib/int[24]4/em_???? 35 +interpreters proper +.PD 0 +.IP /usr/em/mach/m68k2/int/mloop? +source of interpreter +.IP em_profile +profile data +.IP em_count +source line count data +.IP em_flow +source line flow data +.IP em_last +last lines executed +.PD +.SH "SEE ALSO" +\fIack\fP(I), +\fIint24\fP(I), +\fIint44\fP(I) +.SH BUGS +Most error messages are self explanatory. +If runtime flags are turned on it is advisable to try again +with the default options. +If the interpreter does not work most probably your particular +machine has an other format for the system calls then assumed +in the source. +In that case adapt source file mloopc to your machine. +Also the instruction that causes the machine to allocate stack +space might differ . +In that case adapt the macro \fIclaimstack\fP in deffile. +.SH AUTHOR +Freek van Schagen diff --git a/man/macro.v7 b/man/macro.v7 new file mode 100644 index 00000000..620e78cf --- /dev/null +++ b/man/macro.v7 @@ -0,0 +1,66 @@ +.\" $Header$ +.de TH +.PD +.br +.bp +.lc +.nr in 5 +.de hd +'sp 2 +'tl '\\$1(\\$2)'Amsterdam Compiler Kit'\\$1(\\$2)' +'sp 2 +\\.. +.wh -6 fo +.wh 0 hd +.nr pi 5 +.. +.de fo +'sp 2 +'tl ''- % -'' +'bp +.. +.de PD +.nr pd 0.5v +.if \\n(.$ .nr pd \\$1 +.. +.de SH +.nr in 5 +.nr pi 5 +.in \\n(in +.ti 0 +.sp \\n(pdu +.ne 2 +.fi +\fB\\$1\fP +.br +.. +.de LP +.PP +.. +.de PP +.sp \\n(pdu +.ne 2 +.in \\n(in +.nr pi 5 +.ns +.. +.de IP +.if \\n(.$-1 .nr pi \\$2 +.sp \\n(pdu +.in \\n(in+\\n(pi +.ta \\n(in \\n(in+\\n(pi +.ti 0 +\fB\\$1\fR\c +.if \w'\fB\\$1\fP'-\\n(pin+1n .br +.. +.de RS +.nr in +5 +.in +5 +.. +.de RE +.in -5 +.nr in -5 +.. +.de RF +\fI\\$1\fP(\\$2)\\$3 +.. diff --git a/man/ns_as.1 b/man/ns_as.1 new file mode 100644 index 00000000..d5fd34b9 --- /dev/null +++ b/man/ns_as.1 @@ -0,0 +1,148 @@ +.TH NS_ASS VI +.ad +.SH NAME +ns_as \- National Semiconductor 16032 assembler/linker +.SH SYNOPSIS +\&..../lib/ns/as [options] argument ... +.SH DESCRIPTION +The assembler for the National Semiconductor 16032 is based +on the universal assembler \fIuni_ass\fP(VI). +The mnemonics for the instructions are taken from the NS-16000 +Programmers Reference Manual. +The syntax of the instruction operands is similar to the syntax used +in that manual, +although the meaning is sometimes quite different. +The cross assembler issued by National Semiconductor +associates a type (sb,..) with each symbol +and automatically generates sb offset mode for symbols of type sb. +This assembler does not record the types, +each symbol simply produces an untyped value. +.sp 1 +The possible operands are: +.IP "general registers +These are called r0, r1, r2, r3, r4, r5, r6 and r7. +The symbol REG is used to indicate use of any of these 8 registers +in other operands. +.IP "floating point registers +These are called f0, f1, f2, f3, f4, f5, f6 and f7. +.IP "dedicated registers +All types of dedicated registers can be used with the appropriate instructions. +Examples: sb, fp, intbase, ptb1. +.IP expr(REG) +register relative +.IP expr(fp) +frame pointer relative +.IP expr(sb) +static base relative +.IP expr(sp) +stack pointer relative +.IP expr(pc) +program counter relative, +the expression indicates a location in memory from which the current value +of '.' is subtracted by the assembler. +E.g. "movw label(pc),r0; label: .word ..." moves the contents of the word +at \fIlabel\fP to r0. +.IP expr(expr(fb)) +.IP expr(expr(sb)) +.IP expr(expr(sp)) +memory relative +.IP @expr +absolute +.IP external(expr)+expr +The external mode is provided, although this assembler +does not build a module table. +.IP tos +top of stack. +.PD 0 +.sp 1 +.PP +Usage of the scaled index operands is allowed. +.br +The convention used to indicate offset length by appending :B, :W or :D +to offsets is not implemented. +The assembler tries to find out the minimal size needed for any constant +in an operand of the instruction placed in the text segment. +Offsets in instructions outside \fI.text\fP are always four bytes. +.PP +All special operands, e.g. register list, configuration list, have +the same format as in the Programmers Reference Manual. +.PP +Whenever possible the assembler automatically uses the short(quick) opcodes for +jsr(jsb), jump(br), add(addq), cmp(cmpq) and mov(movq). +.SH BUGS +The data types floating and packed-decimal are not supported. +.br +Initialization of floating-point numbers is not possible. +.br +The mnemonics of the slave processor instructions are poorly documented, +the format of the NS-16032S-6 data sheet is used. +.br +The documentation gave contradictory information on the format +of a few instructions. +.IP - +Three different schemes are presented for the encoding +of the last operand of the block instructions. +.IP - +Two different values are specified for +the encoding of the msr register in smr and lmr instructions. +.IP - +Two different possibilities are given for the encoding of +the instructions movsu and movus. +.SH EXAMPLE +.nf +.ta 12n 20n 28n 36n + +00000000 0E0B02 setcfg [ m ] + label: +00000003 EC3E lprb psr,r7 +00000005 2D37 sprw intbase,r6 + +00000007 EA7C br label + +00000009 02803B bsr rout1 +0000000C 228044 cxp rout1 +0000000F 1204 ret 4 +00000011 4204 rett 4 +00000013 328044 rxp rout1 + +00000016 1E0300 rdval r0 +00000019 163028 scsr r5 + +0000001C 3F32 shid r6 +0000001E 7F0B bispsrd r1 +00000020 7C17 caseb r2 +00000022 7FA806 cxpd @6 + +00000025 021F jsr @rout1 + +00000027 BEB529 absf f5,f6 +0000002A EE0538 movusw r7,r0 +0000002D 3E40A101 movbl 1,f5 +00000031 CE440003 cmpmb r0,r1,4 + +00000035 CE4F0800 extsd r1,r1,0,1 +00000039 62A0 save [ r5, r7 ] +0000003B 1E0B00 lmr bpr0,r0 + +0000003E 0E8C04 skpst w +00000041 CC0042 acbb 1,r0,label +00000044 B2 rout1: wait +00000045 7F950C0B adjspd 11(12(sb)) +00000049 7CA50D adjspb 13 +0000004C 7DB50102 adjspw external(1)+2 +00000050 7FBD adjspd tos + +00000052 7CED860807 adjspb 7(8(fp))[r6:w] + +.fi +.SH "SEE ALSO" +uni_ass(VI) +.br +NS 16000 Programmers Reference Manual. Publ. no. 420306565-001PB +.br +NS16032S-6, NS16032S-4 High Performance Microprocessors, november 1982 +.br +publ. no. 420306619-002A. +.PD 0 +.SH AUTHOR +Ed Keizer, Vrije Universiteit diff --git a/man/pdp_as.1 b/man/pdp_as.1 new file mode 100644 index 00000000..afd29b02 --- /dev/null +++ b/man/pdp_as.1 @@ -0,0 +1,138 @@ +.\" $Header$ +.TH PDP_AS 1 +.ad +.SH NAME +pdp_as \- assembler for PDP 11 +.SH SYNOPSIS +/usr/em/lib/pdp_as [options] argument ... +.SH DESCRIPTION +This assembler is made with the general framework +described in \fIuni_ass\fP(6). +.SH SYNTAX +.IP registers +The pdp11 has seven general registers, numbered r0 through r7. +Of these, r6 is the stack pointer and can also be referenced to by \fIsp\fP, +r7 is the program counter and has \fIpc\fP as synonym. There are also six +floating-point registers fr0 through fr5, but the names r0 through r5 can +also be used. From the context will be derived what kind of register is meant. +.IP "addressing modes" +.nf +.ta 8n 16n 24n 32n 40n 48n +syntax meaning (name) + +reg contents of register reg is operand. + (register) + +(reg) contents of reg is address of operand. + (register deferred) + +(reg)+ as (reg), but after the operand is fetched + the contents of reg is incremented by the + size of the operand. (auto-increment) + +*(reg)+ contents of reg points to address of the operand. + after the operand is fetched, reg is incremented + by two. (auto-increment deferred) + +-(reg) as (reg), but before the operand is fetched + the contents of reg is decremented by the + size of the operand. (auto-decrement) + +*-(reg) before the operand is fetched, reg is decremented + by two. then the contents of reg points to the + address of the operand. (auto-decrement deferred) + +expr(reg) value of expr + contents of reg yields address + of operand. (index) + +*expr(reg) value of expr + contents of reg yields pointer + to address of operand. (index deferred) + +$expr the value of expr is the operand. (immediate) + +*$expr the value of expr is the address of the operand. + (absolute) + +expr expr is address of operand. (relative) + +*expr expr points to the address of the operand. + (relative deferred) + +.fi +.IP "condition code instructions" +Two or more of the "clear" instructions (clc, cln, clv, clz), or +two or more of the "set" instructions (sec, sen, sev, sez) may be +or-ed together with `|' to yield a instruction that clears or sets two or more +of the condition-bits. Scc and ccc are not predefined. +.IP "extended branches" +The assembler recognizes conditional branches with a "j" substituted for +the "b". When the target is too remote for a simple branch, a converse branch +over a jmp to the target is generated. Likewise jbr assembles into either br +or jmp. +.IP "floating-point instructions" +The names of several floating-point instructions differ from the names +in the handbook mentioned below. Synonyms ending in "d" for instructions ending +in "f" are not recognized. Some instructions have different names; the mapping +is as below. +.nf +.ta 8n 16n 24n 32n 40n 48n + +handbook pdp_as + +ldcif, ldclf, +ldcid, ldcld movif + +stcfi, stcfl, +stcdi, stcdl movfi + +ldcdf, ldcfd movof + +stcdf, stcfd movfo + +ldexp movie + +stexp movei + +ldd, ldf movf + +std, stf movf + +.fi +The movf instruction assembles into stf, when the first operand is one of the +first three floating-point registers, otherwise it assembles into ldf. +.IP sys +This instruction is synonymous with trap. +.SH EXAMPLE +An example of pdp11 assembly code. +.nf +.ta 8n 16n 24n 32n 40n 48n + +!this is the routine that reads numbers into r0 +!the number is terminated by any non digit +!the non digit is left in r1 +innum: clr r3 !r3 will accumulate the number +inloop: jsr pc,_getchar !read a character into r0 + cmp r0,$0121 !is it a Q? + jeq quit + cmp r0,$48 !is the character a digit? + jlt indone !digits 0-9 have codes 060-071 octal + cmp r0,$56 + jgt indone + mul $10,r3 !r3 = 10 * r3 + sub $48,r3 !convert ascii code to numerical value + add r0,r3 !r3 = old sum * 10 + new digi + jbr inloop + +indone: mov r0,r1 !put the first non digit into r1 + mov r3,r0 !put the number read into r0 + rts pc !return to caller + +.fi +.SH "SEE ALSO" +uni_ass(6), +ack(1), +.br +PDP11/60 processor handbook, Digital Equipment Corporation, 1977 +.SH BUGS +You cannot use *reg in place of (reg). Likewise *(reg) is not understood as +*0(reg). diff --git a/man/z8000_as.1 b/man/z8000_as.1 new file mode 100644 index 00000000..cb2bb777 --- /dev/null +++ b/man/z8000_as.1 @@ -0,0 +1,163 @@ +.TH Z8000_AS 1 +.ad +.SH NAME +z8000_as \- assembler for Zilog z8000 (segmented version) +.SH SYNOPSIS +/usr/em/lib/z8000_as [options] argument ... +.SH DESCRIPTION +This assembler is made with the general framework +described in \fIuni_ass\fP(6). +.SH SYNTAX +.IP instructions +Instruction mnemonics are implemented exactly as described in +\fIZ8000 PLZ/ASM Assembly Language Programming Manual\fP and +\fIAmZ8001/2 Processor Instruction Set\fP. +.IP registers +The z8000 has sixteen 16-bit general purpose registers specified +as R0 through R15. All sixteen registers can be used as accumulators. +In addition to this, fifteen of the sixteen registers may be used +in addressing mode calculations as either indirect, index or +base-address registers. Because the instruction format encoding +uses the value zero to differentiate between various addressing +modes, register R0 (or the register pair RR0) cannot be used as an +indirect, index or base-address register. +It is also possible to address registers as groups of 8, 32 or 64 bits. +These registers are specified as follows. +.nf +.ta 8n 16n 24n 32n 40n 48n +- RH0, RL0, RH1, RL1, ..., RH7, RL7 for 8-bit regis- + ters. (\fIH\fP stands for high-order byte, and \fIL\fP stands + for low-order byte within a word register). These + registers overlap 16-bit registers R0 through R7. +- RR0, RR2, ..., RR14 for 32-bit register pairs. +- RQ0, RQ4, RQ8 and RQ12 for 64-bit register quadruples. +.fi +Besides register pair RR14 is used as stackpointer. +.IP "addressing modes" +.nf +.ta 8n 16n 24n 32n 40n 48n +syntax meaning (name-mnemonic) + +$expr the value of expr is the operand. + (immediate-IM) + +reg contents of register reg is operand. Any + register as described above is allowed. + (register-R) + +*reg32 contents of register pair reg32 is add- + ress of operand. Any register pair can + be used except RR0. + (indirect register-IR) + +expr expr is address of operand. + (direct address-DA) + +expr(reg16) value of expr + contents of word regis- + ter reg16 yields address of operand. + Any word register can be used except R0. + (indexed address-X) + +expr expr is address of operand. This mode + is implied by its instruction. It is + only used by CALR, DJNZ, JR, LDAR and + LDR and is the only mode available to + these instructions. In fact this mode + differs not from the mode DA. + (relative address-RA) + +reg32($expr) contents of register pair reg32 + value + of expr yields address of operand. Any + register pair can be used except RR0. + (based address-BA) + +reg32(reg16) contents of register pair reg32 + con- + tents of word register reg16 yields + address of operand. Any register pair/ + word register can be used except RR0/R0. + (based indexed address-BX) + +.fi +.IP "segmented addresses" +Segmented addresses require 23 bits, 7 bits for the segment number +and 16 bits for the offset within a segment. +So segment 0 contains addresses 0-FFFF, segment 1 contains addresses +10000-1FFFF, and so on. +.br +Assembler syntax of addresses and immediate data is as described above +(modes IM, DA and X). +Thus the assembler treats e.g. address 2BC0F as an address in segment 2 +with offset BC0F within the segment. +There is also an explicit way to express this using the, more unusual, +syntax <>offset. +.br +There are two internal representations of segmented addresses +depending on the size of the offset. If the offset fits into 8 bits +the address is stored in one word (the low-order byte containing +the offset, bits 8 to 14 containing the segment number and +bit 15 containing a zero) otherwise the address is stored in two +words (the lower word containing the offset, the upper word as +before but bit 15 containing 1 indicating that the offset is in +the next word). +This is important for instructions which has an operand of mode DA +or X. +.IP "extended branches" +When the target address in a relative jump/call (JR/CALR) +does not fit into the instruction format, the assembler generates +a corresponding `normal' jump/call (JP/CALL). +.SH EXAMPLE +An example of z8000 assembly code. +.nf +.ta 8n 16n 24n 32n 40n 48n + +! This z8000 assembly routine converts a positive number +!(in R1) to a string representing the number and puts this +!string into a buffer (R3 contains the starting address of +!this buffer. The base is in R4 determining %x, %d or %o. + +convert: + exts RR0 !sign-extend R1 + div RR0, R4 !divide by the base + test R1 !R1 contains the quotient + jr EQ, 5f + !if quotient is 0 convert is ready + !else push remainder onto the stack + push *RR14, R0 + calr convert !and again... + pop R0, *RR14 +5: add R0, $060 !add `0' + cp R0, $071 !compare to `9' + jr LE, 8f + add R0, $7 !in case of %x `A'-`F' +8: ldb 0(R3), RL0 !put character into buffer + inc R3 + ret + +.fi +.SH "SEE ALSO" +uni_ass(6). +.br +ack(1). +.br +Z8000 PLZ/ASM Assembly Language Programming Manual, april 1979. +.br +AmZ8001/2 Processor Instruction Set, 1979. +.SH BUGS +You cannot use (reg16) instead of 0(reg16). +.br +Condition codes \fIZ\fP (meaning zero), \fIC\fP (meaning carry) and +(meaning always false) are not implemented. +The first two because they also represent flags and the third one +because it's useless. +So for \fIZ\fP/\fIC\fP use \fIEQ\fP/\fIULT\fP. +.br +The z8000 assembly instruction set as described in the book +\fIAmZ8001/2 Processor Instruction Set\fP differs from the one +described in the manual \fIZ8000 PLZ/ASM Assembly Language Programming +Manual\fP in that the book includes CLRL, LDL (format F5.1) and +PUSHL (format F5.1) which all in fact do not (!) work. +.br +On the other side the book excludes SIN, SIND, SINDR, SINI, SINIR, +SOUT, SOUTD, SOTDR, SOUTI and SOTIR. +Whether these instructions do work as described in the manual has not +been tested yet. diff --git a/man/z80_as.1 b/man/z80_as.1 new file mode 100644 index 00000000..be2efb43 --- /dev/null +++ b/man/z80_as.1 @@ -0,0 +1,66 @@ +.\" $Header$ +.TH z80_AS 1 +.ad +.SH NAME +z80_as \- assembler for Zilog z80 +.SH SYNOPSIS +/usr/em/lib/z80_as [options] argument ... +.SH DESCRIPTION +This assembler is made with the general framework +described in \fIuni_ass\fP(6). +.SH SYNTAX +.IP registers +The z80 has six general-purpose 8-bit registers: b, c, d, e, h, l; +an 8-bit accumulator: a; an 8-bit flag register: f; an 8-bit interrupt +vector: i; an 8-bit memory refresh register: r; two 16-bit index registers: +ix, iy; a 16-bit stack pointer: sp; and a 16-bit program counter: pc. +The general-purpose registers can be paired to form three registers pairs of +16 bits each: bc, de, hl. +An alternate set of registers is provided that duplicates the accumulator, +the flag register, and the general-purpose registers. The "exx"-instruction +exchanges the contents of the two sets of general-purpose registers; the +contents of the accumulator and flag register can be exchanged with the contents +of their alternates by the "ex af, af2"-instruction. +.IP "addressing modes" +.nf +.ta 8n 16n 24n 32n 40n 48n +syntax meaning + +expr dependent on the instruction, the + value of \fIexpr\fP can be immediate + data or the address of the operand. + There is no special notation for + immediate data. + +(ireg + expr) +(ireg - expr) the contents of ireg (which must be + one of the index-registers) + or - + the - one byte - value of \fIexpr\fP + yield the address of the operand. + +(expr) the value of \fIexpr\fP is the address of + the operand. + +reg the contents of \fIreg\fP - one of the above- + mentioned registers - is the operand. + +(reg) the contents of \fIreg\fP - one of the 16-bit + registers except pc - is the address of + the operand. + +nz, z, nc, c, +po, pe, p, m the letters indicate a condition-code: + nonzero, zero, carry, no carry, + parity odd, parity even, sign positive, + sign negative respectively. Used by conditional + jump, call, and return instructions. + +.fi +.IP instructions +The jr-instruction will automatically be replaced by a jp-instruction if the +target is too remote. +.SH "SEE ALSO" +uni_ass(6), +ack(1), +.br +Z80 Users Manual, Joseph J. Carr, Reston Publishing Company, 1980 diff --git a/modules/compare b/modules/compare new file mode 100755 index 00000000..5eca5d66 --- /dev/null +++ b/modules/compare @@ -0,0 +1,10 @@ +case $# in +1) DEST="$1" + SRC=`basename $DEST` + ;; +2) DEST="$2" + SRC="$1" + ;; +*) echo $0 [source] destination ;; +esac +cmp "$SRC" ../../$DEST diff --git a/modules/h/em_CtoO.h b/modules/h/em_CtoO.h new file mode 100644 index 00000000..b7e92a2a --- /dev/null +++ b/modules/h/em_CtoO.h @@ -0,0 +1,267 @@ +#define C_aar O_aar +#define C_aar_narg O_aar_narg +#define C_adf O_adf +#define C_adf_narg O_adf_narg +#define C_adi O_adi +#define C_adi_narg O_adi_narg +#define C_adp O_adp +#define C_ads O_ads +#define C_ads_narg O_ads_narg +#define C_adu O_adu +#define C_adu_narg O_adu_narg +#define C_and O_and +#define C_and_narg O_and_narg +#define C_asp O_asp +#define C_ass O_ass +#define C_ass_narg O_ass_narg +#define C_beq O_beq +#define C_bge O_bge +#define C_bgt O_bgt +#define C_ble O_ble +#define C_blm O_blm +#define C_bls O_bls +#define C_bls_narg O_bls_narg +#define C_blt O_blt +#define C_bne O_bne +#define C_bra O_bra +#define C_bss_cst O_bss_cst +#define C_bss_fcon O_bss_fcon +#define C_bss_pnam O_bss_pnam +#define C_bss_ucon O_bss_ucon +#define C_cai O_cai +#define C_cal O_cal +#define C_cff O_cff +#define C_cfi O_cfi +#define C_cfu O_cfu +#define C_cif O_cif +#define C_cii O_cii +#define C_ciu O_ciu +#define C_close O_close +#define C_cmf O_cmf +#define C_cmf_narg O_cmf_narg +#define C_cmi O_cmi +#define C_cmi_narg O_cmi_narg +#define C_cmp O_cmp +#define C_cms O_cms +#define C_cms_narg O_cms_narg +#define C_cmu O_cmu +#define C_cmu_narg O_cmu_narg +#define C_com O_com +#define C_com_narg O_com_narg +#define C_con_cst O_con_cst +#define C_con_fcon O_con_fcon +#define C_con_pnam O_con_pnam +#define C_con_scon O_con_scon +#define C_con_ucon O_con_ucon +#define C_csa O_csa +#define C_csa_narg O_csa_narg +#define C_csb O_csb +#define C_csb_narg O_csb_narg +#define C_cst O_cst +#define C_cuf O_cuf +#define C_cui O_cui +#define C_cuu O_cuu +#define C_dch O_dch +#define C_dec O_dec +#define C_dee O_dee +#define C_del O_del +#define C_df_dlb O_df_dlb +#define C_df_dnam O_df_dnam +#define C_df_ilb O_df_ilb +#define C_dlb O_dlb +#define C_dnam O_dnam +#define C_dup O_dup +#define C_dus O_dus +#define C_dus_narg O_dus_narg +#define C_dvf O_dvf +#define C_dvf_narg O_dvf_narg +#define C_dvi O_dvi +#define C_dvi_narg O_dvi_narg +#define C_dvu O_dvu +#define C_dvu_narg O_dvu_narg +#define C_end O_end +#define C_end_narg O_end_narg +#define C_exc O_exc +#define C_exg O_exg +#define C_exg_narg O_exg_narg +#define C_exp O_exp +#define C_fcon O_fcon +#define C_fef O_fef +#define C_fef_narg O_fef_narg +#define C_fif O_fif +#define C_fif_narg O_fif_narg +#define C_fil O_fil +#define C_gto O_gto +#define C_hol_cst O_hol_cst +#define C_hol_fcon O_hol_fcon +#define C_hol_pnam O_hol_pnam +#define C_hol_ucon O_hol_ucon +#define C_icon O_icon +#define C_ilb O_ilb +#define C_inc O_inc +#define C_ine O_ine +#define C_init O_init +#define C_inl O_inl +#define C_inn O_inn +#define C_inn_narg O_inn_narg +#define C_inp O_inp +#define C_ior O_ior +#define C_ior_narg O_ior_narg +#define C_lae O_lae +#define C_lal O_lal +#define C_lar O_lar +#define C_lar_narg O_lar_narg +#define C_ldc O_ldc +#define C_lde O_lde +#define C_ldf O_ldf +#define C_ldl O_ldl +#define C_lfr O_lfr +#define C_lil O_lil +#define C_lim O_lim +#define C_lin O_lin +#define C_lni O_lni +#define C_loc O_loc +#define C_loe O_loe +#define C_lof O_lof +#define C_loi O_loi +#define C_lol O_lol +#define C_lor O_lor +#define C_los O_los +#define C_los_narg O_los_narg +#define C_lpb O_lpb +#define C_lpi O_lpi +#define C_lxa O_lxa +#define C_lxl O_lxl +#define C_magic O_magic +#define C_mes_begin O_mes_begin +#define C_mes_end O_mes_end +#define C_mlf O_mlf +#define C_mlf_narg O_mlf_narg +#define C_mli O_mli +#define C_mli_narg O_mli_narg +#define C_mlu O_mlu +#define C_mlu_narg O_mlu_narg +#define C_mon O_mon +#define C_ngf O_ngf +#define C_ngf_narg O_ngf_narg +#define C_ngi O_ngi +#define C_ngi_narg O_ngi_narg +#define C_nop O_nop +#define C_open O_open +#define C_pnam O_pnam +#define C_pro O_pro +#define C_pro_narg O_pro_narg +#define C_rck O_rck +#define C_rck_narg O_rck_narg +#define C_ret O_ret +#define C_rmi O_rmi +#define C_rmi_narg O_rmi_narg +#define C_rmu O_rmu +#define C_rmu_narg O_rmu_narg +#define C_rol O_rol +#define C_rol_narg O_rol_narg +#define C_rom_cst O_rom_cst +#define C_rom_fcon O_rom_fcon +#define C_rom_pnam O_rom_pnam +#define C_rom_scon O_rom_scon +#define C_rom_ucon O_rom_ucon +#define C_ror O_ror +#define C_ror_narg O_ror_narg +#define C_rtt O_rtt +#define C_sar O_sar +#define C_sar_narg O_sar_narg +#define C_sbf O_sbf +#define C_sbf_narg O_sbf_narg +#define C_sbi O_sbi +#define C_sbi_narg O_sbi_narg +#define C_sbs O_sbs +#define C_sbs_narg O_sbs_narg +#define C_sbu O_sbu +#define C_sbu_narg O_sbu_narg +#define C_scon O_scon +#define C_sde O_sde +#define C_sdf O_sdf +#define C_sdl O_sdl +#define C_set O_set +#define C_set_narg O_set_narg +#define C_sig O_sig +#define C_sil O_sil +#define C_sim O_sim +#define C_sli O_sli +#define C_sli_narg O_sli_narg +#define C_slu O_slu +#define C_slu_narg O_slu_narg +#define C_sri O_sri +#define C_sri_narg O_sri_narg +#define C_sru O_sru +#define C_sru_narg O_sru_narg +#define C_ste O_ste +#define C_stf O_stf +#define C_sti O_sti +#define C_stl O_stl +#define C_str O_str +#define C_sts O_sts +#define C_sts_narg O_sts_narg +#define C_teq O_teq +#define C_tge O_tge +#define C_tgt O_tgt +#define C_tle O_tle +#define C_tlt O_tlt +#define C_tne O_tne +#define C_trp O_trp +#define C_ucon O_ucon +#define C_xor O_xor +#define C_xor_narg O_xor_narg +#define C_zeq O_zeq +#define C_zer O_zer +#define C_zer_narg O_zer_narg +#define C_zge O_zge +#define C_zgt O_zgt +#define C_zle O_zle +#define C_zlt O_zlt +#define C_zne O_zne +#define C_zre O_zre +#define C_zrf O_zrf +#define C_zrf_narg O_zrf_narg +#define C_zrl O_zrl + +#define _10_C_hol_ilb _10_O_hol_ilb +#define _11_C_bss_dnam _11_O_bss_dnam +#define _12_C_bss_dlb _12_O_bss_dlb +#define _13_C_bss_icon _13_O_bss_icon +#define _14_C_bss_ilb _14_O_bss_ilb +#define _15_C_con_dnam _15_O_con_dnam +#define _16_C_con_dlb _16_O_con_dlb +#define _17_C_con_icon _17_O_con_icon +#define _18_C_con_ilb _18_O_con_ilb +#define _19_C_gto_dnam _19_O_gto_dnam +#define _1_C_lae_dnam _1_O_lae_dnam +#define _20_C_gto_dlb _20_O_gto_dlb +#define _21_C_ine_dnam _21_O_ine_dnam +#define _22_C_ine_dlb _22_O_ine_dlb +#define _23_C_rom_dnam _23_O_rom_dnam +#define _24_C_rom_dlb _24_O_rom_dlb +#define _25_C_ina_dnam _25_O_ina_dnam +#define _26_C_ina_dlb _26_O_ina_dlb +#define _27_C_rom_icon _27_O_rom_icon +#define _28_C_rom_ilb _28_O_rom_ilb +#define _29_C_ste_dnam _29_O_ste_dnam +#define _2_C_lae_dlb _2_O_lae_dlb +#define _30_C_ste_dlb _30_O_ste_dlb +#define _31_C_fil_dnam _31_O_fil_dnam +#define _32_C_fil_dlb _32_O_fil_dlb +#define _33_C_lde_dnam _33_O_lde_dnam +#define _34_C_lde_dlb _34_O_lde_dlb +#define _35_C_loe_dnam _35_O_loe_dnam +#define _36_C_loe_dlb _36_O_loe_dlb +#define _37_C_exa_dnam _37_O_exa_dnam +#define _38_C_exa_dlb _38_O_exa_dlb +#define _39_C_dee_dnam _39_O_dee_dnam +#define _3_C_sde_dnam _3_O_sde_dnam +#define _40_C_dee_dlb _40_O_dee_dlb +#define _4_C_sde_dlb _4_O_sde_dlb +#define _5_C_zre_dnam _5_O_zre_dnam +#define _6_C_zre_dlb _6_O_zre_dlb +#define _7_C_hol_dnam _7_O_hol_dnam +#define _8_C_hol_dlb _8_O_hol_dlb +#define _9_C_hol_icon _9_O_hol_icon diff --git a/modules/install b/modules/install new file mode 100755 index 00000000..7aa57e7b --- /dev/null +++ b/modules/install @@ -0,0 +1,33 @@ +case $# in +1) DEST="$1" + SRC=`basename $DEST` + ;; +2) DEST="$2" + SRC="$1" + ;; +*) echo 'Usage:' $0 [source] destination 1>&2 + exit 1 + ;; +esac +DIR=`expr "$DEST" ':' '\(.*\)/[^/]*' '|' "XXXX"` +case $DIR in +XXXX) echo 'Illegal desination argument:' "$DEST" + exit 1 + ;; +esac +mkdir ../../$DIR > /dev/null 2>&1 +chmod 775 ../../$DIR > /dev/null 2>&1 +if cp "$SRC" ../../$DEST >/dev/null 2>&1 || + { rm -f ../../$DEST >/dev/null 2>&1 && + cp "$SRC" ../../$DEST >/dev/null 2>&1 + } +then + if (ar t ../../$DEST | grep __.SYMDEF ) >/dev/null 2>&1 + then + ranlib ../../$DEST + fi + exit 0 +else + echo Sorry, can not create "$DEST". + exit 1 +fi diff --git a/modules/src/alloc/Makefile b/modules/src/alloc/Makefile new file mode 100644 index 00000000..5b5f3f98 --- /dev/null +++ b/modules/src/alloc/Makefile @@ -0,0 +1,63 @@ +EMHOME=../../.. +HDIR = $(EMHOME)/modules/h +INSTALL=$(EMHOME)/modules/install +COMPARE=$(EMHOME)/modules/compare +INCLUDES = -I. -I$(HDIR) +AR = ar +SUF = o +LIBSUF = a + +CFLAGS = -O $(INCLUDES) $(COPT) + +CSRC = Malloc.c\ + Salloc.c\ + Srealloc.c\ + Realloc.c\ + botch.c\ + clear.c\ + st_alloc.c\ + std_alloc.c \ + No_Mem.c +SOURCES = alloc.h\ + $(CSRC) + +OBJECTS = botch.$(SUF) clear.$(SUF) st_alloc.$(SUF) Malloc.$(SUF) \ + Salloc.$(SUF) \ + Srealloc.$(SUF) Realloc.$(SUF) std_alloc.$(SUF) No_Mem.$(SUF) + +.SUFFIXES: .$(SUF) +.c.$(SUF): + $(CC) -c $(CFLAGS) $*.c + +all: liballoc.$(LIBSUF) + +liballoc.$(LIBSUF): $(OBJECTS) + $(AR) cr liballoc.$(LIBSUF) $(OBJECTS) + -sh -c 'ranlib liballoc.$(LIBSUF)' + +install: all + $(INSTALL) lib/liballoc.$(LIBSUF) + $(INSTALL) man/alloc.3 + $(INSTALL) h/alloc.h + +cmp: all + -$(COMPARE) lib/liballoc.$(LIBSUF) + -$(COMPARE) man/alloc.3 + -$(COMPARE) h/alloc.h + +pr: + @pr Makefile $(SOURCES) + +opr: + make pr | opr + +clean: + rm -f *.$(SUF) *.$(LIBSUF) + +lintlib: + lint $(INCLUDES) -Calloc $(CSRC) + mv llib-lalloc.ln $(EMHOME)/modules/lib + +st_alloc.$(SUF): alloc.h +std_alloc.$(SUF): alloc.h +Malloc.$(SUF): alloc.h diff --git a/modules/src/alloc/in_all.h b/modules/src/alloc/in_all.h new file mode 100644 index 00000000..9b804e5a --- /dev/null +++ b/modules/src/alloc/in_all.h @@ -0,0 +1,12 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifdef DEBUG +#define PRIVATE +#else +#define PRIVATE static +#endif + +#define EXPORT diff --git a/modules/src/assert/Makefile b/modules/src/assert/Makefile new file mode 100644 index 00000000..714504a5 --- /dev/null +++ b/modules/src/assert/Makefile @@ -0,0 +1,43 @@ +EMHOME=../../.. +MODULES=$(EMHOME)/modules +HDIR = $(MODULES)/h +INCLUDES = -I$(HDIR) +CFLAGS = $(INCLUDES) -O $(COPT) +INSTALL = $(MODULES)/install +COMPARE = $(MODULES)/compare +AR = ar +SUF = o +LIBSUF = a + +.SUFFIXES: .$(SUF) +.c.$(SUF): + $(CC) -c $(CFLAGS) $*.c + +all: libassert.$(LIBSUF) + +libassert.$(LIBSUF): BadAssert.$(SUF) + $(AR) r libassert.$(LIBSUF) BadAssert.$(SUF) + -sh -c 'ranlib libassert.$(LIBSUF)' + +install: all + $(INSTALL) lib/libassert.$(LIBSUF) + $(INSTALL) man/assert.3 + $(INSTALL) h/assert.h + +cmp: all + -$(COMPARE) lib/libassert.$(LIBSUF) + -$(COMPARE) man/assert.3 + -$(COMPARE) h/assert.h + +pr: + @pr Makefile assert.h BadAssert.c + +opr: + make pr | opr + +clean: + rm -f *.$(LIBSUF) *.$(SUF) + +lintlib: + lint $(INCLUDES) -Cassert BadAssert.c + mv llib-lassert.ln $(MODULES)/lib diff --git a/modules/src/em_code/Makefile b/modules/src/em_code/Makefile new file mode 100644 index 00000000..c7d2df90 --- /dev/null +++ b/modules/src/em_code/Makefile @@ -0,0 +1,68 @@ +EMHOME = ../../.. +ETC = $(EMHOME)/etc +INSTALL = $(EMHOME)/modules/install +COMPARE = $(EMHOME)/modules/compare +CFLAGS = -I$(EMHOME)/h -I$(EMHOME)/modules/h -I$(EMHOME)/modules/src/read_em -I. -O $(COPT) +AR = ar +SUF = o +LIBSUF = a +SRC = bhcst.c bhdlb.c bhdnam.c bhfcon.c bhicon.c bhilb.c bhpnam.c bhucon.c \ + crcst.c crdlb.c crdnam.c crxcon.c crilb.c crpnam.c crscon.c \ + cst.c dfdlb.c dfdnam.c dfilb.c dlb.c dnam.c end.c endarg.c \ + exc.c fcon.c getid.c icon.c ilb.c insert.c internerr.c \ + msend.c op.c opcst.c opdlb.c opdnam.c opilb.c opnarg.c oppnam.c pnam.c \ + pro.c pronarg.c msstart.c psdlb.c psdnam.c pspnam.c scon.c ucon.c \ + C_out.c failed.c em.c + +OBS = failed.$(SUF) insert.$(SUF) internerr.$(SUF) getid.$(SUF) + +.SUFFIXES: .$(SUF) +.c.$(SUF): + $(CC) -c $(CFLAGS) $*.c + +all: em_codeEK.h libeme.$(LIBSUF) libemk.$(LIBSUF) em_code.3 + +install: all + $(INSTALL) lib/libeme.$(LIBSUF) + $(INSTALL) lib/libemk.$(LIBSUF) + $(INSTALL) man/em_code.3 + $(INSTALL) h/em_codeEK.h + +compare: all + -$(COMPARE) lib/libeme.$(LIBSUF) + -$(COMPARE) lib/libemk.$(LIBSUF) + -$(COMPARE) man/em_code.3 + -$(COMPARE) h/em_codeEK.h + +em_code.3: em_code.3X + -sh -c 'tbl < em_code.3X > em_code.3' + -sh -c 'if test -s em_code.3 ; then : ; else cp em_code.3X em_code.3 ; fi ' + +libeme.$(LIBSUF): em_private.h $(SRC) $(OBS) + EMHOME=$(EMHOME); cc="$(CC)"; suf="$(SUF)"; libsuf="$(LIBSUF)"; cflags="-c -DREADABLE_EM $(CFLAGS)"; ar="$(AR)"; export EMHOME cc ar suf libsuf cflags; sh make.sh e $(SRC) + -sh -c 'ranlib libeme.$(LIBSUF)' + +libemk.$(LIBSUF): em_private.h $(SRC) $(OBS) + EMHOME=$(EMHOME); cc="$(CC)"; suf="$(SUF)"; libsuf="$(LIBSUF)"; cflags="-c $(CFLAGS)"; ar="$(AR)"; export EMHOME cc ar suf libsuf cflags; sh make.sh k $(SRC) + -sh -c 'ranlib libemk.$(LIBSUF)' + +em_codeEK.h: make.em.gen $(ETC)/em_table em.nogen + make.em.gen $(ETC)/em_table > em_codeEK.h + cat em.nogen >> em_codeEK.h + +pr: + @pr Makefile em.nogen make.em.gen make.sh insert.h $(SRC) em_private.h + +opr: + make pr | opr + +clean: + rm -f *.$(SUF) *.$(LIBSUF) em_code.3 em_codeEK.h + +lintlib: make.sh + lint -I. -I../../h -I../../../h -Ceme -DREADABLE_EM $(SRC) + lint -I. -I../../h -I../../../h -Cemk $(SRC) + mv llib-leme.ln llib-lemk.ln $(EMHOME)/modules/lib + +insert.$(SUF): insert.c insert.h + $(CC) $(CFLAGS) -c insert.c diff --git a/modules/src/em_code/crfcon.c b/modules/src/em_code/crfcon.c new file mode 100644 index 00000000..189f92ae --- /dev/null +++ b/modules/src/em_code/crfcon.c @@ -0,0 +1,15 @@ +#include "em_private.h" + +/* $Header$ */ + +CC_crfcon(op, v, s) + char *v; + arith s; +{ + /* CON or ROM with argument FCON(v,z) + */ + PS(op); + WCON(sp_fcon, v, s); + CEND(); + NL(); +} diff --git a/modules/src/em_code/cricon.c b/modules/src/em_code/cricon.c new file mode 100644 index 00000000..d0518649 --- /dev/null +++ b/modules/src/em_code/cricon.c @@ -0,0 +1,15 @@ +#include "em_private.h" + +/* $Header$ */ + +CC_cricon(op, v, s) + char *v; + arith s; +{ + /* CON or ROM with argument ICON(v,z) + */ + PS(op); + WCON(sp_icon, v, s); + CEND(); + NL(); +} diff --git a/modules/src/em_code/crucon.c b/modules/src/em_code/crucon.c new file mode 100644 index 00000000..46b7a007 --- /dev/null +++ b/modules/src/em_code/crucon.c @@ -0,0 +1,15 @@ +#include "em_private.h" + +/* $Header$ */ + +CC_crucon(op, v, s) + char *v; + arith s; +{ + /* CON or ROM with argument UCON(v,z) + */ + PS(op); + WCON(sp_ucon, v, s); + CEND(); + NL(); +} diff --git a/modules/src/em_code/e/.distr b/modules/src/em_code/e/.distr new file mode 100644 index 00000000..66366f55 --- /dev/null +++ b/modules/src/em_code/e/.distr @@ -0,0 +1,2 @@ +em.c +em_private.h diff --git a/modules/src/em_code/e/C_failed.c b/modules/src/em_code/e/C_failed.c new file mode 100644 index 00000000..9b3cd21f --- /dev/null +++ b/modules/src/em_code/e/C_failed.c @@ -0,0 +1,12 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#include + +C_failed() +{ + sys_write(STDERR,"write failed\n",13); + sys_stop(S_EXIT); +} diff --git a/modules/src/em_code/e/em.c b/modules/src/em_code/e/em.c new file mode 100644 index 00000000..4c79fa88 --- /dev/null +++ b/modules/src/em_code/e/em.c @@ -0,0 +1,159 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* EM CODE OUTPUT ROUTINES */ + +#include "io.c" +#include "em_private.h" + +/* + The C_pt_*() functions serve as formatting functions of the + various EM language constructs. + See "Description of a Machine Architecture for use with + Block Structured Languages" par. 11.2 for the meaning of these + names. +*/ + +C_magic() +{ +} + +/*** the readable code generating routines ***/ + +static +wrs(s) + register char *s; +{ + while (*s) { + C_putbyte(*s++); + } +} + +C_pt_dnam(s) + char *s; +{ + wrs(s); +} + +C_pt_ilb(l) + label l; +{ + char buf[16]; + + sprint(buf, "*%ld", (long) l); + wrs(buf); +} + +extern char em_mnem[][4]; +extern char em_pseu[][4]; + +C_pt_op(x) +{ + C_putbyte(' '); + wrs(em_mnem[x - sp_fmnem]); + C_putbyte(' '); +} + +C_pt_cst(l) + arith l; +{ + char buf[16]; + + sprint(buf, "%ld", (long) l); + wrs(buf); +} + +C_pt_scon(x, y) + char *x; + arith y; +{ + char xbuf[1024]; + register char *p; + char *bts2str(); + + C_putbyte('\''); + p = bts2str(x, (int) y, xbuf); + while (*p) { + if (*p == '\'') { + C_putbyte('\\'); + } + C_putbyte(*p++); + } + C_putbyte('\''); +} + +C_pt_ps(x) +{ + C_putbyte(' '); + wrs(em_pseu[x - sp_fpseu]); + C_putbyte(' '); +} + +C_pt_dlb(l) + label l; +{ + char buf[16]; + + sprint(buf, ".%ld", (long) l); + wrs(buf); +} + +C_pt_doff(l, v) + label l; + arith v; +{ + char buf[16]; + + C_pt_dlb(l); + if (v != 0) { + sprint(buf,"+%ld", (long) v); + wrs(buf); + } +} + +C_pt_noff(s, v) + char *s; + arith v; +{ + char buf[16]; + + wrs(s); + if (v != 0) { + sprint(buf,"+%ld", (long) v); + wrs(buf); + } +} + +C_pt_pnam(s) + char *s; +{ + C_putbyte('$'); + wrs(s); +} + +C_pt_dfilb(l) + label l; +{ + char buf[16]; + + sprint(buf, "%ld", (long) l); + wrs(buf); +} + +C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */ + int sp; + char *v; + arith sz; +{ + int ch = sp == sp_icon ? 'I' : sp == sp_ucon ? 'U' : 'F'; + + wrs(v); + C_putbyte(ch); + C_pt_cst(sz); +} + +C_pt_nl() { C_putbyte('\n'); } +C_pt_comma() { C_putbyte(','); } +C_pt_ccend() { C_putbyte('?'); } diff --git a/modules/src/em_code/e/em_private.h b/modules/src/em_code/e/em_private.h new file mode 100644 index 00000000..7a89d673 --- /dev/null +++ b/modules/src/em_code/e/em_private.h @@ -0,0 +1,37 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* private inclusion file */ + +#include +#include + +/* include the EM description files */ +#include +#include +#include +#include + +/* macros used in the definitions of the interface functions C_* */ +#define OP(x) C_pt_op(x) +#define CST(x) C_pt_cst(x) +#define DCST(x) C_pt_cst(x) +#define SCON(x,y) C_pt_scon((x), (y)) +#define PS(x) C_pt_ps(x) +#define DLB(x) C_pt_dlb(x) +#define DFDLB(x) C_pt_dlb(x) +#define ILB(x) C_pt_ilb(x) +#define DFILB(x) C_pt_dfilb(x) +#define NOFF(x,y) C_pt_noff((x), (y)) +#define DOFF(x,y) C_pt_doff((x), (y)) +#define PNAM(x) C_pt_pnam(x) +#define DNAM(x) C_pt_dnam(x) +#define DFDNAM(x) C_pt_dnam(x) +#define CEND() +#define CCEND() C_pt_ccend() +#define WCON(x,y,z) C_pt_wcon((x), (y), (z)) +#define COMMA() C_pt_comma() +#define NL() C_pt_nl() +#define CILB(x) C_pt_ilb(x) diff --git a/modules/src/em_code/io.c b/modules/src/em_code/io.c new file mode 100644 index 00000000..8e59e570 --- /dev/null +++ b/modules/src/em_code/io.c @@ -0,0 +1,143 @@ +/* $Header$ */ + +/* I/O part of em_code module. + Also contains C_open, C_close +*/ +#include +#include +#include +#include "insert.h" + +int C_ontmpfile = 0; +int C_sequential = 1; +Part *C_curr_part; +Part *C_stable[TABSIZ]; +char *C_tmpdir = TMP_DIR; +int (*C_outpart)(), (*C_swtout)(), (*C_swttmp)(); + +#ifdef INCORE +char *C_BASE; +#endif + +File *C_ofp; + +#ifndef INCORE +File *C_tfr, *C_old_ofp; +char *C_tmpfile; +char *strcpy(), *strcat(); +char *C_ibuf = 0; +long C_current_out; +#endif + +#if BUFSIZ <= 1024 && BIGMACHINE +#define BUFFERSIZ 8*BUFSIZ +#else +#define BUFFERSIZ BUFSIZ +#endif + +static char obuf[BUFFERSIZ]; +char *C_top = &obuf[BUFFERSIZ]; +char *C_old_top; +char *C_old_opp; +#ifdef INCORE +char *C_current_out = obuf; +#else +char *C_opp = obuf; +#endif + +C_flush() { +#ifdef INCORE + static unsigned int bufsiz; + + if (C_ontmpfile) { + if (C_BASE == 0) { + C_BASE = Malloc(BUFFERSIZ); + bufsiz = BUFFERSIZ; + C_current_out = C_BASE; + } + else { + C_BASE = Srealloc(C_BASE, (bufsiz << 1)); + C_current_out = C_BASE + bufsiz; + bufsiz <<= 1; + } + C_top = C_BASE + bufsiz; + return; + } +#endif + if (C_opp != obuf && sys_write(C_ofp, obuf, C_opp - obuf) == 0) { + C_failed(); + } + C_opp = obuf; +} + +#ifndef INCORE +#define Xputbyte(c) if (C_ontmpfile) C_current_out++; put(c) +#else +#define Xputbyte(c) put(c) +#endif + +C_putbyte(c) + int c; +{ + Xputbyte(c); +} + +#define C_putbyte Xputbyte + +C_init(w, p) + arith w, p; +{ +} + +C_open(nm) + char *nm; +{ + /* Open file "nm" for output + */ + + if (nm == 0) + C_ofp = STDOUT; /* standard output */ + else + if (sys_open(nm, OP_WRITE, &C_ofp) == 0) + return 0; + return 1; +} + +C_close() +{ + /* Finish the code-generation. + */ + +#ifndef INCORE + C_flush(); + if (C_tmpfile) { + (*C_swttmp)(); + sys_close(C_ofp); +#else + if (C_BASE) { +#endif + if (C_curr_part) { + C_curr_part->p_parts->pp_end = C_current_out - C_BASE; + } + (*C_swtout)(); + if (! C_sequential) { + (*C_outpart)(0); + } +#ifndef INCORE + sys_close(C_tfr); + sys_remove(C_tmpfile); + if (C_ibuf) free(C_ibuf); +#else + free(C_BASE); +#endif + } + C_flush(); + if (C_ofp != STDOUT) + sys_close(C_ofp); + C_ofp = 0; +} + +C_busy() +{ + return C_ofp != 0; /* true if code is being generated */ +} diff --git a/modules/src/em_code/k/.distr b/modules/src/em_code/k/.distr new file mode 100644 index 00000000..66366f55 --- /dev/null +++ b/modules/src/em_code/k/.distr @@ -0,0 +1,2 @@ +em.c +em_private.h diff --git a/modules/src/em_code/k/C_failed.c b/modules/src/em_code/k/C_failed.c new file mode 100644 index 00000000..9b3cd21f --- /dev/null +++ b/modules/src/em_code/k/C_failed.c @@ -0,0 +1,12 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#include + +C_failed() +{ + sys_write(STDERR,"write failed\n",13); + sys_stop(S_EXIT); +} diff --git a/modules/src/em_code/k/em.c b/modules/src/em_code/k/em.c new file mode 100644 index 00000000..75260725 --- /dev/null +++ b/modules/src/em_code/k/em.c @@ -0,0 +1,151 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ +/* EM CODE OUTPUT ROUTINES */ + +#include "io.c" +#include "em_private.h" + +#define put8(x) C_putbyte(x) +#define put16(x) put8((int) x); put8((int) (x >> 8)) +#define put32(x) put16((int) x); put16((int) (x >> 16)) + +/* + The C_pt_*() functions serve as formatting functions of the + various EM language constructs. + See "Description of a Machine Architecture for use with + Block Structured Languages" par. 11.2 for the meaning of these + names. +*/ + +C_magic() +{ + put16(sp_magic); +} + +/*** the compact code generating routines ***/ +#define fit16i(x) ((x) >= (long)0xFFFF8000 && (x) <= (long)0x00007FFF) +#define fit8u(x) ((x) <= 0xFF) /* x is already unsigned */ + +C_pt_ilb(l) + register label l; +{ + if (fit8u(l)) { + put8(sp_ilb1); + put8(l); + } + else { + put8(sp_ilb2); + put16(l); + } +} + +C_pt_dlb(l) + register label l; +{ + if (fit8u(l)) { + put8(sp_dlb1); + put8(l); + } + else { + put8(sp_dlb2); + put16((int)l); + } +} + +C_pt_cst(l) + register arith l; +{ + if (l >= (arith) -sp_zcst0 && l < (arith) (sp_ncst0 - sp_zcst0)) { + /* we can convert 'l' to an int because its value + can be stored in a byte. + */ + put8((int)l + (sp_zcst0 + sp_fcst0)); + } + else + if (fit16i(l)) { /* the cast from long to int causes no trouble here */ + put8(sp_cst2); + put16((int) l); + } + else { + put8(sp_cst4); + put32(l); + } +} + +C_pt_doff(l, v) + label l; + arith v; +{ + if (v == 0) { + C_pt_dlb(l); + } + else { + put8(sp_doff); + C_pt_dlb(l); + C_pt_cst(v); + } +} + +C_pt_noff(s, v) + char *s; + arith v; +{ + if (v == 0) { + C_pt_dnam(s); + } + else { + put8(sp_doff); + C_pt_dnam(s); + C_pt_cst(v); + } +} + +C_pt_dnam(s) + char *s; +{ + put8(sp_dnam); + C_pt_str(s); +} + +C_pt_pnam(s) + char *s; +{ + put8(sp_pnam); + C_pt_str(s); +} + +C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */ + int sp; + char *v; + arith sz; +{ + /* how 'bout signextension int --> long ??? */ + put8(sp); + C_pt_cst(sz); + C_pt_str(v); +} + +C_pt_str(s) + register char *s; +{ + register int len; + + C_pt_cst((arith) (len = strlen(s))); + while (--len >= 0) { + put8(*s++); + } +} + +C_pt_scon(b, n) + register char *b; + register arith n; +{ + put8(sp_scon); + C_pt_cst(n); + while (--n >= 0) { + put8(*b++); + } +} diff --git a/modules/src/em_code/k/em_private.h b/modules/src/em_code/k/em_private.h new file mode 100644 index 00000000..9ac1da39 --- /dev/null +++ b/modules/src/em_code/k/em_private.h @@ -0,0 +1,41 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* private inclusion file */ + +#include +#include + +/* include the EM description files */ +#include +#include +#include +#include + +/* macros used in the definitions of the interface functions C_* */ +#define OP(x) C_pt_op(x) +#define CST(x) C_pt_cst(x) +#define DCST(x) C_pt_cst(x) +#define SCON(x,y) C_pt_scon((x), (y)) +#define PS(x) C_pt_ps(x) +#define DLB(x) C_pt_dlb(x) +#define DFDLB(x) C_pt_dlb(x) +#define ILB(x) C_pt_ilb(x) +#define DFILB(x) C_pt_ilb(x) +#define NOFF(x,y) C_pt_noff((x), (y)) +#define DOFF(x,y) C_pt_doff((x), (y)) +#define PNAM(x) C_pt_pnam(x) +#define DNAM(x) C_pt_dnam(x) +#define DFDNAM(x) C_pt_dnam(x) +#define CEND() C_pt_cend() +#define CCEND() C_pt_cend() +#define WCON(x,y,z) C_pt_wcon((x), (y), (z)) +#define COMMA() +#define NL() +#define CILB(x) CST((arith) x) + +#define C_pt_cend() C_putbyte(sp_cend) +#define C_pt_op(x) C_putbyte(x) +#define C_pt_ps(x) C_putbyte(x) diff --git a/modules/src/em_code/make.fun b/modules/src/em_code/make.fun new file mode 100755 index 00000000..9885b9b5 --- /dev/null +++ b/modules/src/em_code/make.fun @@ -0,0 +1,52 @@ +TMP=tmp$$ +cat $* >$TMP +ed - $TMP <<'--EOI--' +g/^%/d +g/^$/d +g/^ /.-1,.j +1,$s/[ ]*|[ ]*/|/g +g/NOTIMPLEMENTED/d +1,$s/\([^|]*\)|\([^|]*\)|\(.*\)$/\ +NAME \1\ +HEAD \1\ +PLST \2\ +DECL \2\ +BODY \3/ +$a +END +. +g/^NAME/m$ +g/^PLST/s/[ ][ ]*\([^:]*\):\([^ ]*\)/,\2/g +g/^PLST,/s//PLST / +g/^PLST /s/^PLST \(.*\)$/(\1)/ +g/^HEAD/.,.+1j +g/^HEAD /s/^HEAD \([^(]*\)\(.*\)$/cat >\1.c <<'--EOF--'\ +#include "em_private.h"\ +\ +\1\2/ +g/^DECL/s/[ ][ ]*\([^:]*\):\([^ ]*\)/\ + \1 \2;/g +g/^DECL/d +g/^BODY/s/^BODY \(.*\)$/{\ + \1;\ +}\ +--EOF--/ +1,/^END/-1p +1,/^END/d +g:^NAME:s:^NAME \(.*\)$:cc -c -O -I$1 -I$EMHOME/modules/h -I$EMHOME/h \1.c: +1i +cat >make.sh <<'--EOF--' +: script for making lib +rm -f C_*.o +. +$a +rm -f libem$1.a +cc -c -O -I. -I$1 -I$EMHOME/modules/h -I$EMHOME/h $1/em.c +mv em.o em$1.o +ar rc libem$1.a C_*.o em$1.o insert.o failed.o internerr.o getid.o +rm -f C_*.o +--EOF-- +. +1,$p +--EOI-- +rm -f $TMP diff --git a/modules/src/em_mes/C_ms_lin.c b/modules/src/em_mes/C_ms_lin.c new file mode 100644 index 00000000..1cc59fdf --- /dev/null +++ b/modules/src/em_mes/C_ms_lin.c @@ -0,0 +1,15 @@ +/* $Header$ */ +/* + * (c) copyright 1990 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#include +#include + +C_ms_lin(l) + int l; +{ + C_mes_begin(ms_lin); + C_cst((arith) l); + C_mes_end(); +} diff --git a/modules/src/em_mes/Makefile b/modules/src/em_mes/Makefile new file mode 100644 index 00000000..40649005 --- /dev/null +++ b/modules/src/em_mes/Makefile @@ -0,0 +1,65 @@ +EMHOME = ../../.. +HDIR = $(EMHOME)/modules/h +INSTALL = $(EMHOME)/modules/install +COMPARE = $(EMHOME)/modules/compare +INCLUDES=-I$(EMHOME)/h -I$(HDIR) +CFLAGS = $(INCLUDES) -O $(COPT) +AR = ar +SUF = o +LIBSUF = a + +SRC = C_ms_err.c C_ms_opt.c C_ms_emx.c C_ms_reg.c C_ms_src.c\ + C_ms_flt.c C_ms_com.c C_ms_par.c C_ms_ego.c C_ms_gto.c\ + C_ms_stb.c C_ms_std.c +OBJ = C_ms_err.$(SUF) C_ms_opt.$(SUF) C_ms_emx.$(SUF) C_ms_reg.$(SUF) C_ms_src.$(SUF)\ + C_ms_flt.$(SUF) C_ms_com.$(SUF) C_ms_par.$(SUF) C_ms_ego.$(SUF) C_ms_gto.$(SUF)\ + C_ms_stb.$(SUF) C_ms_std.$(SUF) + +.SUFFIXES: .$(SUF) +.c.$(SUF): + $(CC) -c $(CFLAGS) $*.c + +all: libem_mes.$(LIBSUF) libem_mesCE.$(LIBSUF) libem_mesO.$(LIBSUF) +libem_mes.$(LIBSUF): $(OBJ) + rm -f libem_mes.$(LIBSUF) + $(AR) cr libem_mes.$(LIBSUF) $(OBJ) + -sh -c 'ranlib libem_mes.$(LIBSUF)' + +libem_mesO.$(LIBSUF): + rm -f *.$(SUF) libem_mesO.$(LIBSUF) + $(CC) -c $(CFLAGS) -DPEEPHOLE $(SRC) + $(AR) cr libem_mesO.$(LIBSUF) $(OBJ) + -sh -c 'ranlib libem_mesO.$(LIBSUF)' + rm -f *.$(SUF) + +libem_mesCE.$(LIBSUF): + rm -f *.$(SUF) libem_mesCE.$(LIBSUF) + $(CC) -c $(CFLAGS) -DCODE_EXPANDER $(SRC) + $(AR) cr libem_mesCE.$(LIBSUF) $(OBJ) + -sh -c 'ranlib libem_mesCE.$(LIBSUF)' + rm -f *.$(SUF) + +install: all + $(INSTALL) lib/libem_mes.$(LIBSUF) + $(INSTALL) lib/libem_mesO.$(LIBSUF) + $(INSTALL) lib/libem_mesCE.$(LIBSUF) + $(INSTALL) man/em_mes.3 + +cmp: all + -$(COMPARE) lib/libem_mes.$(LIBSUF) + -$(COMPARE) lib/libem_mesO.$(LIBSUF) + -$(COMPARE) lib/libem_mesCE.$(LIBSUF) + -$(COMPARE) man/em_mes.3 + +pr: + @pr Makefile $(SRC) + +opr: + make pr | opr + +clean: + rm -f *.$(SUF) *.$(LIBSUF) + +lintlib: + lint $(INCLUDES) -Cem_mes $(SRC) + mv llib-lem_mes.ln $(EMHOME)/modules/lib diff --git a/modules/src/em_opt/Makefile b/modules/src/em_opt/Makefile new file mode 100644 index 00000000..0a8d5f38 --- /dev/null +++ b/modules/src/em_opt/Makefile @@ -0,0 +1,180 @@ +# $Header$ +EMHOME = ../../.. +INSTALL = $(EMHOME)/modules/install +COMPARE = $(EMHOME)/modules/compare +LINT = lint +BINDIR = $(EMHOME)/lib + +# set HOWMUCH to head -20 to limit number of patterns used +#HOWMUCH = head -20 +HOWMUCH = cat + +LEXLIB = -ll +INCLDIR = -I$(EMHOME)/h -I$(EMHOME)/modules/h -I$(EMHOME)/modules/pkg +PREFLAGS = $(INCLDIR) -DPRIVATE=static# -DDEBUG + +# Enable the next line to produce a version that output's the line number +# from the patterns file each time an optimization is performed. +#PREFLAGS = $(PREFLAGS) -DSTATS + +PROFFLAG = -O +CFLAGS = $(PREFLAGS) $(PROFFLAG) $(COPT) +LINTFLAGS = $(PREFLAGS) -DNORCSID +LLOPT = +CMD = '$(CC) -c $(CFLAGS)' +AR = ar +SUF = o +LIBSUF = a + +LIBOPT = libemopt.$(LIBSUF) +LIBCEOPT = libCEopt.$(LIBSUF) + +.SUFFIXES: .d .r + +.r.d: ; CMD=$(CMD); export CMD; awk -f makefuns.awk $*.r | sh -x + touch $@ + +.SUFFIXES: .$(SUF) +.c.$(SUF): + $(CC) -c $(CFLAGS) $*.c + +CSRC = main.c nopt.c mkstrct.c aux.c outputdfa.c outcalls.c\ + findworst.c initlex.c + +SRCS = Makefile nopt.h parser.h parser.g syntax.l pseudo.r\ + patterns $(CSRC) + +NOFILES = nopt.$(SUF) dfa.$(SUF) trans.$(SUF) aux.$(SUF) mkstrct.$(SUF) + +POFILES = parser.$(SUF) syntax.$(SUF) outputdfa.$(SUF) outcalls.$(SUF) findworst.$(SUF)\ + initlex.$(SUF) Lpars.$(SUF) + +GENFILES = Lpars.h Lpars.c parserdummy parser.c syntax.c \ + dfa.c dfa.c.new trans.c trans.c.new\ + incalls.d incalls.r incalls.r.new pseudo.d + +all: em_nopt $(LIBOPT) $(LIBCEOPT) em_opt.3 + +install: all + $(INSTALL) lib/$(LIBOPT) + $(INSTALL) lib/$(LIBCEOPT) + $(INSTALL) man/em_opt.3 + cp em_nopt.6 $(EMHOME)/man + cp em_nopt $(BINDIR)/em_nopt + +cmp: all + -$(COMPARE) lib/$(LIBOPT) + -$(COMPARE) lib/$(LIBCEOPT) + -$(COMPARE) man/em_opt.3 + -cmp em_nopt $(BINDIR)/em_nopt + +pr: + @pr $(SRCS) + +opr: + make pr | opr + +lint: lintparser lintnopt + +clean: + rm -f O_*.$(SUF) + rm -f O_*.c + rm -f $(NOFILES) main.$(SUF) $(POFILES) + rm -f $(GENFILES) parser em_nopt $(LIBOPT) $(LIBCEOPT) + +# How to build stand alone version of the optimizer + +NOPTLIB = $(EMHOME)/modules/lib/libread_emk.$(LIBSUF)\ + $(EMHOME)/modules/lib/libemk.$(LIBSUF)\ + $(EMHOME)/modules/lib/liballoc.$(LIBSUF)\ + $(EMHOME)/modules/lib/malloc.$(SUF)\ + $(EMHOME)/modules/lib/libprint.$(LIBSUF)\ + $(EMHOME)/modules/lib/libstring.$(LIBSUF)\ + $(EMHOME)/modules/lib/libsystem.$(LIBSUF)\ + $(EMHOME)/lib/em_data.$(LIBSUF) + +em_nopt: incalls.r main.$(SUF) $(NOFILES) + $(CC) -o em_nopt main.$(SUF) $(NOFILES) $(NOPTLIB) + +OLINT = main.c mkstrct.c nopt.c aux.c dfa.c trans.c + +OLINTLIB = $(EMHOME)/modules/lib/llib-lread_emkV.ln\ + $(EMHOME)/modules/lib/llib-lemk.ln\ + $(EMHOME)/modules/lib/llib-lsystem.ln\ + $(EMHOME)/modules/lib/llib-lalloc.ln\ + $(EMHOME)/modules/lib/llib-lprint.ln\ + $(EMHOME)/modules/lib/llib-lstring.ln + +lintnopt: incalls.r $(OLINT) + $(LINT) $(LINTFLAGS) $(OLINT) $(OLINTLIB) + +# How to build the library version of the optimizer + +$(LIBOPT): $(NOFILES) pseudo.d incalls.d + rm -f $(LIBOPT) + ar rc $(LIBOPT) O_*.$(SUF) $(NOFILES) + -sh -c 'ranlib $(LIBOPT)' + +$(LIBCEOPT): incalls.r + rm -f O_*.$(SUF) $(NOFILES) pseudo.d incalls.d + -mv $(LIBOPT) $(LIBOPT).saved + make "EMHOME="$(EMHOME) PREFLAGS='$(INCLDIR) -DPRIVATE=static -DCODE_EXPANDER' $(LIBOPT) + mv $(LIBOPT) $(LIBCEOPT) + -mv $(LIBOPT).saved $(LIBOPT) + rm -f O_*.$(SUF) $(NOFILES) + +incalls.r: patterns parser + -$(EMHOME)/lib/cpp patterns | $(HOWMUCH) >/tmp/patts + parser =' + | '>' + ; +.R +.DE +If the rel_op is missing, the equality +.I == +operator is assumed. The general form of expression is defined later but +basically it involves simple constants, references to EM_mnem arguments +that appear earlier in the pattern and expressions similar to those used +in C expressions. + +The form of the restriction after those EM instructions like +.I adi +whose arguments are optional takes the form: +.DS +.I + opt_arg_restriction : normal_restriction + | 'defined' + | 'undefined' + ; +.R +.DE +The +.I defined +and +.I undefined +indicate that the argument is present +or absent respectively. The normal restriction form implies that the +argument is present and satisfies the restriction. + +The form of the restriction after those EM instructions like +.I lae +whose arguments refer to external object take the form: +.DS +.I + ext_arg_restriction : patarg offset_part? + ; + offset_part : [ '+' | '-' ] expression + ; +.R +.DE +Such an argument has one of three forms: a offset with no name, an +offset form a name or an offset from a label. With no offset part +the restriction requires the argument to be identical to a previous +external argument. With an offset part it requires an identical name +part, (either empty, same name or same label) and supplies a relationship +among the offset parts. It is possible to refer to test for the same +external argument, the same name or to obtain the offset part of an external +argument using the +.I sameext +, +.I samenam +and +.I offset +functions given below. +.LP +The general form of an expression is: +.DS +.I + expression : expression binop expression + | unaryop expression + | '(' expression ')' + | bin_function '(' expression ',' expression ')' + | ext_function '(' patarg ',' patarg ')' + | 'offset' '(' patarg ')' + | patarg + | 'p' + | 'w' + | INTEGER + ; +.R +.DE +.DS +.I + bin_function : 'sfit' + | 'ufit' + | 'samesign' + | 'rotate' + ; +.R +.DE +.DS +.I + ext_function : 'samenam' + | 'sameext' + ; + patarg : '$' INTEGER + ; + binop : "As for C language" + unaryop : "As for C language" +.R +.DE +The INTEGER in the +.I patarg +refers to the first, second, etc. argument in the pattern and it is +required to refer to a pattern that appears earlier in the pattern +The +.I w +and +.I p +refer to the word size and pointer size (in bytes) respectively. The +various function test for: +.IP sfit 10 +the first argument fits as a signed value of +the number of bit specified by the second argument. +.IP ufit 10 +as for sfit but for unsigned values. +.IP samesign 10 +the first argument has the same sign as the second. +.IP rotate 10 +the value of the first argument rotated by the number of bit specified +by the second argument. +.IP samenam 10 +both arguments refer to externals and have either no name, the same name +or same label. +.IP sameext 10 +both arguments refer to the same external. +.IP offset 10 +the argument is an external and this yields it offset part. + +.LP +The global restriction takes the form: +.DS +.I + global_restriction : '?' expression + ; +.R +.DE +and is used to express restrictions that cannot be expressed as simple +restrictions on a single argument or are can be expressed in a more +readable fashion as a global restriction. An example of such a rule is: +.DS +.I + dup w ldl stf ? p==2*w : ldl $2 stf $3 ldl $2 lof $3 +.R +.DE +which says that this rule only applies if the pointer size is twice the +word size. + +.NH +Incompatibilities with Previous Optimizer +.LP +The current table format is not compatible with previous versions of the +peephole optimizer tables. In particular the previous table had no provision +for local restrictions and only the equivalent of the global restriction. +This meant that our +.I '?' +character that announces the presence of the optional global restriction was +not required. The previous optimizer performed a number of other tasks that +were unrelated to optimization that were possible because the old optimizer +read the EM code for a complete procedure at a time. This included task such +as register variable reference counting and moving the information regarding +the number of bytes of local storage required by a procedure from it +.I end +pseudo instruction to it's +.I pro +pseudo instruction. These tasks are no longer done. If there are required +then the must be performed by some other program in the pipeline. + +.NH +The Parser +.LP +The program to parse the tables and build the pattern table dependent dfa +routines is built from the files: +.IP parser.h 15 +header file +.IP parser.g 15 +LLGen source file defining syntax of table +.IP syntax.l 15 +Lex sources file defining form of tokens in table. +.IP initlex.c 15 +Uses the data in the library +.I em_data.a +to initialize the lexical analyser to recognize EM instruction mnemonics. +.IP outputdfa.c 15 +Routines to output dfa when it has been constructed. +.IP outcalls.c 15 +Routines to output the file +.I incalls.c +defined in section 4. +.IP findworst.c 15 +Routines to analyze patterns to find how to continue matching after a +successful replacement or failed match. + +.LP +The parser checks that the tables conform to the syntax outlined in the +previous section and also mades a number of semantic checks on their +validity. Further versions could make further checks such as looking for +cycles in the rules or checking that each replacement leaves the same +number of bytes on the stack as the pattern it replaces. The parser +builds an internal dfa representation of the rules by combining rules with +common prefixes. All local and global restrictions are combined into a single +test to be performed are a complete pattern has been detected in the input. +The idea is to build a structure so that each of the patterns can be matched +and then the corresponding tests made and the first that succeeds is replaced. +If two rules have the same pattern and both their tests also succeed the one +that appears first in the tables file will be done. Somewhat less obvious +is that id one pattern is a proper prefix of a longer pattern and its test +succeeds then the second pattern will not be checked for. + +A major task of the parser if to decide on the action to take when a rule has +been partially matched or when a pattern has been completely matched but its +test does not succeed. This requires a search of all patterns to see if any +part of the part matched could be part of some other pattern. for example +given the two patterns: +.DS +.I + loc adi w loc adi w : loc $1+$3 adi w + loc adi w loc sbi w : loc $1-$3 adi w +.R +.DE +If the first pattern fails after seeing the input: +.DS +.I + loc adi loc +.R +.DE +the parser will still need to check whether the second pattern matches. +This requires a decision on how to fix up any internal data structures in +the dfa matcher, such as moving some instructions from the pattern to the +output queue and moving the pattern along and then deciding what state +it should continue from. Similar decisions are requires after a pattern +has been replaced. For example if the replacement is empty it is necessary +to backup +.I n-1 +instructions where +.I n +is the length of the longest pattern in the tables. + +.NH +Structure of the Resulting Library + +.LP +The major data structures maintained by the library consist of three queues; +an +.I output +queue of instructions awaiting output, a +.I pattern +queue containing instructions that match the current prefix, and a +.I backup +queue of instructions that have been backed up over and need to be reparsed +for further pattern matches. + +.LP +If no errors are detected by the parser in the tables it output the following +files: +.IP dfa.c 10 +this consists of a large switch statement that maintains the current state of +the dfa and makes a transition to the next state if the next input instruction +matches. +.IP incalls.r 10 +this contains an entry for every EM instruction (plus +.I lab +) giving information on how to build a routine with the name +.I C_xxx +that conforms to the +.I EM_CODE(3) +modules interface. If the EM instruction does not appear in the tables +patterns at all then the dfa routine is called to flush any current queued +output and the the output +.I O_xxx +routine is called. If the EM instruction does appear in a pattern then the instruction is added onto the end of the pattern queue and the dfa routines called +to attempted to make a transition. This file is input to the +.I awk +program +.I makefuns.awk +to produce individual C files with names like +.I C_xxx.c +each containing a single function definition. This enables the loader to +only load those routines that are actually needed when the library is loaded. +.IP trans.c 10 +this contains a routine that is called after each transition to a state that +contains restrictions and replacements. The restrictions a converted to +C expressions and the replacements coded as calls to output instructions +into the output queue. + +.LP +The following files contain code that is independent of the pattern tables: +.IP nopt.c 10 +general routines to initialize, and maintain the data structures. +.IP aux.c 10 +routines to implement the functions used in the rules. +.IP mkcalls.c 10 +code to convert the internal data structures to calls on the output +.I O_xxx +routines when the output queue is flushed. + +.NH +Miscellaneous Issues +.LP +The size of the output and backup queues are fixed in size according to the +values of +.I MAXOUTPUT +and +.I MAXBACKUP +defined in the file +.I nopt.h. +The size of the pattern queue is set to the length of the maximum pattern +length by the tables output by the parser. The queues are implemented as +arrays of pointers to structures containing the instruction and its arguments. +The space for the structures are initially obtained by calls to +.I Malloc +(from the +.I alloc(3) +module), +and freed when the output queue or patterns queue is cleared. These freed +structures are collected on a free list and reused to avoid the overheads +of repeated calls to +.I malloc +and +.I free. + +.LP +The fixed size of the output and pattern queues causes no difficulty in +practice and can only result in some potential optimizations being missed. +When the output queue fills it is simply prematurely flushed and backups +when the backup queue is fill are simply ignored. A possible improvement +would be to flush only part of the output queue when it fills. It should +be noted that it is not possible to statically determine the maximum possible +size for these queues as they need to be unbounded in the worst case. A +study of the rule +.DS +.I + inc dec : +.R +.DE +with the input consisting of +.I N +.I inc +and then +.I N +.I dec +instructions requires an output queue length of +.I N-1 +to find all possible replacements. diff --git a/modules/src/em_opt/mkcalls.c b/modules/src/em_opt/mkcalls.c new file mode 100644 index 00000000..69c70a60 --- /dev/null +++ b/modules/src/em_opt/mkcalls.c @@ -0,0 +1,303 @@ +#ifndef NORCSID +static char rcsid[] = "$Header$"; +#endif + +#include "nopt.h" + +static Linenumber = 0; /* Local optimization of lin to lni if possible */ + +OO_mkcalls(p) + struct instr *p; +{ + switch(p->opcode) { + case op_aar: + O_aar(p->acst); break; + case op_adf: + O_adf(p->acst); break; + case op_adi: + O_adi(p->acst); break; + case op_adp: + O_adp(p->acst); break; + case op_ads: + O_ads(p->acst); break; + case op_adu: + O_adu(p->acst); break; + case op_and: + O_and(p->acst); break; + case op_asp: + O_asp(p->acst); break; + case op_ass: + O_ass(p->acst); break; + case op_beq: + O_beq((label)p->acst); break; + case op_bge: + O_bge((label)p->acst); break; + case op_bgt: + O_bgt((label)p->acst); break; + case op_ble: + O_ble((label)p->acst); break; + case op_blm: + O_blm(p->acst); break; + case op_bls: + O_bls(p->acst); break; + case op_blt: + O_blt((label)p->acst); break; + case op_bne: + O_bne((label)p->acst); break; + case op_bra: + O_bra((label)p->acst); break; + case op_cai: + O_cai(); break; + case op_cal: + O_cal(p->apnam); break; + case op_cff: + O_cff(); break; + case op_cfi: + O_cfi(); break; + case op_cfu: + O_cfu(); break; + case op_cif: + O_cif(); break; + case op_cii: + O_cii(); break; + case op_ciu: + O_ciu(); break; + case op_cmf: + O_cmf(p->acst); break; + case op_cmi: + O_cmi(p->acst); break; + case op_cmp: + O_cmp(); break; + case op_cms: + O_cms(p->acst); break; + case op_cmu: + O_cmu(p->acst); break; + case op_com: + O_com(p->acst); break; + case op_csa: + O_csa(p->acst); break; + case op_csb: + O_csb(p->acst); break; + case op_cuf: + O_cuf(); break; + case op_cui: + O_cui(); break; + case op_cuu: + O_cuu(); break; + case op_dch: + O_dch(); break; + case op_dec: + O_dec(); break; + case op_dee: + if(p->argtype==nof_ptyp) O_dee_dlb(p->adlb, p->anoff); + else O_dee_dnam(p->adnam, p->asoff); break; + case op_del: + O_del(p->acst); break; + case op_dup: + O_dup(p->acst); break; + case op_dus: + O_dus(p->acst); break; + case op_dvf: + O_dvf(p->acst); break; + case op_dvi: + O_dvi(p->acst); break; + case op_dvu: + O_dvu(p->acst); break; + case op_exg: + O_exg(p->acst); break; + case op_fef: + O_fef(p->acst); break; + case op_fif: + O_fif(p->acst); break; + case op_fil: + Linenumber = 0; + if(p->argtype==nof_ptyp) O_fil_dlb(p->adlb, p->anoff); + else O_fil_dnam(p->adnam, p->asoff); break; + case op_gto: + if(p->argtype==nof_ptyp) O_gto_dlb(p->adlb, p->anoff); + else O_gto_dnam(p->adnam, p->asoff); break; + case op_inc: + O_inc(); break; + case op_ine: + if(p->argtype==nof_ptyp) O_ine_dlb(p->adlb, p->anoff); + else O_ine_dnam(p->adnam, p->asoff); break; + case op_inl: + O_inl(p->acst); break; + case op_inn: + O_inn(p->acst); break; + case op_ior: + O_ior(p->acst); break; + case op_lab: + Linenumber = 0; + O_df_ilb(p->alab); break; + case op_lae: + if(p->argtype==nof_ptyp) O_lae_dlb(p->adlb, p->anoff); + else O_lae_dnam(p->adnam, p->asoff); break; + case op_lal: + O_lal(p->acst); break; + case op_lar: + O_lar(p->acst); break; + case op_ldc: + O_ldc(p->acst); break; + case op_lde: + if(p->argtype==nof_ptyp) O_lde_dlb(p->adlb, p->anoff); + else O_lde_dnam(p->adnam, p->asoff); break; + case op_ldf: + O_ldf(p->acst); break; + case op_ldl: + O_ldl(p->acst); break; + case op_lfr: + O_lfr(p->acst); break; + case op_lil: + O_lil(p->acst); break; + case op_lim: + O_lim(); break; + case op_lin: + if(Linenumber && p->acst == ++Linenumber) { + O_lni(); + } + else { + O_lin(p->acst); + Linenumber = p->acst; + } + break; + case op_lni: + O_lni(); + Linenumber++; + break; + case op_loc: + O_loc(p->acst); break; + case op_loe: + if(p->argtype==nof_ptyp) O_loe_dlb(p->adlb, p->anoff); + else O_loe_dnam(p->adnam, p->asoff); break; + case op_lof: + O_lof(p->acst); break; + case op_loi: + O_loi(p->acst); break; + case op_lol: + O_lol(p->acst); break; + case op_lor: + O_lor(p->acst); break; + case op_los: + O_los(p->acst); break; + case op_lpb: + O_lpb(); break; + case op_lpi: + O_lpi(p->apnam); break; + case op_lxa: + O_lxa(p->acst); break; + case op_lxl: + O_lxl(p->acst); break; + case op_mlf: + O_mlf(p->acst); break; + case op_mli: + O_mli(p->acst); break; + case op_mlu: + O_mlu(p->acst); break; + case op_mon: + O_mon(); break; + case op_ngf: + O_ngf(p->acst); break; + case op_ngi: + O_ngi(p->acst); break; + case op_nop: + O_nop(); break; + case op_rck: + O_rck(p->acst); break; + case op_ret: + O_ret(p->acst); break; + case op_rmi: + O_rmi(p->acst); break; + case op_rmu: + O_rmu(p->acst); break; + case op_rol: + O_rol(p->acst); break; + case op_ror: + O_ror(p->acst); break; + case op_rtt: + O_rtt(); break; + case op_sar: + O_sar(p->acst); break; + case op_sbf: + O_sbf(p->acst); break; + case op_sbi: + O_sbi(p->acst); break; + case op_sbs: + O_sbs(p->acst); break; + case op_sbu: + O_sbu(p->acst); break; + case op_sde: + if(p->argtype==nof_ptyp) O_sde_dlb(p->adlb, p->anoff); + else O_sde_dnam(p->adnam, p->asoff); break; + case op_sdf: + O_sdf(p->acst); break; + case op_sdl: + O_sdl(p->acst); break; + case op_set: + O_set(p->acst); break; + case op_sig: + O_sig(); break; + case op_sil: + O_sil(p->acst); break; + case op_sim: + O_sim(); break; + case op_sli: + O_sli(p->acst); break; + case op_slu: + O_slu(p->acst); break; + case op_sri: + O_sri(p->acst); break; + case op_sru: + O_sru(p->acst); break; + case op_ste: + if(p->argtype==nof_ptyp) O_ste_dlb(p->adlb, p->anoff); + else O_ste_dnam(p->adnam, p->asoff); break; + case op_stf: + O_stf(p->acst); break; + case op_sti: + O_sti(p->acst); break; + case op_stl: + O_stl(p->acst); break; + case op_str: + O_str(p->acst); break; + case op_sts: + O_sts(p->acst); break; + case op_teq: + O_teq(); break; + case op_tge: + O_tge(); break; + case op_tgt: + O_tgt(); break; + case op_tle: + O_tle(); break; + case op_tlt: + O_tlt(); break; + case op_tne: + O_tne(); break; + case op_trp: + O_trp(); break; + case op_xor: + O_xor(p->acst); break; + case op_zeq: + O_zeq((label)p->acst); break; + case op_zer: + O_zer(p->acst); break; + case op_zge: + O_zge((label)p->acst); break; + case op_zgt: + O_zgt((label)p->acst); break; + case op_zle: + O_zle((label)p->acst); break; + case op_zlt: + O_zlt((label)p->acst); break; + case op_zne: + O_zne((label)p->acst); break; + case op_zre: + if(p->argtype==nof_ptyp) O_zre_dlb(p->adlb, p->anoff); + else O_zre_dnam(p->adnam, p->asoff); break; + case op_zrf: + O_zrf(p->acst); break; + case op_zrl: + O_zrl(p->acst); break; + } +} diff --git a/modules/src/flt_arith/Makefile b/modules/src/flt_arith/Makefile new file mode 100644 index 00000000..b76f9d96 --- /dev/null +++ b/modules/src/flt_arith/Makefile @@ -0,0 +1,75 @@ +# $Header$ +EMHOME = ../../.. +MODDIR=$(EMHOME)/modules +INSTALL = $(MODDIR)/install +COMPARE = $(MODDIR)/compare +INCLUDES = -I. -I$(MODDIR)/h +CFLAGS = -O $(INCLUDES) $(COPT) +AR = ar +SUF = o +LIBSUF = a + +LIBFLT = libflt.$(LIBSUF) + +SRC = flt_ar2flt.c flt_div.c flt_flt2ar.c flt_modf.c flt_str2fl.c \ + flt_cmp.c flt_add.c b64_add.c flt_mul.c flt_nrm.c b64_sft.c \ + flt_umin.c flt_chk.c split.c ucmp.c + +OBJ = flt_ar2flt.$(SUF) flt_div.$(SUF) flt_flt2ar.$(SUF) flt_modf.$(SUF) \ + flt_str2fl.$(SUF) flt_cmp.$(SUF) flt_add.$(SUF) b64_add.$(SUF) \ + flt_mul.$(SUF) flt_nrm.$(SUF) b64_sft.$(SUF) flt_umin.$(SUF) \ + flt_chk.$(SUF) split.$(SUF) ucmp.$(SUF) + +.SUFFIXES: .$(SUF) +.c.$(SUF): + $(CC) -c $(CFLAGS) $*.c + +all: $(LIBFLT) + +test: $(LIBFLT) test.o + $(CC) -o tst test.o $(LIBFLT) + ./tst + +$(LIBFLT): $(OBJ) + rm -f $(LIBFLT) + $(AR) r $(LIBFLT) $(OBJ) + -sh -c 'ranlib $(LIBFLT)' + +install: all + $(INSTALL) lib/$(LIBFLT) + $(INSTALL) h/flt_arith.h + $(INSTALL) man/flt_arith.3 + +cmp: all + -$(COMPARE) lib/$(LIBFLT) + -$(COMPARE) h/flt_arith.h + -$(COMPARE) man/flt_arith.3 + +pr: + @pr Makefile $(SRC) + +opr: + make pr | opr + +clean: + rm -f *.$(SUF) $(LIBFLT) + +lintlib: + lint $(INCLUDES) -Cflt $(SRC) + mv llib-lflt.ln $(MODDIR)/lib + +b64_add.$(SUF): flt_misc.h flt_arith.h +flt_ar2flt.$(SUF): flt_misc.h flt_arith.h +flt_div.$(SUF): flt_misc.h flt_arith.h +flt_nrm.$(SUF): flt_misc.h flt_arith.h +b64_sft.$(SUF): flt_misc.h flt_arith.h +flt_chk.$(SUF): flt_misc.h flt_arith.h +flt_flt2ar.$(SUF): flt_misc.h flt_arith.h +flt_str2fl.$(SUF): flt_misc.h flt_arith.h +flt_add.$(SUF): flt_misc.h flt_arith.h +flt_cmp.$(SUF): flt_misc.h flt_arith.h +flt_mul.$(SUF): flt_misc.h flt_arith.h +flt_modf.$(SUF): flt_misc.h flt_arith.h +flt_umin.$(SUF): flt_misc.h +ucmp.$(SUF): flt_misc.h flt_arith.h +split.$(SUF): flt_misc.h flt_arith.h diff --git a/modules/src/flt_arith/misc.h b/modules/src/flt_arith/misc.h new file mode 100644 index 00000000..254d3134 --- /dev/null +++ b/modules/src/flt_arith/misc.h @@ -0,0 +1,22 @@ +/* + * (c) copyright 1989 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +#include + +/* some short-hands ... */ +#define m1 flt_mantissa.flt_h_32 +#define m2 flt_mantissa.flt_l_32 + +/* some constants */ +#define EXT_MAX 16384 /* max exponent */ +#define EXT_MIN (-16384) /* min exponent */ + +/* hiding of names: */ +#define ucmp flt__ucmp +#define flt_nrm flt__nrm +#define flt_chk flt__chk +#define flt_b64_add flt__64add +#define flt_split flt__split diff --git a/modules/src/idf/Makefile b/modules/src/idf/Makefile new file mode 100644 index 00000000..d170b5b9 --- /dev/null +++ b/modules/src/idf/Makefile @@ -0,0 +1,23 @@ +EMHOME = ../../.. +INSTALL = $(EMHOME)/modules/install +COMPARE = $(EMHOME)/modules/compare + +all: + +install: all + $(INSTALL) pkg/idf_pkg.body + $(INSTALL) pkg/idf_pkg.spec + $(INSTALL) man/idf.3 + +cmp: all + -$(COMPARE) pkg/idf_pkg.body + -$(COMPARE) pkg/idf_pkg.spec + -$(COMPARE) man/idf.3 + +pr: + @pr Makefile idf_pkg.spec idf_pkg.body + +opr: + make pr | opr + +clean: diff --git a/modules/src/input/Makefile b/modules/src/input/Makefile new file mode 100644 index 00000000..ab4da17a --- /dev/null +++ b/modules/src/input/Makefile @@ -0,0 +1,46 @@ +EMHOME = ../../.. +MODULES = $(EMHOME)/modules +INSTALL = $(MODULES)/install +COMPARE = $(MODULES)/compare +CFLAGS = -O $(COPT) +AR = ar +SUF = o +LIBSUF = a + +OBJECTS = AtEoIF.$(SUF)\ + AtEoIT.$(SUF) + +.SUFFIXES: .$(SUF) +.c.$(SUF): + $(CC) -c $(CFLAGS) $*.c + +all: libinput.$(LIBSUF) + +libinput.$(LIBSUF): $(OBJECTS) + $(AR) cr libinput.$(LIBSUF) $(OBJECTS) + -sh -c 'ranlib libinput.$(LIBSUF)' + +install: all + $(INSTALL) lib/libinput.$(LIBSUF) + $(INSTALL) man/input.3 + $(INSTALL) pkg/inp_pkg.body + $(INSTALL) pkg/inp_pkg.spec + +cmp: all + -$(COMPARE) lib/libinput.$(LIBSUF) + -$(COMPARE) man/input.3 + -$(COMPARE) pkg/inp_pkg.body + -$(COMPARE) pkg/inp_pkg.spec + +pr: + @pr Makefile inp_pkg.spec inp_pkg.body AtEoIF.c AtEoIT.c + +opr: + make pr | opr + +clean: + rm -f *.$(SUF) *.$(LIBSUF) + +lintlib: + lint -Cinput AtEoIF.c AtEoIT.c + mv llib-linput.ln $(MODULES)/lib diff --git a/modules/src/malloc/Makefile b/modules/src/malloc/Makefile new file mode 100644 index 00000000..0a4ca6ba --- /dev/null +++ b/modules/src/malloc/Makefile @@ -0,0 +1,44 @@ +EMHOME = ../../.. +INSTALL = $(EMHOME)/modules/install +COMPARE = $(EMHOME)/modules/compare +CFLAGS = -O -I$(EMHOME)/modules/h $(COPT) +SUF = o +RCC = cc #$ must produce a runnable object + +MALLOCSRC = READ_ME size_type.h gensize_type.h param.h impl.h check.h log.h phys.h \ + mal.c log.c phys.c check.c + +.SUFFIXES: .$(SUF) +.c.$(SUF): + $(CC) -c $(CFLAGS) $*.c + +all: malloc.$(SUF) + +install: all + $(INSTALL) lib/malloc.$(SUF) + +cmp: all + -$(COMPARE) lib/malloc.$(SUF) + +malloc1.c: $(MALLOCSRC) Makefile add_file + rm -f malloc1.c + for i in $(MALLOCSRC) ; do add_file $$i >> malloc1.c ; done + +malloc.c: malloc1.c + cclash -l7 -c malloc1.c > clashes + cid -Fclashes < malloc1.c > malloc.c + +pr: + @pr Makefile add_file $(MALLOCSRC) + +opr: + make pr | opr + +clean: + rm -f *.$(SUF) clashes malloc1.c gensize_type.h getsize malloc.c + +gensize_type.h: getsize + getsize > gensize_type.h + +getsize: getsize.c + $(RCC) -o getsize getsize.c diff --git a/modules/src/object/Makefile b/modules/src/object/Makefile new file mode 100644 index 00000000..6c253adb --- /dev/null +++ b/modules/src/object/Makefile @@ -0,0 +1,80 @@ +EMHOME = ../../.. +MODULES = $(EMHOME)/modules +INSTALL = $(MODULES)/install +COMPARE = $(MODULES)/compare +INCLUDES = -I$(EMHOME)/h +CFLAGS = -O $(INCLUDES) $(COPT) +AR = ar +SUF = o +LIBSUF = a +RCC = cc # must produce a runnable object + +CFILES = rd_arhdr.c wr_arhdr.c \ + rd_ranlib.c wr_ranlib.c \ + rd_bytes.c wr_bytes.c \ + rd.c wr.c \ + wr_putc.c \ + rd_int2.c wr_int2.c \ + rd_unsig2.c \ + rd_long.c wr_long.c +# do not change the order in OFILES +OFILES = rd.$(SUF) rd_arhdr.$(SUF) rd_int2.$(SUF) rd_long.$(SUF) rd_ranlib.$(SUF) rd_unsig2.$(SUF) \ + rd_bytes.$(SUF) wr_arhdr.$(SUF) wr_int2.$(SUF) wr_long.$(SUF) wr_putc.$(SUF) wr.$(SUF) \ + wr_ranlib.$(SUF) wr_bytes.$(SUF) + +.SUFFIXES: .$(SUF) +.c.$(SUF): + $(CC) -c $(CFLAGS) $*.c + +all: libobject.$(LIBSUF) + +install: all + $(INSTALL) lib/libobject.$(LIBSUF) + $(INSTALL) man/object.3 + +compare: all + -$(COMPARE) lib/libobject.$(LIBSUF) + -$(COMPARE) man/object.3 + +pr: + @pr Makefile byte_order.c object.h $(CFILES) + +opr: + make pr | opr + +clean: + rm -f *.$(SUF) *.$(LIBSUF) nohup.out Out byte_order byte_order.h + +libobject.$(LIBSUF): $(OFILES) + $(AR) r libobject.$(LIBSUF) $(OFILES) + -sh -c 'ranlib libobject.$(LIBSUF)' + +depend: byte_order.h + sed '/^#AUTOAUTO/,$$d' Makefile > Makefile.new + echo '#AUTOAUTOAUTOAUTOAUTOAUTOAUTO' >> Makefile.new + mkdep $(CFILES) | sed 's/\.c:/\.$(SUF):/' >> Makefile.new + mv Makefile Makefile.$(SUF)ld + mv Makefile.new Makefile + +byte_order: byte_order.c + $(RCC) -o byte_order byte_order.c + +byte_order.h: byte_order + byte_order > byte_order.h + +lintlib: byte_order.h + lint $(INCLUDES) -Cobject $(CFILES) + mv llib-lobject.ln $(MODULES)/lib + +#AUTOAUTOAUTOAUTOAUTOAUTOAUTO +rd_arhdr.$(SUF): byte_order.h object.h +wr_arhdr.$(SUF): byte_order.h object.h +rd_ranlib.$(SUF): byte_order.h object.h +wr_ranlib.$(SUF): byte_order.h object.h +rd.$(SUF): byte_order.h object.h +wr.$(SUF): byte_order.h object.h +rd_int2.$(SUF): byte_order.h object.h +wr_int2.$(SUF): byte_order.h object.h +rd_unsig2.$(SUF): byte_order.h object.h +rd_long.$(SUF): byte_order.h object.h +wr_long.$(SUF): byte_order.h object.h diff --git a/modules/src/object/byte_order.c b/modules/src/object/byte_order.c new file mode 100644 index 00000000..16da2c2e --- /dev/null +++ b/modules/src/object/byte_order.c @@ -0,0 +1,54 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#include + +char bytes_reversed = 0; +char words_reversed = 0; +char char_unsigned = 0; + +/* + * Determine the byte/word order in shorts/longs, assuming the size of a short + * is 2 chars, and the size of a long is 4 chars. Not all theoretical + * possibilities are tested; only bytes reversed and/or words reversed. + */ +determine_ordering() +{ + short s; + long l; + register char *cp; + register short *sp; + + cp = (char *)&s; + cp[0] = 0x01; cp[1] = 0x02; + if (s != 0x01 + (0x02 << 8)) + bytes_reversed = 1; + sp = (short *)&l; + sp[0] = 0x0001; sp[1] = 0x0002; + if (l != 0x0001 + (0x0002L << 16)) + words_reversed = 1; +} + +/* + * determine whether characters are unsigned or signed + */ + +uns_char() +{ + char c = 0200; + int i = c; + + if (i > 0) char_unsigned = 1; +} + +main() +{ + determine_ordering(); + uns_char(); + printf("#define BYTES_REVERSED %d\n", bytes_reversed); + printf("#define WORDS_REVERSED %d\n", words_reversed); + printf("#define CHAR_UNSIGNED %d\n", char_unsigned); + return 0; +} diff --git a/modules/src/print/Makefile b/modules/src/print/Makefile new file mode 100644 index 00000000..3831b133 --- /dev/null +++ b/modules/src/print/Makefile @@ -0,0 +1,51 @@ +EMHOME = ../../.. +MODDIR=$(EMHOME)/modules +INSTALL = $(MODDIR)/install +COMPARE = $(MODDIR)/compare +INCLUDES = -I$(MODDIR)/h +CFLAGS = -O $(INCLUDES) $(COPT) +AR = ar +SUF = o +LIBSUF = a + +LIBPRINT = libprint.$(LIBSUF) + +SRC = doprnt.c fprint.c print.c sprint.c format.c +OBJ = doprnt.$(SUF) fprint.$(SUF) print.$(SUF) sprint.$(SUF) format.$(SUF) + +.SUFFIXES: .$(SUF) +.c.$(SUF): + $(CC) -c $(CFLAGS) $*.c + +all: $(LIBPRINT) + +$(LIBPRINT): $(OBJ) + rm -f $(LIBPRINT) + $(AR) r $(LIBPRINT) $(OBJ) + -sh -c 'ranlib $(LIBPRINT)' + +install: all + $(INSTALL) lib/$(LIBPRINT) + $(INSTALL) man/print.3 + +cmp: all + -$(COMPARE) lib/$(LIBPRINT) + -$(COMPARE) man/print.3 + +pr: + @pr Makefile $(SRC) + +opr: + make pr | opr + +clean: + rm -f *.$(SUF) $(LIBPRINT) + +lintlib: + lint $(INCLUDES) -Cprint $(SRC) + mv llib-lprint.ln $(MODDIR)/lib + +doprnt.$(SUF): param.h +fprint.$(SUF): param.h +print.$(SUF): param.h +sprint.$(SUF): param.h diff --git a/modules/src/read_em/Makefile b/modules/src/read_em/Makefile new file mode 100644 index 00000000..34a2fb86 --- /dev/null +++ b/modules/src/read_em/Makefile @@ -0,0 +1,119 @@ +EMHOME = ../../.. +MODULES = $(EMHOME)/modules +HDIR = $(MODULES)/h +EMHDIR = $(EMHOME)/h +INCLUDES = -I$(HDIR) -I$(EMHDIR) +DEFINES = -DPRIVATE=static -DEXPORT= +CFLAGS = -O $(INCLUDES) $(DEFINES) $(COPT) +INSTALL = $(MODULES)/install +COMPARE = $(MODULES)/compare +AR = ar +SUF = o +LIBSUF = a + +TARGETS = libread_emk.$(LIBSUF)\ + libread_emkV.$(LIBSUF)\ + libread_emeV.$(LIBSUF) # makecallsO.$(SUF) makecallsCE.$(SUF) + +ESRCFILES = read_em.c\ + mkcalls.c\ + EM_vars.c + +KSRCFILES = read_em.c\ + mkcalls.c\ + EM_vars.c + +SRCFILES = em_comp.h\ + read_em.c\ + reade.c\ + readk.c \ + mkcalls.c\ + EM_vars.c + +EV_OFILES = read_emeV.$(SUF) makecallsV.$(SUF) EM_vars.$(SUF) +KV_OFILES = read_emkV.$(SUF) makecallsV.$(SUF) EM_vars.$(SUF) +K_OFILES = read_emk.$(SUF) makecalls.$(SUF) EM_vars.$(SUF) + +.SUFFIXES: .$(SUF) +.c.$(SUF): + $(CC) -c $(CFLAGS) $*.c + +all: $(TARGETS) + +install: all + $(INSTALL) h/em_comp.h + $(INSTALL) lib/libread_emk.$(LIBSUF) + $(INSTALL) lib/libread_emkV.$(LIBSUF) + $(INSTALL) lib/libread_emeV.$(LIBSUF) + $(INSTALL) man/read_em.3 +# $(INSTALL) lib/makecallsO.$(SUF) +# $(INSTALL) lib/makecallsCE.$(SUF) + +cmp: all + -$(COMPARE) h/em_comp.h + -$(COMPARE) lib/libread_emk.$(LIBSUF) + -$(COMPARE) lib/libread_emkV.$(LIBSUF) + -$(COMPARE) lib/libread_emeV.$(LIBSUF) + -$(COMPARE) man/read_em.3 +# -$(COMPARE) lib/makecallsO.$(SUF) +# -$(COMPARE) lib/makecallsCE.$(SUF) + +pr: + @pr Makefile m_C_mnem m_C_mnem_na argtype $(SRCFILES) + +opr: + make pr | opr + +clean: + rm -f *.$(SUF) *.$(LIBSUF) C_mnem C_mnem_narg + +libread_emk.$(LIBSUF): $(K_OFILES) + $(AR) r libread_emk.$(LIBSUF) $(K_OFILES) + -sh -c 'ranlib libread_emk.$(LIBSUF)' + +libread_emkV.$(LIBSUF): $(KV_OFILES) + $(AR) r libread_emkV.$(LIBSUF) $(KV_OFILES) + -sh -c 'ranlib libread_emkV.$(LIBSUF)' + +libread_emeV.$(LIBSUF): $(EV_OFILES) + $(AR) r libread_emeV.$(LIBSUF) $(EV_OFILES) + -sh -c 'ranlib libread_emeV.$(LIBSUF)' + +read_emk.$(SUF): read_em.c em_comp.h readk.c + $(CC) -c $(CFLAGS) -DCOMPACT read_em.c + mv read_em.$(SUF) read_emk.$(SUF) + +read_emkV.$(SUF): read_em.c em_comp.h readk.c + $(CC) -c $(CFLAGS) -DCOMPACT -DCHECKING read_em.c + mv read_em.$(SUF) read_emkV.$(SUF) + +read_emeV.$(SUF): read_em.c em_comp.h reade.c + $(CC) -c $(CFLAGS) -DCHECKING read_em.c + mv read_em.$(SUF) read_emeV.$(SUF) + +makecalls.$(SUF): C_mnem C_mnem_narg em_comp.h mkcalls.c + $(CC) -c $(CFLAGS) mkcalls.c + mv mkcalls.$(SUF) makecalls.$(SUF) + +makecallsV.$(SUF): C_mnem C_mnem_narg em_comp.h mkcalls.c + $(CC) -c $(CFLAGS) -DCHECKING mkcalls.c + mv mkcalls.$(SUF) makecallsV.$(SUF) + +makecallsO.$(SUF): C_mnem C_mnem_narg em_comp.h mkcalls.c + $(CC) -c -DPEEPHOLE $(CFLAGS) mkcalls.c + mv mkcalls.$(SUF) makecallsO.$(SUF) + +makecallsCE.$(SUF): C_mnem C_mnem_narg em_comp.h mkcalls.c + $(CC) -c -DCODE_EXPANDER $(CFLAGS) mkcalls.c + mv mkcalls.$(SUF) makecallsCE.$(SUF) + +C_mnem: m_C_mnem argtype + sh m_C_mnem > C_mnem + +C_mnem_narg: m_C_mnem_na argtype + sh m_C_mnem_na > C_mnem_narg + +lintlib: C_mnem C_mnem_narg + lint $(INCLUDES) $(DEFINES) -DCOMPACT -DCHECKING -Cread_emkV $(KSRCFILES) + lint $(INCLUDES) $(DEFINES) -DCHECKING -Cread_emeV $(ESRCFILES) + mv llib-lread_emeV.ln llib-lread_emkV.ln $(MODULES)/lib diff --git a/modules/src/read_em/m_C_funcs b/modules/src/read_em/m_C_funcs new file mode 100755 index 00000000..dd89cc8b --- /dev/null +++ b/modules/src/read_em/m_C_funcs @@ -0,0 +1,25 @@ +EM_TABLE=../../../etc/em_table +ed - $EM_TABLE << EOF +1,/^\$/d +1,/^\$/d +1,\$s/^\(...\).*/int C_\\1();/ +w blabla1 +q +EOF +ed - $EM_TABLE << A +1,/^\$/d +1,/^\$/d +/^\$/d +1,\$s/^\(...\).*/C_\\1,/ +\$a +}; +. +1i +static int (*C_funcs[])() = { +0, +. +w blabla2 +q +A +cat blabla1 blabla2 > C_funcs +rm blabla1 blabla2 diff --git a/modules/src/string/Makefile b/modules/src/string/Makefile new file mode 100644 index 00000000..5622bfa8 --- /dev/null +++ b/modules/src/string/Makefile @@ -0,0 +1,49 @@ +EMHOME = ../../.. +MODULES = $(EMHOME)/modules +INSTALL = $(MODULES)/install +COMPARE = $(MODULES)/compare +AR = ar +SUF = o +LIBSUF = a + +CFLAGS = -O $(COPT) + +SRC = bts2str.c btscat.c btscmp.c btscpy.c btszero.c long2str.c \ + str2bts.c str2long.c strcat.c strcmp.c strcpy.c strindex.c \ + strlen.c strncat.c strncmp.c strncpy.c strrindex.c strzero.c +OBJ = bts2str.$(SUF) btscat.$(SUF) btscmp.$(SUF) btscpy.$(SUF) \ + btszero.$(SUF) long2str.$(SUF) str2bts.$(SUF) str2long.$(SUF) \ + strcat.$(SUF) strcmp.$(SUF) strcpy.$(SUF) strindex.$(SUF) \ + strlen.$(SUF) strncat.$(SUF) strncmp.$(SUF) strncpy.$(SUF) \ + strrindex.$(SUF) strzero.$(SUF) + +.SUFFIXES: .$(SUF) +.c.$(SUF): + $(CC) -c $(CFLAGS) $*.c + +all: libstring.$(LIBSUF) + +libstring.$(LIBSUF): $(OBJ) Makefile + $(AR) r libstring.$(LIBSUF) $(OBJ) + -sh -c 'ranlib libstring.$(LIBSUF)' + +install: all + $(INSTALL) lib/libstring.$(LIBSUF) + $(INSTALL) man/string.3 + +cmp: all + -$(COMPARE) lib/libstring.$(LIBSUF) + -$(COMPARE) man/string.3 + +pr: + @pr Makefile $(SRC) + +opr: + make pr | opr + +clean: + rm -f *.$(SUF) *.$(LIBSUF) + +lintlib: + lint -Cstring $(SRC) + mv llib-lstring.ln $(MODULES)/lib diff --git a/modules/src/system/Makefile b/modules/src/system/Makefile new file mode 100644 index 00000000..f4d4b5a9 --- /dev/null +++ b/modules/src/system/Makefile @@ -0,0 +1,63 @@ +EMHOME = ../../.. +MODULES = $(EMHOME)/modules +INSTALL = $(MODULES)/install +COMPARE = $(MODULES)/compare +INCLUDES = -I. +CFLAGS = $(INCLUDES) -O $(COPT) +AR = ar +SUF = o +LIBSUF = a + +LIBSYS = libsystem.$(LIBSUF) +OBJ = access.$(SUF) break.$(SUF) chmode.$(SUF) close.$(SUF) create.$(SUF) \ + filesize.$(SUF) modtime.$(SUF) lock.$(SUF) open.$(SUF) read.$(SUF) \ + remove.$(SUF) stop.$(SUF) system.$(SUF) time.$(SUF) unlock.$(SUF) \ + write.$(SUF) seek.$(SUF) rename.$(SUF) +CSRC = access.c break.c chmode.c close.c create.c filesize.c \ + modtime.c lock.c open.c read.c remove.c stop.c \ + system.c time.c unlock.c write.c seek.c rename.c +SRC = Makefile system.h $(CSRC) + +.SUFFIXES: .$(SUF) +.c.$(SUF): + $(CC) -c $(CFLAGS) $*.c + +all: $(LIBSYS) + +$(LIBSYS): $(OBJ) + rm -f $(LIBSYS) + $(AR) r $(LIBSYS) $(OBJ) + -sh -c 'ranlib $(LIBSYS)' + +install: all + $(INSTALL) lib/$(LIBSYS) + $(INSTALL) man/system.3 + $(INSTALL) h/system.h + +cmp: all + -$(COMPARE) lib/$(LIBSYS) + -$(COMPARE) man/system.3 + -$(COMPARE) h/system.h + +clean: + rm -f *.$(SUF) *.$(LIBSUF) + +pr: + @pr $(SRC) + +opr: + make pr | opr + +lintlib: + lint $(INCLUDES) -Csystem $(CSRC) + mv llib-lsystem.ln $(MODULES)/lib + +access.$(SUF): system.h +break.$(SUF): system.h +close.$(SUF): system.h +create.$(SUF): system.h +open.$(SUF): system.h +read.$(SUF): system.h +stop.$(SUF): system.h +system.$(SUF): system.h +write.$(SUF): system.h diff --git a/modules/src/system/exit.c b/modules/src/system/exit.c new file mode 100644 index 00000000..bcad6e8e --- /dev/null +++ b/modules/src/system/exit.c @@ -0,0 +1,13 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ +/* called by /lib/crt0.o; needed to suppress the loading of the + standard exit() which performs unnecessary cleanup actions +*/ + +exit(n) +{ + _exit(n); +} diff --git a/util/LLgen/src/assert.h b/util/LLgen/src/assert.h new file mode 100644 index 00000000..beb5f3fe --- /dev/null +++ b/util/LLgen/src/assert.h @@ -0,0 +1,24 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + */ + +/* + * L L G E N + * + * An Extended LL(1) Parser Generator + * + * Author : Ceriel J.H. Jacobs + */ + +/* + * assert.h $Header$ + * an assertion macro + */ + +#ifndef NDEBUG +#define assert(x) if(!(x)) badassertion("x",__FILE__,__LINE__) +#else +#define assert(x) /* nothing */ +#endif diff --git a/util/LLgen/src/tunable.h b/util/LLgen/src/tunable.h new file mode 100644 index 00000000..da9c73bc --- /dev/null +++ b/util/LLgen/src/tunable.h @@ -0,0 +1,31 @@ +/* + * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. + * + * This product is part of the Amsterdam Compiler Kit. + * + * Permission to use, sell, duplicate or disclose this software must be + * obtained in writing. Requests for such permissions may be sent to + * + * Dr. Andrew S. Tanenbaum + * Wiskundig Seminarium + * Vrije Universiteit + * Postbox 7161 + * 1007 MC Amsterdam + * The Netherlands + * + */ + +/* + * L L G E N + * + * An Extended LL(1) Parser Generator + * + * Author : Ceriel J.H. Jacobs + */ + +/* + * tunable.h $Header$ + * Tunable constants + */ + +# define LTEXTSZ 51 /* size of token */ diff --git a/util/ack/Makefile b/util/ack/Makefile new file mode 100644 index 00000000..a834ed91 --- /dev/null +++ b/util/ack/Makefile @@ -0,0 +1,75 @@ +# $Header$ +EMHOME=../.. +HFILES=ack.h list.h trans.h data.h dmach.h grows.h +DSRC=list.c data.c main.c scan.c svars.c trans.c util.c rmach.c run.c grows.c\ + files.c +ISRC=dmach.c intable.c +OBJ=list.o data.o main.o scan.o svars.o trans.o util.o rmach.o run.o \ + dmach.o intable.o grows.o files.o +ACKDIR=$(EMHOME)/lib +FE=fe +INTABLES=pdp +LNTABLES=acc apc abc ocm m2 vax4 i86 i386 m68k2 m68k4 pmds pmds4 mantra \ + m68020 z8000 em22 em24 em44 6500 6800 6805 6809 i80 ns s2650 z80 \ + sun3 sun2 xenix3 minix minixST +INCLUDES=-I$(EMHOME)/h +CFLAGS=-O $(INCLUDES) +LDFLAGS= +BINDIR=$(EMHOME)/bin +MANDIR=$(EMHOME)/man +MODDIR=$(EMHOME)/modules/lib + +head: ack ack.1 + +install: ack ack.1 + rm -f $(BINDIR)/ack + cp ack $(BINDIR)/ack + -cd $(BINDIR) ; \ + for i in $(INTABLES) $(LNTABLES) ; do rm -f $$i ; ln ack $$i ; done + rm -f $(MANDIR)/ack.1 + cp ack.1 $(MANDIR)/ack.1 + +cmp: ack ack.1 + -cmp ack $(BINDIR)/ack + -cmp ack.1 $(MANDIR)/ack.1 + +ack.1: ack.1.X + -sh -c 'tbl < ack.1.X > ack.1' + -sh -c 'if test -s ack.1 ; then : ; else cp ack.1.X ack.1 ; fi' + +clean: + -rm -f *.old *.o ack ack.1 + +ack: $(OBJ) + $(CC) $(LDFLAGS) -o ack $(OBJ) $(MODDIR)/libstring.a + +grows.o files.o list.o run.o \ +data.o main.o scan.o trans.o rmach.o util.o : ack.h list.h + +files.o data.o main.o scan.o run.o trans.o rmach.o: trans.h data.h + +files.o rmach.o trans.o grows.c : grows.h + +rmach.c: dmach.h + +files.o main.o rmach.o : $(EMHOME)/h/em_path.h + +main.o : $(EMHOME)/h/local.h + +svars.o: ack.h + +dmach.c intable.c: mktables dmach.h + : mktables $(ACKDIR) # $(FE) $(INTABLES) + mktables $(ACKDIR) + +mktables: mktables.c + $(CC) -o mktables mktables.c + +pr: + @pr Makefile $(HFILES) $(DSRC) + +opr: + make pr | opr + +lint: $(ISRC) + lint -hbx $(INCLUDES) $(DSRC) $(ISRC) diff --git a/util/ack/malloc.c b/util/ack/malloc.c new file mode 100644 index 00000000..87a4bce5 --- /dev/null +++ b/util/ack/malloc.c @@ -0,0 +1,212 @@ +/* + * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. + * + * This product is part of the Amsterdam Compiler Kit. + * + * Permission to use, sell, duplicate or disclose this software must be + * obtained in writing. Requests for such permissions may be sent to + * + * Dr. Andrew S. Tanenbaum + * Wiskundig Seminarium + * Vrije Universiteit + * Postbox 7161 + * 1007 MC Amsterdam + * The Netherlands + * + */ + + +#include "ack.h" +#ifdef DEBUG +#define ASSERT(p) if(!(p))botch("p");else +botch(s) +char *s; +{ + printf("malloc/free botched: %s\n",s); + abort(); +} +#else +#define ASSERT(p) +#endif + +#ifndef NORCSID +static char rcs_id[] = "$Header$" ; +#endif + +/* avoid break bug */ +#ifdef pdp11 +#define GRANULE 64 +#else +#define GRANULE 0 +#endif +/* C storage allocator + * circular first-fit strategy + * works with noncontiguous, but monotonically linked, arena + * each block is preceded by a ptr to the (pointer of) + * the next following block + * blocks are exact number of words long + * aligned to the data type requirements of ALIGN + * pointers to blocks must have BUSY bit 0 + * bit in ptr is 1 for busy, 0 for idle + * gaps in arena are merely noted as busy blocks + * last block of arena (pointed to by alloct) is empty and + * has a pointer to first + * idle blocks are coalesced during space search + * + * a different implementation may need to redefine + * ALIGN, NALIGN, BLOCK, BUSY, INT + * where INT is integer type to which a pointer can be cast +*/ +#define INT int +#define ALIGN int +#define NALIGN 1 +#define WORD sizeof(union store) +#define BLOCK 1024 /* a multiple of WORD*/ +#define BUSY 1 +#define NULL 0 +#define testbusy(p) ((INT)(p)&BUSY) +#define setbusy(p) (union store *)((INT)(p)|BUSY) +#define clearbusy(p) (union store *)((INT)(p)&~BUSY) + +union store { union store *ptr; + ALIGN dummy[NALIGN]; + int calloc; /*calloc clears an array of integers*/ +}; + +static union store allocs[2]; /*initial arena*/ +static union store *allocp; /*search ptr*/ +static union store *alloct; /*arena top*/ +static union store *allocx; /*for benefit of realloc*/ +char *sbrk(); + +char * +malloc(nbytes) +unsigned nbytes; +{ + register union store *p, *q; + register nw; + static temp; /*coroutines assume no auto*/ + + if(allocs[0].ptr==0) { /*first time*/ + allocs[0].ptr = setbusy(&allocs[1]); + allocs[1].ptr = setbusy(&allocs[0]); + alloct = &allocs[1]; + allocp = &allocs[0]; + } + nw = (nbytes+WORD+WORD-1)/WORD; + ASSERT(allocp>=allocs && allocp<=alloct); + ASSERT(allock()); + for(p=allocp; ; ) { + for(temp=0; ; ) { + if(!testbusy(p->ptr)) { + while(!testbusy((q=p->ptr)->ptr)) { + ASSERT(q>p&&qptr = q->ptr; + } + if(q>=p+nw && p+nw>=p) + goto found; + } + q = p; + p = clearbusy(p->ptr); + if(p>q) + ASSERT(p<=alloct); + else if(q!=alloct || p!=allocs) { + ASSERT(q==alloct&&p==allocs); + return(NULL); + } else if(++temp>1) + break; + } + temp = ((nw+BLOCK/WORD)/(BLOCK/WORD))*(BLOCK/WORD); + q = (union store *)sbrk(0); + if(q+temp+GRANULE < q) { + return(NULL); + } + q = (union store *)sbrk(temp*WORD); + if((INT)q == -1) { + return(NULL); + } + ASSERT(q>alloct); + alloct->ptr = q; + if(q!=alloct+1) + alloct->ptr = setbusy(alloct->ptr); + alloct = q->ptr = q+temp-1; + alloct->ptr = setbusy(allocs); + } +found: + allocp = p + nw; + ASSERT(allocp<=alloct); + if(q>allocp) { + allocx = allocp->ptr; + allocp->ptr = p->ptr; + } + p->ptr = setbusy(allocp); + return((char *)(p+1)); +} + +/* freeing strategy tuned for LIFO allocation +*/ +free(ap) +register char *ap; +{ + register union store *p = (union store *)ap; + + ASSERT(p>clearbusy(allocs[1].ptr)&&p<=alloct); + ASSERT(allock()); + allocp = --p; + ASSERT(testbusy(p->ptr)); + p->ptr = clearbusy(p->ptr); + ASSERT(p->ptr > allocp && p->ptr <= alloct); +} + +/* realloc(p, nbytes) reallocates a block obtained from malloc() + * and freed since last call of malloc() + * to have new size nbytes, and old content + * returns new location, or 0 on failure +*/ + +char * +realloc(p, nbytes) +register union store *p; +unsigned nbytes; +{ + register union store *q; + union store *s, *t; + register unsigned nw; + unsigned onw; + + if(testbusy(p[-1].ptr)) + free((char *)p); + onw = p[-1].ptr - p; + q = (union store *)malloc(nbytes); + if(q==NULL || q==p) + return((char *)q); + s = p; + t = q; + nw = (nbytes+WORD-1)/WORD; + if(nw=p) + (q+(q+nw-p))->ptr = allocx; + return((char *)q); +} + +#ifdef DEBUG +allock() +{ +#ifdef DEBUG + register union store *p; + int x; + x = 0; + for(p= &allocs[0]; clearbusy(p->ptr) > p; p=clearbusy(p->ptr)) { + if(p==allocp) + x++; + } + ASSERT(p==alloct); + return(x==1|p==allocp); +#else + return(1); +#endif +} +#endif diff --git a/util/amisc/Makefile b/util/amisc/Makefile new file mode 100644 index 00000000..3ebbdbd7 --- /dev/null +++ b/util/amisc/Makefile @@ -0,0 +1,39 @@ +EM = ../.. +BINDIR = $(EM)/bin +MANDIR = $(EM)/man +LIBDIR = $(EM)/modules/lib +h = $(EM)/h +LDFLAGS = +CFLAGS = $(LDFLAGS) -O -I$h +ALL = anm asize astrip +OFILES = anm.o asize.o astrip.o +CFILES = anm.c asize.c astrip.c +LIBS = $(LIBDIR)/libobject.a + +all: $(ALL) + +anm: anm.c + $(CC) $(CFLAGS) -o anm anm.c $(LIBS) +asize: asize.c + $(CC) $(CFLAGS) -o asize asize.c $(LIBS) +astrip: astrip.c + $(CC) $(CFLAGS) -o astrip astrip.c $(LIBS) +#not installed: +ashow: ashow.c + $(CC) $(CFLAGS) -o ashow ashow.c $(LIBS) + +install: all + for i in $(ALL); do rm -f $(BINDIR)/$$i; cp $$i $(BINDIR)/$$i; done + for i in anm.1 asize.1 astrip.1; do rm -f $(MANDIR)/$$i; cp $$i $(MANDIR)/$$i; done + +cmp: all + -for i in $(ALL); do cmp $$i $(BINDIR)/$$i; done + -for i in anm.1 astrip.1 asize.1 ; do cmp $$i $(MANDIR)/$$i; done + +clean: ; rm -f $(ALL) $(OFILES) + +pr: + @pr `pwd`/Makefile `pwd`/anm.c `pwd`/astrip.c `pwd`/asize.c + +opr: + make pr | opr diff --git a/util/arch/Makefile b/util/arch/Makefile new file mode 100644 index 00000000..373c1fb1 --- /dev/null +++ b/util/arch/Makefile @@ -0,0 +1,50 @@ +EMHOME = ../.. +EMH = $(EMHOME)/h +EMBIN = $(EMHOME)/bin +LIB = $(EMHOME)/modules/lib + +LIBS = $(LIB)/libobject.a $(LIB)/libprint.a \ + $(LIB)/libstring.a $(LIB)/libsystem.a + +CFLAGS=-O -I$(EMH) -DDISTRIBUTION +LDFLAGS = + +all: arch aal + +arch: arch.o + $(CC) $(LDFLAGS) -o arch arch.o $(LIBS) + +aal: aal.o + $(CC) $(LDFLAGS) -o aal aal.o $(LIBS) + +arch.o: $(EMH)/arch.h archiver.c + $(CC) $(CFLAGS) -c archiver.c + mv archiver.o arch.o + +aal.o: $(EMH)/arch.h archiver.c $(EMH)/ranlib.h $(EMH)/out.h + $(CC) -DAAL $(CFLAGS) -c archiver.c + mv archiver.o aal.o + +clean: + rm -f aal arch *.o *.old + +install : all + rm -f $(EMBIN)/arch $(EMBIN)/aal + cp aal $(EMBIN)/aal + cp arch $(EMBIN)/arch + rm -f $(EMHOME)/man/arch.1 $(EMHOME)/man/aal.1 $(EMHOME)/man/arch.5 + cp aal.1 $(EMHOME)/man/aal.1 + cp arch.1 $(EMHOME)/man/arch.1 + cp arch.5 $(EMHOME)/man/arch.5 + +cmp : all + -cmp aal $(EMBIN)/aal + -cmp arch $(EMBIN)/arch + -cmp aal.1 $(EMHOME)/man/aal.1 + -cmp arch.1 $(EMHOME)/man/arch.1 + -cmp arch.5 $(EMHOME)/man/arch.5 + +opr: + make pr ^ opr +pr: + @pr Makefile archiver.c diff --git a/util/ass/Makefile b/util/ass/Makefile new file mode 100644 index 00000000..8d1762fe --- /dev/null +++ b/util/ass/Makefile @@ -0,0 +1,76 @@ +# $Header$ +d=../.. +l=$d/lib +h=$d/h +m=$d/man +ASS_PATH=$l/em_ass + +CFLAGS=-O -I$d/h + +all: ass + +clean: + -rm -f ass *.o maktab *.old asstb.c + +install : all + rm -f $(ASS_PATH) + cp ass $(ASS_PATH) + rm -f $m/em_ass.6 + cp em_ass.6 $m/em_ass.6 + +cmp : all + -cmp ass $(ASS_PATH) + -cmp em_ass.6 $m/em_ass.6 + +lint: ass00.c ass30.c ass40.c ass50.c ass60.c ass70.c \ + ass80.c assci.c assda.c assrl.c asstb.c asscm.c + lint -hpvbx \ + ass00.c ass30.c ass40.c ass50.c ass60.c ass70.c \ + ass80.c assci.c assda.c assrl.c asstb.c asscm.c + + +ass: ass00.o ass30.o ass40.o ass50.o ass60.o ass70.o \ + ass80.o assci.o assda.o assrl.o asstb.o asscm.o \ + $l/em_data.a + $(CC) $(CFLAGS) -o ass \ + ass00.o ass30.o ass40.o ass50.o ass60.o ass70.o \ + ass80.o assci.o assda.o assrl.o asstb.o asscm.o \ + $l/em_data.a + +ass00.o ass40.o ass60.o ass70.o ass80.o assrl.o: \ + $h/local.h $h/em_spec.h $h/as_spec.h \ + $h/em_flag.h $h/arch.h ass00.h assex.h + +assci.o: $h/local.h $h/em_spec.h $h/as_spec.h \ + $h/em_flag.h $h/em_mes.h $h/em_pseu.h \ + $h/em_ptyp.h $h/arch.h ass00.h assex.h + +ass30.o ass50.o : \ + $h/local.h $h/em_spec.h $h/as_spec.h \ + $h/em_flag.h ip_spec.h ass00.h assex.h + +ass80.o: $h/em_path.h + +assda.o: $h/local.h $h/em_spec.h $h/as_spec.h \ + $h/em_flag.h $h/arch.h ass00.h + +asscm.o: ass00.h + +asstb.o: asstb.c + +asstb.c: maktab $d/etc/ip_spec.t + maktab $d/etc/ip_spec.t asstb.c + +maktab: maktab.c $h/em_spec.h ip_spec.h $h/em_flag.h \ + $l/em_data.a + $(CC) -O -o maktab maktab.c $l/em_data.a + +asprint: asprint.p + apc -w -o asprint asprint.p + +opr: + make pr ^ opr + +pr: + @(pr ass00.h assex.h ip_spec.h ass?0.c ass[rcd]?.c \ + maktab.c) diff --git a/util/ass/ip_spec.h b/util/ass/ip_spec.h new file mode 100644 index 00000000..6c5d86dc --- /dev/null +++ b/util/ass/ip_spec.h @@ -0,0 +1,40 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* Contents of flags used when describing interpreter opcodes */ + +#define RCS_IP "$Header$" + +#define OPTYPE 07 /* type field in flag */ + +#define OPMINI 0 /* m MINI */ +#define OPSHORT 1 /* s SHORT */ +#define OPNO 2 /* - No operand */ +#define OP8 3 /* 1 1-byte signed operand */ +#define OP16 4 /* 2 2-byte signed operand */ +#define OP32 5 /* 4 4-byte signed operand */ +#define OP64 6 /* 8 8-byte signed operand */ +#define OP16U 7 /* u 2-byte unsigned operand */ + +#define OPESC 010 /* e escaped opcode */ +#define OPWORD 020 /* w operand is word multiple */ +#define OPNZ 040 /* o operand starts at 1 ( or wordsize if w-flag) */ + +#define OPRANGE 0300 /* Range of operands: Positive, negative, both */ + +#define OP_BOTH 0000 /* the default */ +#define OP_POS 0100 /* p Positive (>=0) operands only */ +#define OP_NEG 0200 /* n Negative (<0) operands only */ + +struct opform { + char i_opcode ; /* the opcode number */ + char i_flag ; /* the flag byte */ + char i_low ; /* the interpreter first opcode */ + char i_num ; /* the number of shorts/minis (optional) */ +}; + +/* Escape indicators */ + +#define ESC 254 /* To escape group */ +#define ESC_L 255 /* To 32 and 64 bit operands */ diff --git a/util/byacc/Makefile b/util/byacc/Makefile new file mode 100644 index 00000000..2386de5d --- /dev/null +++ b/util/byacc/Makefile @@ -0,0 +1,82 @@ +EMHOME = ../.. + +DEST = $(EMHOME)/bin +MAN = $(EMHOME)/man + +HDRS = defs.h + +CFLAGS = -O -Dvoid=int + +LDFLAGS = + +LIBS = + +LINKER = cc + +OBJS = closure.o \ + error.o \ + lalr.o \ + lr0.o \ + main.o \ + mkpar.o \ + output.o \ + reader.o \ + skeleton.o \ + symtab.o \ + verbose.o \ + warshall.o + +PRINT = pr -f -l88 + +PROGRAM = yacc + +SRCS = closure.c \ + error.c \ + lalr.c \ + lr0.c \ + main.c \ + mkpar.c \ + output.c \ + reader.c \ + skeleton.c \ + symtab.c \ + verbose.c \ + warshall.c + +all: $(PROGRAM) + +$(PROGRAM): $(OBJS) $(LIBS) + @echo -n "Loading $(PROGRAM) ... " + @$(LINKER) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS) + @echo "done" + +clean:; @rm -f $(OBJS) $(PROGRAM) + +index:; @ctags -wx $(HDRS) $(SRCS) + +install: $(PROGRAM) + @echo Installing $(PROGRAM) in $(DEST) + cp $(PROGRAM) $(DEST)/$(PROGRAM) + cp manpage $(MAN)/yacc.1 + +listing:; @$(PRINT) Makefile $(HDRS) $(SRCS) | lpr + +lint:; @lint $(SRCS) + +program: $(PROGRAM) + +tags: $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS) + +### +closure.o: defs.h +error.o: defs.h +lalr.o: defs.h +lr0.o: defs.h +main.o: defs.h +mkpar.o: defs.h +output.o: defs.h +reader.o: defs.h +skeleton.o: defs.h +symtab.o: defs.h +verbose.o: defs.h +warshall.o: defs.h diff --git a/util/ceg/EM_parser/as_EM_pars/Makefile b/util/ceg/EM_parser/as_EM_pars/Makefile new file mode 100644 index 00000000..efdaa9e0 --- /dev/null +++ b/util/ceg/EM_parser/as_EM_pars/Makefile @@ -0,0 +1,33 @@ +EM=../../../.. +CEGLIB = $(EM)/lib/ceg +PARLIB = $(CEGLIB)/EM_parser +LIB = $(PARLIB)/as_EM_pars + +OFILES = dist.o error.o +HFILES = arg_type.h em_decl.h em_parser.h + +IFILES = -I$(EM)/h -I$(EM)/modules/h +CC = cc + +.c.o : + $(CC) $(IFILES) -c $< + +all : $(OFILES) + +install: all + -mkdir $(CEGLIB) + -mkdir $(PARLIB) + -mkdir $(LIB) + cp $(OFILES) $(HFILES) $(LIB) + +cmp: all + for i in $(OFILES) $(HFILES) ; do cmp $$i $(LIB)/$$i ; done + +clean: + rm -f *.o + +pr: + @pr Makefile arg_type.h dist.c em_decl.h em_parser.h error.c + +opr: + make pr | opr diff --git a/util/ceg/EM_parser/common/Makefile b/util/ceg/EM_parser/common/Makefile new file mode 100644 index 00000000..cef1cf06 --- /dev/null +++ b/util/ceg/EM_parser/common/Makefile @@ -0,0 +1,44 @@ +EM=../../../.. +CEGLIB = $(EM)/lib/ceg +PARLIB = $(CEGLIB)/EM_parser +OBJLIB = $(PARLIB)/obj_EM_pars +ASLIB = $(PARLIB)/as_EM_pars + +GFILES = pars.g +OFILES = pars.o Lpars.o scan.o mylex.o default.o C_instr2.o help.o eval.o\ + action.o +IFILES = -I$(EM)/h -I$(EM)/modules/h +CC = cc +CFLAGS = $(IFILES) + +all : dummy + make $(OFILES) + +dummy : $(GFILES) + LLgen $(LLOPT) $(GFILES) + touch dummy + +install: all + -mkdir $(CEGLIB) + -mkdir $(PARLIB) + -mkdir $(OBJLIB) + -mkdir $(ASLIB) + cp $(OFILES) $(ASLIB) + for i in $(OFILES) ; do rm -f $(OBJLIB)/$$i ; done + for i in $(OFILES) ; do ln $(ASLIB)/$$i $(OBJLIB)/$$i ; done + +cmp: all + for i in $(OFILES) ; do cmp $$i $(ASLIB)/$$i ; done + +clean: + rm -f *.o dummy Lpars.[ch] pars.c + +pr: + @pr Makefile C_instr2.c action.c arg_type.h decl.h default.c \ + em_parser.h eval.c help.c mylex.c pars.g scan.c + +opr: + make pr | opr + +Lpars.o : Lpars.h decl.h +pars.o : Lpars.h decl.h diff --git a/util/ceg/EM_parser/obj_EM_pars/Makefile b/util/ceg/EM_parser/obj_EM_pars/Makefile new file mode 100644 index 00000000..f50c374f --- /dev/null +++ b/util/ceg/EM_parser/obj_EM_pars/Makefile @@ -0,0 +1,33 @@ +EM=../../../.. +CEGLIB = $(EM)/lib/ceg +PARLIB = $(CEGLIB)/EM_parser +LIB = $(PARLIB)/obj_EM_pars + +OFILES = dist.o +HFILES = arg_type.h em_parser.h + +IFILES = -I$(EM)/h -I$(EM)/modules/h +CC = cc + +.c.o : + $(CC) $(IFILES) -c $< + +all : $(OFILES) + +install: all + -mkdir $(CEGLIB) + -mkdir $(PARLIB) + -mkdir $(LIB) + cp $(OFILES) $(HFILES) $(LIB) + +cmp: all + for i in $(OFILES) $(HFILES) ; do cmp $$i $(LIB)/$$i ; done + +clean: + rm -f *.o + +pr: + @pr Makefile arg_type.h dist.c em_parser.h + +opr: + make pr | opr diff --git a/util/ceg/as_parser/Makefile b/util/ceg/as_parser/Makefile new file mode 100644 index 00000000..772f464d --- /dev/null +++ b/util/ceg/as_parser/Makefile @@ -0,0 +1,59 @@ +EM=../../.. +CEGLIB = $(EM)/lib/ceg + +GFILES = pars.g +OFILES = pars.o Lpars.o lex.yy.o help.o conversion.o +IFILES = -I$(EM)/h -I$(EM)/modules/h +LIBS = $(EM)/modules/lib/liballoc.a\ + $(EM)/modules/lib/libprint.a\ + $(EM)/modules/lib/libstring.a\ + $(EM)/modules/lib/libsystem.a +CC = cc +CFLAGS = -O +LEXLIB = -ll + +.c.o : + $(CC) $(CFLAGS) $(IFILES) -c $< + +all: as_parser eval/eval + +as_parser: dummy + make $(OFILES) + $(CC) -o as_parser $(OFILES) $(LIBS) $(LEXLIB) + +eval/eval: + ( cd eval ; make eval ) + +install: all + -mkdir $(CEGLIB) + -mkdir $(CEGLIB)/as_parser + -mkdir $(CEGLIB)/as_parser/eval + cp as_parser $(CEGLIB)/as_parser/as_parser + cp eval/eval $(CEGLIB)/as_parser/eval/eval + cp as_parser.h $(CEGLIB)/as_parser/as_parser.h + +cmp: all + -cmp as_parser $(CEGLIB)/as_parser/as_parser + -cmp eval/eval $(CEGLIB)/as_parser/eval/eval + -cmp as_parser.h $(CEGLIB)/as_parser/as_parser.h + +pr: + @pr Makefile as_parser.h const.h conversion.c decl.h help.c pars.g table.l eval/Makefile eval/eval.c eval/states.h + +opr: + make pr | opr + +clean: + rm -f as_parser *.o lex.yy.c Lpars.[ch] pars.c dummy eval/*.o eval/eval + +lex.yy.c : table.l + lex table.l + +dummy : $(GFILES) + LLgen $(LLOPT) $(GFILES) + touch dummy + +Lpars.o : Lpars.h decl.h +pars.o : Lpars.h decl.h +Lpars.o : Lpars.h decl.h +lex.yy.o : Lpars.h decl.h diff --git a/util/ceg/as_parser/eval/Makefile b/util/ceg/as_parser/eval/Makefile new file mode 100644 index 00000000..22652daf --- /dev/null +++ b/util/ceg/as_parser/eval/Makefile @@ -0,0 +1,7 @@ +CC = cc +CFLAGS = -O + +eval: eval.o + $(CC) $(CFLAGS) -o eval eval.o + +eval.o : states.h diff --git a/util/ceg/assemble/Makefile b/util/ceg/assemble/Makefile new file mode 100644 index 00000000..18d8cfa4 --- /dev/null +++ b/util/ceg/assemble/Makefile @@ -0,0 +1,29 @@ +EM=../../.. +CEG = $(EM)/lib/ceg +ASS = $(CEG)/assemble + +ASLIST = assemble.c block_as.c +OBJLIST = assemble.c block_as.c const.h + +all: + +install: + -mkdir $(CEG) + -mkdir $(ASS) + -mkdir $(ASS)/as_assemble + -mkdir $(ASS)/obj_assemble + for i in $(ASLIST) ; do cp as_assemble/$$i $(ASS)/as_assemble/$$i ; done + for i in $(OBJLIST) ; do cp obj_assemble/$$i $(ASS)/obj_assemble/$$i ; done + +cmp: + -for i in $(ASLIST) ; do cp as_assemble/$$i $(ASS)/as_assemble/$$i ; done + -for i in $(OBJLIST) ; do cp obj_assemble/$$i $(ASS)/obj_assemble/$$i ; done + +pr: + @for i in $(ASLIST) ; do pr as_assemble/$$i ; done + @for i in $(OBJLIST) ; do pr obj_assemble/$$i ; done + +opr: + make pr | opr + +clean: diff --git a/util/ceg/ce_back/Makefile b/util/ceg/ce_back/Makefile new file mode 100644 index 00000000..25f888b3 --- /dev/null +++ b/util/ceg/ce_back/Makefile @@ -0,0 +1,39 @@ +EM=../../.. +CEG = $(EM)/lib/ceg +BACK = $(CEG)/ce_back + +ASLIST = Makefile back.h bottom.c bss.c con1.c con2.c con4.c \ + do_close.c do_open.c end_back.c gen1.c gen2.c gen4.c header.h \ + init_back.c reloc1.c reloc2.c reloc4.c rom1.c rom2.c rom4.c \ + set_global.c set_local.c switchseg.c symboldef.c text1.c \ + text2.c text4.c + +OBJLIST = Makefile back.h con2.c con4.c data.c data.h do_close.c do_open.c \ + end_back.c extnd.c gen1.c gen2.c gen4.c hash.h header.h \ + init_back.c label.c memory.c misc.c output.c \ + reloc1.c reloc2.c reloc4.c relocation.c rom2.c rom4.c \ + set_global.c set_local.c switchseg.c symboldef.c symtable.c \ + text2.c text4.c common.c + +all: + +install: + -mkdir $(CEG) + -mkdir $(BACK) + -mkdir $(BACK)/as_back + -mkdir $(BACK)/obj_back + for i in $(ASLIST) ; do cp as_back/$$i $(BACK)/as_back/$$i ; done + for i in $(OBJLIST) ; do cp obj_back/$$i $(BACK)/obj_back/$$i ; done + +cmp: + -for i in $(ASLIST) ; do cmp as_back/$$i $(BACK)/as_back/$$i ; done + -for i in $(OBJLIST) ; do cmp obj_back/$$i $(BACK)/obj_back/$$i ; done + +pr: + @for i in $(ASLIST) ; do pr as_back/$$i ; done + @for i in $(OBJLIST) ; do pr obj_back/$$i ; done + +opr: + make pr | opr + +clean: diff --git a/util/ceg/ce_back/as_back/Makefile b/util/ceg/ce_back/as_back/Makefile new file mode 100644 index 00000000..ca2d4fe4 --- /dev/null +++ b/util/ceg/ce_back/as_back/Makefile @@ -0,0 +1,96 @@ +EM=../../../.. +CEG=$(EM)/lib/ceg +SOURCE=$(CEG)/ce_back/as_back + +CC = cc +CFLAGS = -O + +IDIRS=-I.\ + -I..\ + -I$(EM)/h\ + -I$(EM)/modules/h + +LIBS=$(EM)/modules/lib/object.a\ + $(EM)/modules/lib/libstring.a\ + $(EM)/modules/lib/libprint.a\ + $(EM)/modules/lib/libsystem.a + +all : bottom.o con1.o con2.o con4.o end_back.o gen1.o gen2.o\ + gen4.o init_back.o reloc1.o reloc2.o reloc4.o bss.o\ + rom1.o rom2.o rom4.o set_global.o set_local.o switchseg.o symboldef.o \ + do_open.o do_close.o text1.o text2.o text4.o + +bottom.o : ../mach.h back.h header.h $(SOURCE)/bottom.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/bottom.c + +bss.o : ../mach.h back.h header.h $(SOURCE)/bss.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/bss.c + +text1.o : ../mach.h back.h header.h $(SOURCE)/text1.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/text1.c + +text2.o : ../mach.h back.h header.h $(SOURCE)/text2.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/text2.c + +text4.o : ../mach.h back.h header.h $(SOURCE)/text4.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/text4.c + +con1.o : ../mach.h back.h header.h $(SOURCE)/con1.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/con1.c + +con2.o : ../mach.h back.h header.h $(SOURCE)/con2.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/con2.c + +con4.o : ../mach.h back.h header.h $(SOURCE)/con4.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/con4.c + +do_open.o : back.h header.h ../mach.h $(SOURCE)/do_open.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/do_open.c + +do_close.o : back.h header.h ../mach.h $(SOURCE)/do_close.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/do_close.c + +gen1.o : back.h header.h ../mach.h $(SOURCE)/gen1.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/gen1.c + +gen2.o : back.h header.h ../mach.h $(SOURCE)/gen2.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/gen2.c + +gen4.o : back.h header.h ../mach.h $(SOURCE)/gen4.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/gen4.c + +init_back.o : header.h back.h ../mach.h $(SOURCE)/init_back.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/init_back.c + +end_back.o : header.h back.h ../mach.h $(SOURCE)/end_back.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/end_back.c + +reloc1.o : back.h header.h ../mach.h $(SOURCE)/reloc1.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/reloc1.c + +reloc2.o : back.h header.h ../mach.h $(SOURCE)/reloc2.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/reloc2.c + +reloc4.o : back.h header.h ../mach.h $(SOURCE)/reloc4.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/reloc4.c + +rom1.o : back.h header.h ../mach.h $(SOURCE)/rom1.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/rom1.c + +rom2.o : back.h header.h ../mach.h $(SOURCE)/rom2.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/rom2.c + +rom4.o : back.h header.h ../mach.h $(SOURCE)/rom4.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/rom4.c + +set_global.o : header.h back.h ../mach.h $(SOURCE)/set_global.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/set_global.c + +set_local.o : header.h back.h ../mach.h $(SOURCE)/set_local.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/set_local.c + +switchseg.o : header.h back.h ../mach.h $(SOURCE)/switchseg.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/switchseg.c + +symboldef.o : header.h back.h ../mach.h $(SOURCE)/symboldef.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/symboldef.c diff --git a/util/ceg/ce_back/as_back/const.h b/util/ceg/ce_back/as_back/const.h new file mode 100644 index 00000000..0a206834 --- /dev/null +++ b/util/ceg/ce_back/as_back/const.h @@ -0,0 +1,2 @@ +#define TRUE 1 +#define FALSE 0 diff --git a/util/ceg/ce_back/obj_back/Makefile b/util/ceg/ce_back/obj_back/Makefile new file mode 100644 index 00000000..67e94d2c --- /dev/null +++ b/util/ceg/ce_back/obj_back/Makefile @@ -0,0 +1,107 @@ +EM=../../../.. +CEG=$(EM)/lib/ceg +SOURCE=$(CEG)/ce_back/obj_back + +CC = cc +CFLAGS = -O + +IDIRS=-I.\ + -I..\ + -I$(EM)/h\ + -I$(EM)/modules/h + +LIBS=$(EM)/modules/lib/*.a + +all : data.o con2.o con4.o relocation.o end_back.o gen1.o gen2.o\ + gen4.o init_back.o output.o reloc1.o reloc2.o reloc4.o\ + rom2.o rom4.o set_global.o set_local.o switchseg.o symboldef.o text2.o\ + text4.o do_open.o do_close.o memory.o label.o misc.o extnd.o symtable.o\ + common.o + +data.o : data.h back.h header.h $(SOURCE)/data.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/data.c + +memory.o :data.h back.h header.h $(SOURCE)/memory.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/memory.c + +con2.o : data.h back.h header.h $(SOURCE)/con2.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/con2.c + +con4.o : data.h back.h header.h $(SOURCE)/con4.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/con4.c + +relocation.o : data.h back.h ../mach.h $(SOURCE)/relocation.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/relocation.c + +do_open.o : data.h back.h ../mach.h $(SOURCE)/do_open.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/do_open.c + +do_close.o : data.h back.h ../mach.h $(SOURCE)/do_close.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/do_close.c + +gen1.o : data.h back.h header.h $(SOURCE)/gen1.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/gen1.c + +gen2.o : data.h back.h header.h $(SOURCE)/gen2.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/gen2.c + +gen4.o : data.h back.h header.h $(SOURCE)/gen4.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/gen4.c + +init_back.o : data.h back.h ../mach.h $(SOURCE)/init_back.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/init_back.c + +end_back.o : data.h back.h ../mach.h $(SOURCE)/end_back.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/end_back.c + +output.o : data.h back.h ../mach.h $(SOURCE)/output.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/output.c + +reloc1.o : data.h back.h header.h $(SOURCE)/reloc1.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/reloc1.c + +reloc2.o : data.h back.h header.h $(SOURCE)/reloc2.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/reloc2.c + +reloc4.o : data.h back.h header.h $(SOURCE)/reloc4.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/reloc4.c + +rom2.o : data.h back.h header.h $(SOURCE)/rom2.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/rom2.c + +rom4.o : data.h back.h header.h $(SOURCE)/rom4.c + $(CC) $(CFLAGS) -c $(IDIRS) $(SOURCE)/rom4.c + +set_global.o : data.h back.h ../mach.h $(SOURCE)/set_global.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/set_global.c + +set_local.o : data.h back.h ../mach.h $(SOURCE)/set_local.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/set_local.c + +switchseg.o : data.h back.h ../mach.h $(SOURCE)/switchseg.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/switchseg.c + +symboldef.o : data.h back.h ../mach.h $(SOURCE)/symboldef.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/symboldef.c + +text2.o : data.h back.h ../mach.h $(SOURCE)/text2.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/text2.c + +text4.o : data.h back.h ../mach.h $(SOURCE)/text4.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/text4.c + +symtable.o : data.h back.h ../mach.h $(SOURCE)/symtable.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/symtable.c + +extnd.o : data.h back.h ../mach.h $(SOURCE)/extnd.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/extnd.c + +misc.o : data.h back.h ../mach.h $(SOURCE)/misc.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/misc.c + +label.o : data.h back.h ../mach.h $(SOURCE)/label.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/label.c + +common.o : data.h back.h ../mach.h $(SOURCE)/common.c + $(CC) $(CFLAGS) -c $(IDIRS) -I.. $(SOURCE)/common.c + diff --git a/util/ceg/ce_back/obj_back/mysprint.c b/util/ceg/ce_back/obj_back/mysprint.c new file mode 100644 index 00000000..44281a66 --- /dev/null +++ b/util/ceg/ce_back/obj_back/mysprint.c @@ -0,0 +1,28 @@ +#include +#include "data.h" +#include + +/* Mysprint() stores the string directly in the string_arae. This saves + * a copy action. It is assumed that the strings stored in the string-table + * are never longer than MAXSTRLEN bytes. + */ + +#define MAXSTRLEN 1024 + +/*VARARGS*/ +int mysprint(va_alist) + va_dcl +{ + char *fmt; + va_list args; + int retval; + + va_start(args); + fmt = va_arg(args, char *); + while (string + MAXSTRLEN - string_area > size_string) + mem_string(); + retval = _format(string, fmt, args); + string[retval] = '\0'; + va_end(args); + return retval; +} diff --git a/util/ceg/defaults/Makefile b/util/ceg/defaults/Makefile new file mode 100644 index 00000000..bd5ba143 --- /dev/null +++ b/util/ceg/defaults/Makefile @@ -0,0 +1,62 @@ +EM = ../../.. +CEGLIB = $(EM)/lib/ceg +DEF = $(CEGLIB)/defaults +MessageList = C_cst.c C_dlb.c C_dnam.c C_fcon.c C_icon.c C_ilb.c C_mes_begin.c \ + C_mes_end.c C_pnam.c C_scon.c C_ucon.c +NotimplList = not_impl.c not_impl_table +PseudoList = C_busy.c C_close.c C_df_dlb.c C_df_dnam.c C_df_ilb.c C_end.c \ + C_end_narg.c C_exa_dlb.c C_exa_dnam.c C_exp.c C_ina_dlb.c \ + C_ina_dnam.c C_init.c C_inp.c C_magic.c C_open.c C_pro.c \ + C_pro_narg.c C_insertpart.c +StorageList = C_bss_cst.c C_bss_dlb.c C_bss_dnam.c C_bss_ilb.c C_bss_pnam.c \ + C_con_cst.c C_con_dlb.c C_con_dnam.c C_con_ilb.c C_con_pnam.c \ + C_con_scon.c C_hol_cst.c C_hol_dlb.c C_hol_dnam.c C_hol_ilb.c \ + C_hol_pnam.c C_rom_cst.c C_rom_dlb.c C_rom_dnam.c C_rom_ilb.c \ + C_rom_pnam.c C_rom_scon.c + +all: C_out.c + +clean: + rm -f C_out.c C_mnem C_mnem_narg + +install: all + -mkdir $(CEGLIB) + -mkdir $(DEF) + -mkdir $(DEF)/message + -mkdir $(DEF)/not_impl + -mkdir $(DEF)/pseudo + -mkdir $(DEF)/storage + cp pseudo_vars.c $(DEF) + cp EM_vars.c $(DEF) + for i in $(MessageList) ; do cp message/$$i $(DEF)/message/$$i ; done + for i in $(NotimplList) ; do cp not_impl/$$i $(DEF)/not_impl/$$i ; done + for i in $(PseudoList) ; do cp pseudo/$$i $(DEF)/pseudo/$$i ; done + for i in $(StorageList) ; do cp storage/$$i $(DEF)/storage/$$i ; done + cp C_out.c $(DEF)/C_out.c + +cmp: + -cmp pseudo_vars.c $(DEF)/pseudo_vars.c + -cmp EM_vars.c $(DEF)/EM_vars.c + -for i in $(MessageList) ; do cmp message/$$i $(DEF)/message/$$i ; done + -for i in $(NotimplList) ; do cmp not_impl/$$i $(DEF)/not_impl/$$i ; done + -for i in $(PseudoList) ; do cmp pseudo/$$i $(DEF)/pseudo/$$i ; done + -for i in $(StorageList) ; do cmp storage/$$i $(DEF)/storage/$$i ; done + -cmp C_out.c $(DEF)/C_out.c + +pr: + @for i in $(MessageList) ; do pr message/$$i ; done + @for i in $(NotimplList) ; do pr not_impl/$$i ; done + @for i in $(PseudoList) ; do pr pseudo/$$i ; done + @for i in $(StorageList) ; do pr storage/$$i ; done + +opr: + make pr | opr + +C_out.c: C_out_skel.c C_mnem C_mnem_narg mk_C_out + mk_C_out > C_out.c + +C_mnem: m_C_mnem argtype + sh m_C_mnem > C_mnem + +C_mnem_narg: m_C_mnem_na argtype + sh m_C_mnem_na > C_mnem_narg diff --git a/util/ceg/util/Makefile b/util/ceg/util/Makefile new file mode 100644 index 00000000..e473f63d --- /dev/null +++ b/util/ceg/util/Makefile @@ -0,0 +1,23 @@ +EM = ../../.. +CEGLIB = $(EM)/lib/ceg +UTIL = $(CEGLIB)/util +UtilList = make_asobj make_own make_back make_ce make_ceg_as make_ceg_obj + +all: + +install: + -mkdir $(CEGLIB) + -mkdir $(UTIL) + cp $(UtilList) $(UTIL) + cp install_ceg update_ceg $(EM)/bin + +cmp: + for i in $(UtilList) ; do cmp $$i $(UTIL)/$$i ; done + +clean: + +pr: + @pr $(UtilList) + +opr: + make pr | opr diff --git a/util/ceg/util/create_ofiles b/util/ceg/util/create_ofiles new file mode 100644 index 00000000..4c8735b3 --- /dev/null +++ b/util/ceg/util/create_ofiles @@ -0,0 +1,13 @@ +list= +for i in *.c +do + b=`basename $i .c` + if test ! -f $b.o + then + >$b.o + list="$list $i" + fi +done +: my SUN is too fast ... +sleep 2 +touch $list diff --git a/util/ceg/util/make_as b/util/ceg/util/make_as new file mode 100644 index 00000000..37e48827 --- /dev/null +++ b/util/ceg/util/make_as @@ -0,0 +1,68 @@ +EM = ../../../.. +CEG = $(EM)/lib/ceg + +Em = $(CEG)/EM_parser/as_EM_pars +ASMAIN = $(CEG)/assemble/as_assemble +BACK = $(CEG)/ce_back +AS = $(CEG)/as_parser +DEF = $(CEG)/defaults + +CC = cc +AR = ar +LEXLIB = -ll + +IFILES = -I. -I.. -I$(AS) -I$(Em) -I$(EM)/h -I$(EM)/modules/h -I../back + +CFLAGS = -O $(IFILES) + +CEG_LIBS = $(EM)/modules/lib/liballoc.a\ + $(EM)/modules/lib/libprint.a\ + $(EM)/modules/lib/libstring.a\ + $(EM)/modules/lib/libsystem.a + +.c.o: mach.h back.a + cd ce ; $(CC) -c $(CFLAGS) ../$*.c ; cd .. + +all: back.a ce.a + +install: all + ../../install ce.a + ../../install back.a + +cmp: all + -../../compare ce.a + -../../compare back.a + +clean: + rm -rf ce back ceg ce.a back.a Out + +dclean: + rm -rf ce back ceg Out + +ce.a : ce/dummy + $(AR) r ce.a ce/*.o + -sh -c 'ranlib ce.a' + +ce/dummy : ce/dummy1 mach.h back.a + cd ce;$(CC) -c $(CFLAGS) *.c; touch dummy ; cd .. + +ce/dummy1: ceg/ceg EM_table mach.h back.a + -mkdir ce + -ln mach.c ce/mach.c + cd ce; ../ceg/ceg -l < $(DEF)/not_impl/not_impl_table ; cp $(DEF)/*.c . ; cp $(DEF)/*/*.c . ; cd .. + cd ce; $(EM)/lib/cpp -P ../EM_table | ../ceg/ceg -l ; cd .. + touch ce/dummy1 + +ceg/as_lib.a: + -mkdir ceg + cd ceg; cp $(ASMAIN)/* . ; $(CC) -c $(IFILES) *.c; $(AR) r as_lib.a *.o ; cd .. + -sh -c 'ranlib ceg/as_lib.a' + +back.a: mach.h + -mkdir back + cd back;cp $(BACK)/as_back/*h . ; cp $(BACK)/as_back/Makefile . ; make ; cd .. + $(AR) r back.a back/*o + -sh -c 'ranlib back.a' + +ceg/ceg : ceg/as_lib.a # $(Em)/em_parser + cd ceg; $(CC) -o ceg $(Em)/*.o as_lib.a $(CEG_LIBS) $(LEXLIB) ; cd .. diff --git a/util/ceg/util/make_ceg_as b/util/ceg/util/make_ceg_as new file mode 100644 index 00000000..60b50f77 --- /dev/null +++ b/util/ceg/util/make_ceg_as @@ -0,0 +1,31 @@ +EM = ../../../.. +CEG = $(EM)/lib/ceg + +Em = $(CEG)/EM_parser/as_EM_pars +ASMAIN = $(CEG)/assemble/as_assemble +AS = $(CEG)/as_parser +DEF = $(CEG)/defaults + +AR = ar +CC = cc +LEXLIB = -ll + +IFILES = -I. -I.. -I$(AS) -I$(Em) -I$(EM)/h -I$(EM)/modules/h -I../back + +CFLAGS = -O $(IFILES) + +CEG_LIBS = $(EM)/modules/lib/liballoc.a\ + $(EM)/modules/lib/libprint.a\ + $(EM)/modules/lib/libstring.a\ + $(EM)/modules/lib/libsystem.a + +all: ceg/ceg + +ceg/ceg: ceg/as_lib.a + cd ceg ; $(CC) -o ceg $(Em)/*.o as_lib.a $(CEG_LIBS) $(LEXLIB) ; cd .. + +ceg/as_lib.a: + -mkdir ceg + cd ceg ; cp $(CEG)/util/make_ceg_as Makefile ; cd .. + cd ceg ; cp $(ASMAIN)/* . ; $(CC) -c $(CFLAGS) *.c; $(AR) r as_lib.a *.o ; cd .. + -sh -c 'ranlib ceg/as_lib.a' diff --git a/util/ceg/util/make_ceg_obj b/util/ceg/util/make_ceg_obj new file mode 100644 index 00000000..df1ac394 --- /dev/null +++ b/util/ceg/util/make_ceg_obj @@ -0,0 +1,44 @@ +EM = ../../../.. +CEG = $(EM)/lib/ceg + +Em = $(CEG)/EM_parser/obj_EM_pars +ASMAIN = $(CEG)/assemble/obj_assemble +AS = $(CEG)/as_parser +EVAL = $(CEG)/as_parser/eval +DEF = $(CEG)/defaults + +AR = ar +CC = cc +LEXLIB = -ll + +IFILES = -I. -I.. -I$(AS) -I$(Em) -I$(EM)/h -I$(EM)/modules/h -I../back + +CFLAGS = -O $(IFILES) + +CEG_LIBS = $(EM)/modules/lib/liballoc.a\ + $(EM)/modules/lib/libprint.a\ + $(EM)/modules/lib/libstring.a\ + $(EM)/modules/lib/libsystem.a + +all: ceg/ceg + +ceg/ceg : ceg/as_lib.a ceg/as_instr.o ceg/eval_as.o + cd ceg ; $(CC) -o ceg $(Em)/*.o as_instr.o eval_as.o as_lib.a $(CEG_LIBS) $(LEXLIB) ; cd .. + +ceg/as_lib.a: + -mkdir ceg + cd ceg ; cp $(CEG)/util/make_ceg_obj Makefile ; cd .. + cd ceg ; cp $(ASMAIN)/* . ; $(CC) -c $(CFLAGS) *.c; $(AR) r as_lib.a *.o ; cd .. + -sh -c 'ranlib ceg/as_lib.a' + +ceg/eval_as.o : ceg/eval_as.c as.h # $(AS)/as_parser.h $(Em)/arg_type.h + cd ceg ; $(CC) -c $(CFLAGS) eval_as.c ; cd .. + +ceg/eval_as.c : as.c # $(EVAL)/eval + cd ceg ; $(EVAL)/eval < ../as.c > eval_as.c ; cd .. + +ceg/as_instr.o : as.h ceg/as_lib.a ceg/as_instr.c + cd ceg ; $(CC) -c $(CFLAGS) as_instr.c ; cd .. + +ceg/as_instr.c : as_table # $(AS)/as_parser + cd ceg ; $(EM)/lib/cpp -P ../as_table | $(AS)/as_parser > as_instr.c ; cd .. diff --git a/util/ceg/util/make_obj b/util/ceg/util/make_obj new file mode 100644 index 00000000..b4709aa8 --- /dev/null +++ b/util/ceg/util/make_obj @@ -0,0 +1,78 @@ +EM = ../../../.. +CEG = $(EM)/lib/ceg + +Em = $(CEG)/EM_parser/obj_EM_pars +ASMAIN = $(CEG)/assemble/obj_assemble +BACK = $(CEG)/ce_back +AS = $(CEG)/as_parser +EVAL = $(CEG)/as_parser/eval +DEF = $(CEG)/defaults + +AR = ar +CC = cc +LEXLIB = -ll + +IFILES = -I. -I.. -I$(AS) -I$(Em) -I$(EM)/h -I$(EM)/modules/h -I../back + +CEG_LIBS = $(EM)/modules/lib/liballoc.a\ + $(EM)/modules/lib/libprint.a\ + $(EM)/modules/lib/libstring.a\ + $(EM)/modules/lib/libsystem.a + +CFLAGS = -O $(IFILES) + +.c.o: mach.h back.a + cd ce ; $(CC) -c $(CFLAGS) ../$*.c ; cd .. + +all: back.a ce.a + +install: all + ../../install ce.a + ../../install back.a + +cmp: all + -../../compare ce.a + -../../compare back.a + +clean: + rm -rf ce back ceg ce.a back.a Out + +ce.a : ce/dummy + $(AR) r ce.a ce/*.o + -sh -c 'ranlib ce.a' + +ce/dummy : ce/dummy1 mach.h back.a + cd ce;$(CC) -c $(CFLAGS) *.c; touch dummy ; cd .. + +ce/dummy1: ceg/ceg EM_table mach.h back.a + -mkdir ce + -ln mach.c ce/mach.c + cd ce; ../ceg/ceg -l < $(DEF)/not_impl/not_impl_table ; cp $(DEF)/*.c . ; cp $(DEF)/*/*.c . ; cd .. + cd ce; $(EM)/lib/cpp -P ../EM_table | ../ceg/ceg -l ; cd .. + touch ce/dummy1 + +back.a: mach.h + -mkdir back + cd back;cp $(BACK)/obj_back/*h . ; cp $(BACK)/obj_back/Makefile . ; make; cd .. + $(AR) r back.a back/*o; + -sh -c 'ranlib back.a' + +ceg/ceg : ceg/as_lib.a ceg/as_instr.o ceg/eval_as.o # $(Em)/em_parser + cd ceg; $(CC) -o ceg $(Em)/*.o as_instr.o eval_as.o as_lib.a $(CEG_LIBS) $(LEXLIB) ; cd .. + +ceg/as_lib.a: + -mkdir ceg + cd ceg; cp $(ASMAIN)/* . ; $(CC) -c $(IFILES) *.c; $(AR) r as_lib.a *.o ; touch dummy ; cd .. + -sh -c 'ranlib ceg/as_lib.a' + +ceg/eval_as.o : ceg/eval_as.c as.h # $(AS)/as_parser.h $(Em)/arg_type.h + cd ceg;$(CC) -c $(IFILES) eval_as.c ; cd .. + +ceg/eval_as.c : as.c # $(EVAL)/eval + cd ceg; $(EVAL)/eval < ../as.c > eval_as.c ; cd .. + +ceg/as_instr.o : as.h ceg/dummy ceg/as_instr.c + cd ceg;$(CC) -c $(IFILES) as_instr.c ; cd .. + +ceg/as_instr.c : as_table # $(AS)/as_parser + cd ceg; $(EM)/lib/cpp -P ../as_table| $(AS)/as_parser > as_instr.c ; cd .. diff --git a/util/ceg/util/preproc b/util/ceg/util/preproc new file mode 100644 index 00000000..28fb419d --- /dev/null +++ b/util/ceg/util/preproc @@ -0,0 +1 @@ +../../../../lib/cpp $@ | sed "/^#/d" diff --git a/util/ceg/util/update b/util/ceg/util/update new file mode 100644 index 00000000..9cca367e --- /dev/null +++ b/util/ceg/util/update @@ -0,0 +1,28 @@ +make -f ce_makefile ceg/ceg + +for i +do + case $i in + ALL) make -f ce_makefile EM_instr ce.a; + exit 0;; + + *.o) make -f ce_makefile ce/$i; + ar r ce.a $i;; + + *..) ( cd ce; ../../../../lib/cpp ../EM_table| sed "/^#/d"| ../ceg/ceg -c $i); + F=`basename $i ..`; + U="_dnam" + V="_dlb" + make -f ce_makefile ce/$F.o ce/$F$U.o ce/"$F$V.o"; + echo ar r ce.a ce/$F.o ce/"$F$U.o" ce/"$F$V.o"; + ar r ce.a ce/$F.o ce/$F$U.o ce/"$F$U.o";; + + *) ( cd ce; ../../../../lib/cpp ../EM_table| sed "/^#/d"| ../ceg/ceg -c $i); + make -f ce_makefile ce/$i.o; + echo ar r ce.a ce/$i.o; + ar r ce.a ce/$i.o;; + esac +done + +echo ranlib ce.a +ranlib ce.a diff --git a/util/cgg/Makefile b/util/cgg/Makefile new file mode 100644 index 00000000..d33c168c --- /dev/null +++ b/util/cgg/Makefile @@ -0,0 +1,34 @@ +# $Header$ + +PREFLAGS=-I../../h +CFLAGS=$(PREFLAGS) +LDFLAGS= +LINTOPTS=-hbxac $(PREFLAGS) +LIBS=../../lib/em_data.a +# LEXLIB is system dependent, try -ll or -lln first +LEXLIB = -lln + +cgg: bootgram.o main.o bootlex.o + $(CC) $(LDFLAGS) bootgram.o main.o bootlex.o $(LIBS) $(LEXLIB) -o cgg + +bootgram.c: bootgram.y + @echo expect 1 shift/reduce conflict + yacc -d bootgram.y + mv y.tab.c bootgram.c + +install: cgg + cp cgg ../../lib/cgg + +cmp: cgg + cmp cgg ../../lib/cgg + +lint: bootgram.c main.c bootlex.c + lint $(LINTOPTS) bootgram.c main.c bootlex.c +clean: + rm -f *.o bootgram.c bootlex.c cgg y.tab.h +bootgram.o: booth.h +bootgram.o: ../../h/cg_pattern.h +bootlex.o: booth.h +bootlex.o: ../../h/cg_pattern.h +main.o: booth.h +main.o: ../../h/cg_pattern.h diff --git a/util/cmisc/Makefile b/util/cmisc/Makefile new file mode 100644 index 00000000..7a7894f3 --- /dev/null +++ b/util/cmisc/Makefile @@ -0,0 +1,52 @@ +EM = ../.. +EMBIN = $(EM)/bin +EMMAN = $(EM)/man +CFLAGS = -O +LDFLAGS = + +all: mkdep cid cclash prid tabgen + +install: all + rm -f $(EMBIN)/mkdep $(EMBIN)/cid $(EMBIN)/cclash $(EMBIN)/prid \ + $(EMBIN)/tabgen + cp mkdep cid cclash prid tabgen $(EMBIN) + rm -f $(EMMAN)/mkdep.1 $(EMMAN)/cid.1 $(EMMAN)/cclash.1 \ + $(EMMAN)/prid.1 $(EMMAN)/tabgen.1 + cp mkdep.1 cid.1 cclash.1 prid.1 tabgen.1 $(EMMAN) + +cmp: all + -cmp mkdep $(EMBIN)/mkdep + -cmp cid $(EMBIN)/cid + -cmp cclash $(EMBIN)/cclash + -cmp prid $(EMBIN)/prid + -cmp tabgen $(EMBIN)/tabgen + -cmp mkdep.1 $(EMMAN)/mkdep.1 + -cmp cid.1 $(EMMAN)/cid.1 + -cmp cclash.1 $(EMMAN)/cclash.1 + -cmp prid.1 $(EMMAN)/prid.1 + -cmp tabgen.1 $(EMMAN)/tabgen.1 + +clean: + rm -f *.o mkdep cid cclash prid tabgen + +pr: + @pr `pwd`/Makefile `pwd`/mkdep.c `pwd`/cclash.c `pwd`/cid.c \ + `pwd`/prid.c `pwd`/GCIPM.c `pwd`/tabgen.c + +opr: + make pr | opr + +mkdep: mkdep.o + $(CC) $(LDFLAGS) -o mkdep mkdep.o + +tabgen: tabgen.o + $(CC) $(LDFLAGS) -o tabgen tabgen.o + +cid: cid.o GCIPM.o + $(CC) $(LDFLAGS) -o cid cid.o GCIPM.o + +cclash: cclash.o GCIPM.o + $(CC) $(LDFLAGS) -o cclash cclash.o GCIPM.o + +prid: prid.o GCIPM.o + $(CC) $(LDFLAGS) -o prid prid.o GCIPM.o diff --git a/util/cpp/Version.c b/util/cpp/Version.c new file mode 100644 index 00000000..0a2ab69a --- /dev/null +++ b/util/cpp/Version.c @@ -0,0 +1,8 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef lint +static char Version[] = "ACK C preprocessor Version 1.3"; +#endif lint diff --git a/util/cpp/chtab.c b/util/cpp/chtab.c new file mode 100644 index 00000000..32e34997 --- /dev/null +++ b/util/cpp/chtab.c @@ -0,0 +1,321 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* + chtab - character table generator + + Author: Erik Baalbergen (..tjalk!erikb) + Modified by Ceriel Jacobs +*/ + +#include + +static char *RcsId = "$Header$"; + +#define MAXBUF 256 +#define TABSIZE 257 +#define COMCOM '-' +#define FILECOM '%' + +int InputForm = 'c'; +char OutputForm[MAXBUF] = "%s,\n"; +char *Table[TABSIZE]; +char *Name; +char *ProgCall; +int signedch = 0; +char *OutputName; +char *chroffsetfile = "charoffset.h"; + +main(argc, argv) + char *argv[]; +{ + char c = 0200; + int i = c; + + if (i < 0) signedch = 1; + + ProgCall = *argv++; + argc--; + while (argc-- > 0) { + if (**argv == COMCOM) { + option(*argv++); + } + else { + process(*argv++, InputForm); + } + } + MkCharIndex(); + exit(0); +} + +MkCharIndex() +{ + FILE *fp; + + if ((fp = fopen(chroffsetfile, "w")) == NULL) { + fprintf(stderr, "%s: cannot write file %s\n", ProgCall, chroffsetfile); + exit(1); + } + if (signedch) { + fputs("#define CharOffset 128\n", fp); + } + else fputs("#define CharOffset 0\n", fp); + fclose(fp); +} + +char * +Salloc(s) + char *s; +{ + char *malloc(); + char *ns = malloc(strlen(s) + 1); + + if (ns) { + strcpy(ns, s); + } + return ns; +} + +option(str) + char *str; +{ + /* note that *str indicates the source of the option: + either COMCOM (from command line) or FILECOM (from a file). + */ + switch (*++str) { + + case ' ': /* command */ + case '\t': + case '\0': + break; + case 'I': + InputForm = *++str; + break; + case 'f': + if (*++str == '\0') { + fprintf(stderr, "%s: -f: name expected\n", ProgCall); + exit(1); + } + DoFile(str); + break; + case 'F': + sprintf(OutputForm, "%s\n", ++str); + break; + case 'T': + printf("%s\n", ++str); + break; + case 'p': + PrintTable(); + break; + case 'C': + ClearTable(); + break; + case 'H': + if (*++str == '\0') { + fprintf(stderr, "%s: -H: name expected\n", ProgCall); + } + else chroffsetfile = ++str; + break; + default: + fprintf(stderr, "%s: bad option -%s\n", ProgCall, str); + } +} + +ClearTable() +{ + register i; + + for (i = 0; i < TABSIZE; i++) { + Table[i] = 0; + } +} + +PrintTable() +{ + register i; + + for (i = 0; i < TABSIZE; i++) { + if (Table[i]) { + printf(OutputForm, Table[i]); + } + else { + printf(OutputForm, "0"); + } + } +} + +process(str, format) + char *str; +{ + char *cstr = str; + char *Name = cstr; /* overwrite original string! */ + + /* strip of the entry name + */ + while (*str && *str != ':') { + if (*str == '\\') { + ++str; + } + *cstr++ = *str++; + } + + if (*str != ':') { + fprintf(stderr, "%s: bad specification: \"%s\", ignored\n", + ProgCall, Name); + return 0; + } + *cstr = '\0'; + str++; + + switch (format) { + + case 'c': + return c_proc(str, Name); + default: + fprintf(stderr, "%s: bad input format\n", ProgCall); + } + return 0; +} + +c_proc(str, Name) + char *str; + char *Name; +{ + int ch, ch2; + int quoted(); + char *name = Salloc(Name); + + while (*str) { + if (*str == '\\') { + ch = quoted(&str); + } + else { + ch = *str++; + } + if (*str == '-') { + if (*++str == '\\') { + ch2 = quoted(&str); + } + else { + if (ch2 = *str++); + else str--; + } + if (ch > ch2) { + fprintf(stderr, "%s: bad range\n", ProgCall); + return 0; + } +#define ind(X) (signedch?(X>=128?X-128:X+128):X) + while (ch <= ch2) { + Table[ind(ch)] = name; + ch++; + } + } + else { + if (ch >= 0 && ch <= 255) + Table[ind(ch)] = name; + } + } + Table[256] = Table[0]; + return 1; +} + +int +quoted(pstr) + char **pstr; +{ + register int ch; + register int i; + register char *str = *pstr; + + if ((*++str >= '0') && (*str <= '9')) { + ch = 0; + for (i = 0; i < 3; i++) { + ch = 8 * ch + (*str - '0'); + if (*++str < '0' || *str > '9') + break; + } + } + else { + switch (*str++) { + + case 'n': + ch = '\n'; + break; + case 't': + ch = '\t'; + break; + case 'b': + ch = '\b'; + break; + case 'r': + ch = '\r'; + break; + case 'f': + ch = '\f'; + break; + default : + ch = *str; + } + } + *pstr = str; + return ch & 0377; +} + +int +stoi(str) + char *str; +{ + register i = 0; + + while (*str >= '0' && *str <= '9') { + i = i * 10 + *str++ - '0'; + } + return i; +} + +char * +getline(s, n, fp) + char *s; + FILE *fp; +{ + register c = getc(fp); + char *str = s; + + while (n--) { + if (c == EOF) { + return NULL; + } + else + if (c == '\n') { + *str++ = '\0'; + return s; + } + *str++ = c; + c = getc(fp); + } + s[n - 1] = '\0'; + return s; +} + +#define BUFSIZE 1024 + +DoFile(name) + char *name; +{ + char text[BUFSIZE]; + FILE *fp; + + if ((fp = fopen(name, "r")) == NULL) { + fprintf(stderr, "%s: cannot read file %s\n", ProgCall, name); + exit(1); + } + while (getline(text, BUFSIZE, fp) != NULL) { + if (text[0] == FILECOM) { + option(text); + } + else { + process(text, InputForm); + } + } +} diff --git a/util/data/Makefile b/util/data/Makefile new file mode 100644 index 00000000..12a7dfb1 --- /dev/null +++ b/util/data/Makefile @@ -0,0 +1,40 @@ +# $Header$ +d=../.. +h=$d/h +l=$d/lib +AR=ar +SUF=o +LIBSUF=a + +OBJ=em_mnem.$(SUF) em_pseu.$(SUF) em_flag.$(SUF) em_ptyp.$(SUF) + +DATA_PATH=em_data.$(LIBSUF) + +CFLAGS=-O -I$h $(COPT) + +.SUFFIXES: .$(SUF) +.c.$(SUF): + $(CC) -c $(CFLAGS) $*.c + +$(DATA_PATH): $(OBJ) + $(AR) rv $(DATA_PATH) $(OBJ) + -sh -c 'ranlib $(DATA_PATH)' + +em_flag.$(SUF): $h/em_flag.h + +em_ptyp.$(SUF): $h/em_flag.h $h/em_ptyp.h + +install : $(DATA_PATH) + -cmp -s $(DATA_PATH) $l/$(DATA_PATH) || { cp $(DATA_PATH) $l/$(DATA_PATH) ; sh -c 'ranlib $l/$(DATA_PATH)' ; } + +cmp : $(DATA_PATH) + -cmp $(DATA_PATH) $l/$(DATA_PATH) + +clean: + rm -f $(OBJ) $(DATA_PATH) *.old + +opr: + make pr ^ opr + +pr: + @pr Makefile em_mnem.c em_pseu.c em_flag.c em_ptyp.c diff --git a/util/ego/bo/Makefile b/util/ego/bo/Makefile new file mode 100644 index 00000000..f037501c --- /dev/null +++ b/util/ego/bo/Makefile @@ -0,0 +1,79 @@ +EMHOME=../../.. +EMH=$(EMHOME)/h +EMLIB=$(EMHOME)/lib +SHR=../share + +LDFLAGS= +CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) +CFLAGS=$(CPPFLAGS) -O +LINTFLAGS=-hbu + +CFILES=\ +bo.c + +OFILES=\ +bo.o + +HFILES= + +PRFILES=\ +$(CFILES) $(HFILES) Makefile + +SHARE_OFILES=\ +$(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/debug.o \ +$(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/aux.o \ +$(SHR)/stack_chg.o $(SHR)/go.o + +SHARE_MFILES=\ +$(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/debug.m \ +$(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/aux.m \ +$(SHR)/stack_chg.m $(SHR)/go.m + +all: bo + +bo: $(OFILES) + $(CC) -o bo $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a + +bo_ack: $(CFILES) $(SHARE_MFILES) + $(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES) + $(CC) -o bo -.c $(LDFLAGS) bo.o $(EMLIB)/em_data.a + +install: all + ../install bo + +cmp: all + -../compare bo + +pr: + @pr $(PRFILES) + +opr: + make pr | opr + +clean: + rm -f bo *.o Out out nohup.out + +lint: + lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) + +print: $(PRFILES) + @pr $? + @touch print + +depend: + $(SHR)/makedepend + +# the next lines are generated automatically +# AUTOAUTOAUTOAUTOAUTOAUTO +bo.o: ../share/alloc.h +bo.o: ../share/aux.h +bo.o: ../share/debug.h +bo.o: ../share/def.h +bo.o: ../share/files.h +bo.o: ../share/get.h +bo.o: ../share/global.h +bo.o: ../share/go.h +bo.o: ../share/lset.h +bo.o: ../share/map.h +bo.o: ../share/put.h +bo.o: ../share/types.h diff --git a/util/ego/ca/Makefile b/util/ego/ca/Makefile new file mode 100644 index 00000000..d8cab707 --- /dev/null +++ b/util/ego/ca/Makefile @@ -0,0 +1,82 @@ +EMHOME=../../.. +EMH=$(EMHOME)/h +EMLIB=$(EMHOME)/lib +SHR=../share + +LDFLAGS= +CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) +CFLAGS=$(CPPFLAGS) -O +LINTFLAGS=-hbu + +CFILES=\ +ca.c ca_put.c + +OFILES=\ +ca.o ca_put.o + +HFILES=\ +ca.h ca_put.h + +PRFILES=\ +$(CFILES) $(HFILES) Makefile + +SHARE_OFILES=\ +$(SHR)/get.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/aux.o $(SHR)/debug.o \ +$(SHR)/lset.o $(SHR)/cset.o $(SHR)/files.o $(SHR)/map.o + +SHARE_MFILES=\ +$(SHR)/get.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/aux.m $(SHR)/debug.m \ +$(SHR)/lset.m $(SHR)/cset.m $(SHR)/files.m $(SHR)/map.m + +all: ca + +ca: $(OFILES) + $(CC) -o ca $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a + +ca_ack: $(CFILES) $(SHARE_MFILES) + $(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES) + $(CC) -o ca -.c $(LDFLAGS) ca.o $(EMLIB)/em_data.a + +install: all + ../install ca + +cmp: all + -../compare ca + +pr: + @pr $(PRFILES) + +opr: + make pr | opr + +clean: + rm -f ca *.o Out out nohup.out + +lint: + lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) + +print: $(PRFILES) + @pr $? + @touch print + +depend: + $(SHR)/makedepend + +# the next lines are generated automatically +# AUTOAUTOAUTOAUTOAUTOAUTO +ca.o: ../share/alloc.h +ca.o: ../share/debug.h +ca.o: ../share/files.h +ca.o: ../share/get.h +ca.o: ../share/global.h +ca.o: ../share/lset.h +ca.o: ../share/map.h +ca.o: ../share/types.h +ca.o: ca.h +ca.o: ca_put.h +ca_put.o: ../share/alloc.h +ca_put.o: ../share/debug.h +ca_put.o: ../share/def.h +ca_put.o: ../share/map.h +ca_put.o: ../share/types.h +ca_put.o: ca.h diff --git a/util/ego/cf/Makefile b/util/ego/cf/Makefile new file mode 100644 index 00000000..4a6236b3 --- /dev/null +++ b/util/ego/cf/Makefile @@ -0,0 +1,102 @@ +EMHOME=../../.. +EMH=$(EMHOME)/h +EMLIB=$(EMHOME)/lib +SHR=../share + +LDFLAGS= +CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) +CFLAGS=$(CPPFLAGS) -O +LINTFLAGS=-hbu + +CFILES=\ +cf.c cf_succ.c cf_idom.c cf_loop.c + +OFILES=\ +cf.o cf_idom.o cf_loop.o cf_succ.o + +HFILES=\ +cf.h cf_succ.h cf_idom.h cf_loop.h + +PRFILES=\ +$(CFILES) $(HFILES) Makefile + +SHARE_OFILES=\ +$(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o \ +$(SHR)/debug.o $(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o \ +$(SHR)/cset.o $(SHR)/aux.o + +SHARE_MFILES=\ +$(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m \ +$(SHR)/debug.m $(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m \ +$(SHR)/cset.m $(SHR)/aux.m + +all: cf + +cf: $(OFILES) + $(CC) -o cf $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a + +cf_ack: $(CFILES) $(SHARE_MFILES) + $(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES) + $(CC) -o cf -.c $(LDFLAGS) cf.o $(EMLIB)/em_data.a + +install: all + ../install cf + +cmp: all + -../compare cf + +pr: + @pr $(PRFILES) + +opr: + make pr | opr + +clean: + rm -f cf *.o Out out nohup.out + +lint: + lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) + +print: $(PRFILES) + @pr $? + @touch print + +depend: + $(SHR)/makedepend + +# the next lines are generated automatically +# AUTOAUTOAUTOAUTOAUTOAUTO +cf.o: ../share/alloc.h +cf.o: ../share/cset.h +cf.o: ../share/debug.h +cf.o: ../share/def.h +cf.o: ../share/files.h +cf.o: ../share/get.h +cf.o: ../share/global.h +cf.o: ../share/lset.h +cf.o: ../share/map.h +cf.o: ../share/put.h +cf.o: ../share/types.h +cf.o: cf.h +cf.o: cf_idom.h +cf.o: cf_loop.h +cf.o: cf_succ.h +cf_idom.o: ../share/alloc.h +cf_idom.o: ../share/debug.h +cf_idom.o: ../share/lset.h +cf_idom.o: ../share/types.h +cf_idom.o: cf.h +cf_loop.o: ../share/alloc.h +cf_loop.o: ../share/aux.h +cf_loop.o: ../share/debug.h +cf_loop.o: ../share/lset.h +cf_loop.o: ../share/types.h +cf_loop.o: cf.h +cf_succ.o: ../share/cset.h +cf_succ.o: ../share/debug.h +cf_succ.o: ../share/def.h +cf_succ.o: ../share/global.h +cf_succ.o: ../share/lset.h +cf_succ.o: ../share/map.h +cf_succ.o: ../share/types.h +cf_succ.o: cf.h diff --git a/util/ego/cj/Makefile b/util/ego/cj/Makefile new file mode 100644 index 00000000..30e5c026 --- /dev/null +++ b/util/ego/cj/Makefile @@ -0,0 +1,80 @@ +EMHOME=../../.. +EMH=$(EMHOME)/h +EMLIB=$(EMHOME)/lib +SHR=../share + +LDFLAGS= +CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) +CFLAGS=$(CPPFLAGS) -O +LINTFLAGS=-hbu + +CFILES=\ +cj.c + +OFILES=\ +cj.o + +HFILES= + +PRFILES=\ +$(CFILES) $(HFILES) Makefile + +SHARE_OFILES=\ +$(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/debug.o \ +$(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/aux.o \ +$(SHR)/stack_chg.o $(SHR)/go.o + +SHARE_MFILES=\ +$(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/debug.m \ +$(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/aux.m $(SHR)/stack_chg.m $(SHR)/go.m + +all: cj + +cj: $(OFILES) + $(CC) -o \ + cj $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a + +cj_ack: $(CFILES) $(SHARE_MFILES) + $(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES) + $(CC) -o cj -.c $(LDFLAGS) cj.o $(EMLIB)/em_data.a + +install: all + ../install cj + +cmp: all + -../compare cj + +pr: + @pr $(PRFILES) + +opr: + make pr | opr + +clean: + rm -f cj *.o Out out nohup.out + +lint: + lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) + +print: $(PRFILES) + @pr $? + @touch print + +depend: + $(SHR)/makedepend + +# the next lines are generated automatically +# AUTOAUTOAUTOAUTOAUTOAUTO +cj.o: ../share/alloc.h +cj.o: ../share/aux.h +cj.o: ../share/debug.h +cj.o: ../share/def.h +cj.o: ../share/files.h +cj.o: ../share/get.h +cj.o: ../share/global.h +cj.o: ../share/go.h +cj.o: ../share/lset.h +cj.o: ../share/map.h +cj.o: ../share/put.h +cj.o: ../share/stack_chg.h +cj.o: ../share/types.h diff --git a/util/ego/compare b/util/ego/compare new file mode 100755 index 00000000..774b4733 --- /dev/null +++ b/util/ego/compare @@ -0,0 +1,6 @@ +case $# in +1) DEST="$1" ;; +2) DEST="$2" ;; +*) echo $0 [source] destination ;; +esac +cmp "$1" ../../../lib/ego/$DEST diff --git a/util/ego/cs/Makefile b/util/ego/cs/Makefile new file mode 100644 index 00000000..523012e8 --- /dev/null +++ b/util/ego/cs/Makefile @@ -0,0 +1,190 @@ +EMHOME=../../.. +EMH=$(EMHOME)/h +EMLIB=$(EMHOME)/lib +SHR=../share + +LDFLAGS= +CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) +CFLAGS=$(CPPFLAGS) -O +LINTFLAGS=-hbu + +CFILES=\ +cs.c cs_alloc.c cs_aux.c cs_avail.c cs_debug.c cs_elim.c \ +cs_entity.c cs_kill.c cs_partit.c cs_profit.c cs_getent.c \ +cs_stack.c cs_vnm.c + +OFILES=\ +cs.o cs_alloc.o cs_aux.o cs_avail.o cs_debug.o cs_elim.o \ +cs_entity.o cs_kill.o cs_partit.o cs_profit.o cs_getent.o \ +cs_stack.o cs_vnm.o + +HFILES=\ +cs.h cs_alloc.h cs_aux.h cs_avail.h cs_debug.h cs_elim.h \ +cs_entity.h cs_kill.h cs_partit.h cs_profit.h cs_getent.h \ +cs_stack.h cs_vnm.h + +PRFILES=\ +$(CFILES) $(HFILES) Makefile + +SHARE_OFILES=\ +$(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/debug.o\ +$(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/aux.o\ +$(SHR)/go.o + +SHARE_MFILES=\ +$(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/debug.m\ +$(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/aux.m\ +$(SHR)/go.m + +all: cs + +cs: $(OFILES) + $(CC) -o cs $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a + +cs_ack: $(CFILES) $(SHARE_MFILES) + $(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES) + $(CC) -o cs -.c $(LDFLAGS) cs.o $(EMLIB)/em_data.a + +install: all + ../install cs + +cmp: all + -../compare cs + +pr: + @pr $(PRFILES) + +opr: + make pr | opr + +clean: + rm -f cs *.o Out out nohup.out + +lint: + lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) + +print: $(PRFILES) + @pr $? + @touch print + +depend: + $(SHR)/makedepend + +# the next lines are generated automatically +# AUTOAUTOAUTOAUTOAUTOAUTO +cs.o: ../share/debug.h +cs.o: ../share/go.h +cs.o: ../share/lset.h +cs.o: ../share/types.h +cs.o: cs.h +cs.o: cs_aux.h +cs.o: cs_avail.h +cs.o: cs_debug.h +cs.o: cs_elim.h +cs.o: cs_entity.h +cs.o: cs_profit.h +cs.o: cs_stack.h +cs.o: cs_vnm.h +cs_alloc.o: ../share/alloc.h +cs_alloc.o: ../share/types.h +cs_alloc.o: cs.h +cs_aux.o: ../share/aux.h +cs_aux.o: ../share/debug.h +cs_aux.o: ../share/global.h +cs_aux.o: ../share/lset.h +cs_aux.o: ../share/types.h +cs_aux.o: cs.h +cs_aux.o: cs_entity.h +cs_avail.o: ../share/aux.h +cs_avail.o: ../share/debug.h +cs_avail.o: ../share/global.h +cs_avail.o: ../share/lset.h +cs_avail.o: ../share/types.h +cs_avail.o: cs.h +cs_avail.o: cs_alloc.h +cs_avail.o: cs_aux.h +cs_avail.o: cs_debug.h +cs_avail.o: cs_getent.h +cs_debug.o: ../share/debug.h +cs_debug.o: ../share/lset.h +cs_debug.o: ../share/types.h +cs_debug.o: cs.h +cs_debug.o: cs_aux.h +cs_debug.o: cs_avail.h +cs_debug.o: cs_entity.h +cs_elim.o: ../share/alloc.h +cs_elim.o: ../share/aux.h +cs_elim.o: ../share/debug.h +cs_elim.o: ../share/global.h +cs_elim.o: ../share/lset.h +cs_elim.o: ../share/types.h +cs_elim.o: cs.h +cs_elim.o: cs_alloc.h +cs_elim.o: cs_aux.h +cs_elim.o: cs_avail.h +cs_elim.o: cs_debug.h +cs_elim.o: cs_partit.h +cs_elim.o: cs_profit.h +cs_entity.o: ../share/debug.h +cs_entity.o: ../share/global.h +cs_entity.o: ../share/lset.h +cs_entity.o: ../share/types.h +cs_entity.o: cs.h +cs_entity.o: cs_alloc.h +cs_entity.o: cs_aux.h +cs_getent.o: ../share/aux.h +cs_getent.o: ../share/debug.h +cs_getent.o: ../share/global.h +cs_getent.o: ../share/types.h +cs_getent.o: cs.h +cs_getent.o: cs_aux.h +cs_getent.o: cs_entity.h +cs_getent.o: cs_stack.h +cs_kill.o: ../share/aux.h +cs_kill.o: ../share/cset.h +cs_kill.o: ../share/debug.h +cs_kill.o: ../share/global.h +cs_kill.o: ../share/lset.h +cs_kill.o: ../share/map.h +cs_kill.o: ../share/types.h +cs_kill.o: cs.h +cs_kill.o: cs_aux.h +cs_kill.o: cs_avail.h +cs_kill.o: cs_debug.h +cs_kill.o: cs_entity.h +cs_partit.o: ../share/aux.h +cs_partit.o: ../share/debug.h +cs_partit.o: ../share/global.h +cs_partit.o: ../share/types.h +cs_partit.o: cs.h +cs_partit.o: cs_stack.h +cs_profit.o: ../share/aux.h +cs_profit.o: ../share/cset.h +cs_profit.o: ../share/debug.h +cs_profit.o: ../share/global.h +cs_profit.o: ../share/lset.h +cs_profit.o: ../share/types.h +cs_profit.o: cs.h +cs_profit.o: cs_aux.h +cs_profit.o: cs_avail.h +cs_profit.o: cs_debug.h +cs_profit.o: cs_partit.h +cs_stack.o: ../share/aux.h +cs_stack.o: ../share/debug.h +cs_stack.o: ../share/global.h +cs_stack.o: ../share/types.h +cs_stack.o: cs.h +cs_stack.o: cs_aux.h +cs_vnm.o: ../share/aux.h +cs_vnm.o: ../share/debug.h +cs_vnm.o: ../share/global.h +cs_vnm.o: ../share/types.h +cs_vnm.o: cs.h +cs_vnm.o: cs_alloc.h +cs_vnm.o: cs_aux.h +cs_vnm.o: cs_avail.h +cs_vnm.o: cs_entity.h +cs_vnm.o: cs_getent.h +cs_vnm.o: cs_kill.h +cs_vnm.o: cs_partit.h +cs_vnm.o: cs_stack.h diff --git a/util/ego/descr/Makefile b/util/ego/descr/Makefile new file mode 100644 index 00000000..ca4d3b6d --- /dev/null +++ b/util/ego/descr/Makefile @@ -0,0 +1,66 @@ +EMHOME=../../.. +EMH=$(EMHOME)/h +EMLIB=$(EMHOME)/lib +SHARE=../share +CPP=$(EMLIB)/cpp + +LDFLAGS= +CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) +CFLAGS=$(CPPFLAGS) -O +LINTFLAGS=-hbu + +SOURCES = i86.descr m68k2.descr pdp.descr vax4.descr m68k4.descr m68020.descr \ + em22.descr em24.descr em44.descr + +TARGETS = i86descr m68k2descr vax4descr pdpdescr m68k4descr m68020descr \ + em22descr em24descr em44descr + +PRFILES = Makefile descr.sed $(SOURCES) + +all: $(TARGETS) + +install: all + for i in $(TARGETS) ; do ../install $$i ; done + +cmp: all + -for i in $(TARGETS) ; do ../compare $$i ; done + +pr: + @pr $(PRFILES) + +opr: + make pr | opr + +clean: + rm -f $(TARGETS) *.o Out out nohup.out + +i86descr: i86.descr descr.sed + $(CPP) -P -I$(EMH) i86.descr | sed -f descr.sed > i86descr + +pdpdescr: pdp.descr descr.sed + $(CPP) -P -I$(EMH) pdp.descr | sed -f descr.sed > pdpdescr + +m68k2descr: m68k2.descr descr.sed + $(CPP) -P -I$(EMH) m68k2.descr | sed -f descr.sed > m68k2descr + +m68k4descr: m68k4.descr descr.sed + $(CPP) -P -I$(EMH) m68k4.descr | sed -f descr.sed > m68k4descr + +m68020descr: m68020.descr descr.sed + $(CPP) -P -I$(EMH) m68020.descr | sed -f descr.sed > m68020descr + +vax4descr: vax4.descr descr.sed + $(CPP) -P -I$(EMH) vax4.descr | sed -f descr.sed > vax4descr + +em22descr: em22.descr descr.sed + $(CPP) -P -I$(EMH) em22.descr | sed -f descr.sed > em22descr + +em24descr: em24.descr descr.sed + $(CPP) -P -I$(EMH) em24.descr | sed -f descr.sed > em24descr + +em44descr: em44.descr descr.sed + $(CPP) -P -I$(EMH) em44.descr | sed -f descr.sed > em44descr + +sparcdescr: sparc.descr descr.sed + $(CPP) -P -I$(EMH) sparc.descr | sed -f descr.sed > sparcdescr + diff --git a/util/ego/descr/vax2.descr b/util/ego/descr/vax2.descr new file mode 100644 index 00000000..8dfc9ace --- /dev/null +++ b/util/ego/descr/vax2.descr @@ -0,0 +1,117 @@ +wordsize: 2 +pointersize: 4 +%%RA +general registers: 3 +address registers: 4 +floating point registers: 0 + +register score parameters: + local variable: + (2 cases) + pointer,pointer + (2 sizes) + fitbyte -> (5,2) + default -> (4,3) + general,general + (2 sizes) + fitbyte -> (3,1) + default -> (2,2) + address of local variable: + (2 cases) + pointer,pointer + (2 sizes) + fitbyte -> (0,1) + default -> (0,2) + general,pointer + (2 sizes) + fitbyte -> (0,1) + default -> (0,2) + constant: + (3 sizes) + in_0_63 -> (0,0) + fitbyte -> (0,1) + default -> (1,2) + double constant: + (1 size) + default -> (-1,-1) + address of global variable: + (1 size) + default -> (2,4) + address of procedure: + (1 size) + default -> (2,4) + +opening cost parameters: + local variable: + (2 cases) + pointer + (2 sizes) + fitbyte -> (10,4) + default -> (9,5) + general + (2 sizes) + fitbyte -> (8,4) + default -> (7,5) + address of local variable: + (2 cases) + pointer + (2 sizes) + fitbyte -> (0,4) + default -> (0,5) + general + (2 sizes) + fitbyte -> (0,4) + general -> (0,5) + constant: + (3 sizes) + in_0_63 -> (4,2) + fitbyte -> (5,3) + default -> (6,4) + double constant: + (1 size) + default -> (1000,1000) + address of global variable: + (1 size) + default -> (6,7) + address of procedure: + (1 size) + default -> (6,7) + +register save costs: + (9 cases) + 0 -> (0,0) + 1 -> (1,0) + 2 -> (2,0) + 3 -> (3,0) + 4 -> (4,0) + 5 -> (5,0) + 6 -> (6,0) + 7 -> (7,0) + 0 -> (0,0) +%%UD +access costs of global variables: + (1 size) + default -> (7,4) +access costs of local variables: + (2 sizes) + fitbyte -> (3,1) + default -> (2,2) +%%SR +overflow harmful?: no +array bound harmful?: no + +%%CS +#include "../../../h/em_mnem.h" +first time then space: +addressing modes: op_adp op_lof op_ldf op_loi op_dch op_lpb -1 + op_adp op_lof op_ldf op_loi op_dch op_lpb -1 +cheap operations: op_cii op_cui op_cfi op_ciu op_cff op_cuu op_cif + op_cmi op_cmf op_cmu op_cms op_cmp -1 + op_cii op_cui op_cfi op_ciu op_cff op_cuu op_cif + op_cmi op_cmf op_cmu op_cms op_cmp -1 +lexical tresholds: 1 1 +indirection limit: 8 +do sli if index?: no no +forbidden operators: -1 -1 +%%SP +global stack pollution allowed?: yes diff --git a/util/ego/em_ego/Makefile b/util/ego/em_ego/Makefile new file mode 100644 index 00000000..e615b9be --- /dev/null +++ b/util/ego/em_ego/Makefile @@ -0,0 +1,36 @@ +EMHOME=../../.. +EMH=$(EMHOME)/h +EMLIB=$(EMHOME)/lib +MODLIB=$(EMHOME)/modules/lib +MODH=$(EMHOME)/modules/h +SHARE=../share +MODS=$(MODLIB)/libprint.a $(MODLIB)/libstring.a $(MODLIB)/libsystem.a + +LDFLAGS= +CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(MODH) +CFLAGS=$(CPPFLAGS) -O +LINTFLAGS=-hbu + +all: em_ego + +em_ego: em_ego.o + $(CC) $(LDFLAGS) -o em_ego em_ego.o $(MODS) + +install: all + rm -f $(EMLIB)/em_ego + cp em_ego $(EMLIB)/em_ego + +cmp: all + -cmp em_ego $(EMLIB)/em_ego + +pr: + @pr em_ego.c + +opr: + make pr | opr + +lint: + lint $(LINTFLAGS) $(CPPFLAGS) em_ego.c + +clean: + rm -f *.o em_ego diff --git a/util/ego/em_ego/em_ego b/util/ego/em_ego/em_ego new file mode 100755 index 00000000..32ac0abd --- /dev/null +++ b/util/ego/em_ego/em_ego @@ -0,0 +1,91 @@ +TMP=/usr/tmp/ego +DDUMP=$TMP.dd.$$ +PDUMP=$TMP.pd.$$ +PHASES='' +FLAGS='' +LEVEL=xxx +EM=$1 +KEEPTEMPS=no +shift + + +while : +do + case $# in + 0) break ;; + esac + A="$1" + shift + case $A in + *.m|*.ma) ICARG="$ICARG $A"; continue;; + -P) OPT="$1"; shift; continue;; + -IL) PHASES="$PHASES il cf caopt ic cf " ; continue;; + -CS) PHASES="$PHASES cs " ; continue;; + -SR) PHASES="$PHASES sr " ; continue;; + -UD) PHASES="$PHASES ud " ; continue;; + -LV) PHASES="$PHASES lv " ; continue;; + -RA) PHASES="$PHASES ra " ; continue;; + -SP) PHASES="$PHASES sp " ; continue;; + -BO) PHASES="$PHASES bo " ; continue;; + -CJ) PHASES="$PHASES cj " ; continue;; + -O*) LEVEL=$A ; continue;; + -t) KEEPTEMPS=yes ; continue;; + -*) FLAGS="$FLAGS $A"; continue;; + esac +done +if test "$PHASES" +then : +else + case $LEVEL in + -O2|-O|xxx)PHASES='cj bo sp ' ;; + -O3) PHASES='cs sr cj bo sp ud lv ra ' ;; + *) PHASES='il cf caopt ic cf cs sr cj bo sp ud lv ra ' ;; + esac +fi +TMPOPT=$TMP.o.$$ +PASSES="ic cf $PHASES ca" +OUTFILES="$PDUMP $DDUMP" +FILES="$OUTFILES $TMPOPT" +c=1 +if test "$ICARG" +then : +else +exit 0 +fi +for i in $PASSES +do INFILES=$OUTFILES + OUTFILES="$TMP.p.$c.$$ $TMP.d.$c.$$ $TMP.l.$c.$$ $TMP.b.$c.$$" + FILES="$FILES $OUTFILES" + if [ $KEEPTEMPS = no ] + then + trap "rm -f $FILES; exit 1" 0 1 2 15 + fi + case $i in + ic) $OPT/ic $INFILES - - $OUTFILES $ICARG || exit 1 + ;; + ca) $OPT/ca $INFILES $PDUMP $DDUMP - - || exit 1 + ;; + caopt) rm -f $TMPOPT + $OPT/ca $INFILES $PDUMP $DDUMP - - | $EM/lib/em_opt2 > $TMPOPT || exit 1 + ICARG=$TMPOPT + OUTFILES="$PDUMP $DDUMP" + if [ $KEEPTEMPS = no ] + then + rm -f $INFILES $PDUMP $DDUMP + fi + ;; + *) $OPT/$i $INFILES $OUTFILES $FLAGS || exit 1 + if [ $KEEPTEMPS = no ] + then + rm -f $INFILES + fi + ;; + esac + c=`expr $c + 1` +done +if [ $KEEPTEMPS = no ] +then + rm -f $FILES +fi +trap 0 +exit 0 diff --git a/util/ego/ic/Makefile b/util/ego/ic/Makefile new file mode 100644 index 00000000..15ad00e0 --- /dev/null +++ b/util/ego/ic/Makefile @@ -0,0 +1,110 @@ +EMHOME=../../.. +EMH=$(EMHOME)/h +EMLIB=$(EMHOME)/lib +SHR=../share + +LDFLAGS= +CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) +CFLAGS=$(CPPFLAGS) -O +LINTFLAGS=-hbu + +CFILES=\ +ic.c ic_aux.c ic_lib.c ic_lookup.c ic_io.c + +OFILES=\ +ic.o ic_aux.o ic_lookup.o ic_io.o ic_lib.o + +HFILES=\ +ic.h ic_aux.h ic_lib.h ic_lookup.h ic_io.h + +PRFILES=\ +$(CFILES) $(HFILES) Makefile + +SHARE_OFILES=\ +$(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/debug.o \ +$(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/aux.o + +SHARE_MFILES=\ +$(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/debug.m \ +$(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/aux.m + +all: ic + +ic: $(OFILES) + $(CC) -o ic $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a + +ic_ack: $(CFILES) $(SHARE_MFILES) + $(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES) + $(CC) -o ic -.c $(LDFLAGS) ic.o $(EMLIB)/em_data.a + +install: all + ../install ic + +cmp: all + -../compare ic + +clean: + rm -f *.o ic Out out nohup.out + +lint: + lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) + +print: $(PRFILES) + @pr $? + @touch print + +pr: + @pr $(PRFILES) + +opr: + make pr | opr + +depend: + $(SHR)/makedepend + +# the next lines are generated automatically +# AUTOAUTOAUTOAUTOAUTOAUTO +ic.o: ../share/alloc.h +ic.o: ../share/aux.h +ic.o: ../share/debug.h +ic.o: ../share/def.h +ic.o: ../share/files.h +ic.o: ../share/global.h +ic.o: ../share/map.h +ic.o: ../share/put.h +ic.o: ../share/types.h +ic.o: ic.h +ic.o: ic_aux.h +ic.o: ic_io.h +ic.o: ic_lib.h +ic.o: ic_lookup.h +ic_aux.o: ../share/alloc.h +ic_aux.o: ../share/aux.h +ic_aux.o: ../share/debug.h +ic_aux.o: ../share/def.h +ic_aux.o: ../share/global.h +ic_aux.o: ../share/types.h +ic_aux.o: ic.h +ic_aux.o: ic_aux.h +ic_aux.o: ic_io.h +ic_aux.o: ic_lookup.h +ic_io.o: ../share/alloc.h +ic_io.o: ../share/debug.h +ic_io.o: ../share/types.h +ic_io.o: ic.h +ic_io.o: ic_io.h +ic_io.o: ic_lookup.h +ic_lib.o: ../share/debug.h +ic_lib.o: ../share/files.h +ic_lib.o: ../share/global.h +ic_lib.o: ../share/types.h +ic_lib.o: ic.h +ic_lib.o: ic_io.h +ic_lib.o: ic_lib.h +ic_lib.o: ic_lookup.h +ic_lookup.o: ../share/alloc.h +ic_lookup.o: ../share/debug.h +ic_lookup.o: ../share/map.h +ic_lookup.o: ../share/types.h +ic_lookup.o: ic.h +ic_lookup.o: ic_lookup.h diff --git a/util/ego/il/Makefile b/util/ego/il/Makefile new file mode 100644 index 00000000..20ee2aa5 --- /dev/null +++ b/util/ego/il/Makefile @@ -0,0 +1,175 @@ +EMHOME=../../.. +EMH=$(EMHOME)/h +EMLIB=$(EMHOME)/lib +SHR=../share + +LDFLAGS= +CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) +CFLAGS=$(CPPFLAGS) -O +LINTFLAGS=-hbu + +CFILES=\ +il.c il1_anal.c il1_cal.c il1_formal.c il1_aux.c il2_aux.c \ +il3_subst.c il3_change.c il3_aux.c il_aux.c + +OFILES=\ +il.o il1_anal.o il1_cal.o il1_formal.o il1_aux.o il2_aux.o \ +il3_change.o il3_subst.o il3_aux.o il_aux.o + +HFILES=\ +il.h il1_anal.h il1_cal.h il1_formal.h il1_aux.h il2_aux.h \ +il3_subst.h il3_change.h il3_aux.h il_aux.h + +PRFILES=\ +$(CFILES) $(HFILES) Makefile + +SHARE_OFILES=\ +$(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/debug.o \ +$(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/parser.o \ +$(SHR)/aux.o $(SHR)/go.o + +SHARE_MFILES=\ +$(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/debug.m \ +$(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/parser.m \ +$(SHR)/aux.m $(SHR)/go.m + +all: il + +il: $(OFILES) + $(CC) -o il $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a + +il_ack: $(CFILES) $(SHARE_MFILES) + $(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES) + $(CC) -o il -.c $(LDFLAGS) il.o $(EMLIB)/em_data.a + +install: all + ../install il + +cmp: all + -../compare il + +pr: + @pr $(PRFILES) + +opr: + make pr | opr + +clean: + rm -f il *.o Out out nohup.out + +lint: + lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) + +print: $(PRFILES) + @pr $? + @touch print + +depend: + $(SHR)/makedepend + +# the next lines are generated automatically +# AUTOAUTOAUTOAUTOAUTOAUTO +il.o: ../share/alloc.h +il.o: ../share/debug.h +il.o: ../share/files.h +il.o: ../share/get.h +il.o: ../share/global.h +il.o: ../share/go.h +il.o: ../share/lset.h +il.o: ../share/map.h +il.o: ../share/put.h +il.o: ../share/types.h +il.o: il.h +il.o: il1_anal.h +il.o: il2_aux.h +il.o: il3_subst.h +il.o: il_aux.h +il1_anal.o: ../share/alloc.h +il1_anal.o: ../share/aux.h +il1_anal.o: ../share/debug.h +il1_anal.o: ../share/global.h +il1_anal.o: ../share/lset.h +il1_anal.o: ../share/put.h +il1_anal.o: ../share/types.h +il1_anal.o: il.h +il1_anal.o: il1_anal.h +il1_anal.o: il1_aux.h +il1_anal.o: il1_cal.h +il1_anal.o: il1_formal.h +il1_anal.o: il_aux.h +il1_aux.o: ../share/alloc.h +il1_aux.o: ../share/debug.h +il1_aux.o: ../share/global.h +il1_aux.o: ../share/lset.h +il1_aux.o: ../share/types.h +il1_aux.o: il.h +il1_aux.o: il1_aux.h +il1_aux.o: il_aux.h +il1_cal.o: ../share/alloc.h +il1_cal.o: ../share/debug.h +il1_cal.o: ../share/global.h +il1_cal.o: ../share/lset.h +il1_cal.o: ../share/parser.h +il1_cal.o: ../share/types.h +il1_cal.o: il.h +il1_cal.o: il1_aux.h +il1_cal.o: il1_cal.h +il1_formal.o: ../share/alloc.h +il1_formal.o: ../share/debug.h +il1_formal.o: ../share/global.h +il1_formal.o: ../share/lset.h +il1_formal.o: ../share/types.h +il1_formal.o: il.h +il1_formal.o: il1_aux.h +il1_formal.o: il1_formal.h +il2_aux.o: ../share/alloc.h +il2_aux.o: ../share/aux.h +il2_aux.o: ../share/debug.h +il2_aux.o: ../share/get.h +il2_aux.o: ../share/global.h +il2_aux.o: ../share/lset.h +il2_aux.o: ../share/types.h +il2_aux.o: il.h +il2_aux.o: il2_aux.h +il2_aux.o: il_aux.h +il3_aux.o: ../share/alloc.h +il3_aux.o: ../share/debug.h +il3_aux.o: ../share/global.h +il3_aux.o: ../share/types.h +il3_aux.o: il.h +il3_aux.o: il3_aux.h +il3_aux.o: il_aux.h +il3_change.o: ../share/alloc.h +il3_change.o: ../share/aux.h +il3_change.o: ../share/debug.h +il3_change.o: ../share/def.h +il3_change.o: ../share/get.h +il3_change.o: ../share/global.h +il3_change.o: ../share/lset.h +il3_change.o: ../share/put.h +il3_change.o: ../share/types.h +il3_change.o: il.h +il3_change.o: il3_aux.h +il3_change.o: il3_change.h +il3_change.o: il_aux.h +il3_subst.o: ../share/alloc.h +il3_subst.o: ../share/debug.h +il3_subst.o: ../share/get.h +il3_subst.o: ../share/global.h +il3_subst.o: ../share/lset.h +il3_subst.o: ../share/types.h +il3_subst.o: il.h +il3_subst.o: il3_aux.h +il3_subst.o: il3_change.h +il3_subst.o: il3_subst.h +il3_subst.o: il_aux.h +il_aux.o: ../share/alloc.h +il_aux.o: ../share/debug.h +il_aux.o: ../share/get.h +il_aux.o: ../share/global.h +il_aux.o: ../share/lset.h +il_aux.o: ../share/map.h +il_aux.o: ../share/put.h +il_aux.o: ../share/types.h +il_aux.o: il.h +il_aux.o: il_aux.h diff --git a/util/ego/install b/util/ego/install new file mode 100755 index 00000000..02ced829 --- /dev/null +++ b/util/ego/install @@ -0,0 +1,16 @@ +case $# in +1) DEST="$1" ;; +2) DEST="$2" ;; +*) echo $0 [source] destination ;; +esac +mkdir ../../../lib/ego > /dev/null 2>&1 +if cp "$1" ../../../lib/ego/$DEST >/dev/null 2>&1 || + { rm -f ../../../lib/ego/$DEST >/dev/null 2>&1 && + cp "$1" ../../../lib/ego/$DEST >/dev/null 2>&1 + } +then + exit 0 +else + echo Sorry, can not create "lib/ego/$DEST". + exit 1 +fi diff --git a/util/ego/lv/Makefile b/util/ego/lv/Makefile new file mode 100644 index 00000000..5777404a --- /dev/null +++ b/util/ego/lv/Makefile @@ -0,0 +1,85 @@ +EMHOME=../../.. +EMH=$(EMHOME)/h +EMLIB=$(EMHOME)/lib +SHR=../share + +LDFLAGS= +CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) +CFLAGS=$(CPPFLAGS) -O +LINTFLAGS=-hbu + +CFILES=\ +lv.c + +OFILES=\ +lv.o + +HFILES=\ +lv.h + +PRFILES=\ +$(CFILES) $(HFILES) Makefile + +SHARE_OFILES=\ +$(SHR)/get.o $(SHR)/aux.o $(SHR)/put.o $(SHR)/map.o $(SHR)/alloc.o \ +$(SHR)/global.o $(SHR)/debug.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/parser.o \ +$(SHR)/files.o $(SHR)/locals.o $(SHR)/init_glob.o $(SHR)/go.o + +SHARE_MFILES=\ +$(SHR)/get.m $(SHR)/aux.m $(SHR)/put.m $(SHR)/map.m $(SHR)/alloc.m \ +$(SHR)/global.m $(SHR)/debug.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/parser.m \ +$(SHR)/files.m $(SHR)/locals.m $(SHR)/init_glob.m $(SHR)/go.m + +all: lv + +lv: $(OFILES) + $(CC) -o lv $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a + +lv_ack: $(CFILES) $(SHARE_MFILES) + $(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES) + $(CC) -o lv -.c $(LDFLAGS) lv.o $(EMLIB)/em_data.a + +install: all + ../install lv + +cmp: all + -../compare lv + +pr: + @pr $(PRFILES) + +opr: + make pr | opr + +clean: + rm -f lv *.o Out out nohup.out + +lint: + lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) + +print: $(PRFILES) + @pr $? + @touch print + +depend: + $(SHR)/makedepend + +# the next lines are generated automatically +# AUTOAUTOAUTOAUTOAUTOAUTO +lv.o: ../share/alloc.h +lv.o: ../share/aux.h +lv.o: ../share/cset.h +lv.o: ../share/debug.h +lv.o: ../share/def.h +lv.o: ../share/files.h +lv.o: ../share/get.h +lv.o: ../share/global.h +lv.o: ../share/go.h +lv.o: ../share/init_glob.h +lv.o: ../share/locals.h +lv.o: ../share/lset.h +lv.o: ../share/map.h +lv.o: ../share/parser.h +lv.o: ../share/put.h +lv.o: ../share/types.h +lv.o: lv.h diff --git a/util/ego/ra/Makefile b/util/ego/ra/Makefile new file mode 100644 index 00000000..43443ad0 --- /dev/null +++ b/util/ego/ra/Makefile @@ -0,0 +1,173 @@ +EMHOME=../../.. +EMH=$(EMHOME)/h +EMLIB=$(EMHOME)/lib +SHR=../share + +LDFLAGS= +CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) +CFLAGS=$(CPPFLAGS) -O +LINTFLAGS=-hbu + +CFILES=\ +ra.c ra_items.c ra_lifet.c ra_allocl.c ra_profits.c \ +ra_interv.c ra_pack.c ra_xform.c ra_aux.c + +OFILES=\ +ra.o ra_items.o ra_lifet.o ra_allocl.o ra_profits.o \ +ra_interv.o ra_pack.o ra_xform.o ra_aux.o + +HFILES=\ +ra.h ra_items.h ra_lifet.h ra_allocl.h ra_profits.h \ +ra_interv.h ra_pack.h ra_xform.h ra_aux.h + +PRFILES=\ +$(CFILES) $(HFILES) Makefile + +SHARE_OFILES=\ +$(SHR)/aux.o $(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o \ +$(SHR)/debug.o $(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o \ +$(SHR)/go.o + +SHARE_MFILES=\ +$(SHR)/aux.m $(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m \ +$(SHR)/debug.m $(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m \ +$(SHR)/go.m + +all: ra + +ra: $(OFILES) + $(CC) -o ra $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a + +ra_ack: $(CFILES) $(SHARE_MFILES) + $(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES) + $(CC) -o ra -.c $(LDFLAGS) ra.o $(EMLIB)/em_data.a + +itemtab.h: itemtab.src makeitems $(EMH)/em_mnem.h + makeitems $(EMH)/em_mnem.h itemtab.src > itemtab.h + +makeitems: makeitems.c + $(CC) -o makeitems makeitems.c + +install: all + ../install ra + +cmp: all + -../compare ra + +pr: + @pr $(PRFILES) + +opr: + make pr | opr + +clean: + rm -f ra makeitems itemtab.h *.o Out out nohup.out + +lint: + lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) + +print: $(PRFILES) + @pr $? + @touch print + +depend: + $(SHR)/makedepend + +# the next lines are generated automatically +# AUTOAUTOAUTOAUTOAUTOAUTO +ra.o: ../share/alloc.h +ra.o: ../share/debug.h +ra.o: ../share/files.h +ra.o: ../share/get.h +ra.o: ../share/global.h +ra.o: ../share/go.h +ra.o: ../share/lset.h +ra.o: ../share/map.h +ra.o: ../share/put.h +ra.o: ../share/types.h +ra.o: ra.h +ra.o: ra_allocl.h +ra.o: ra_items.h +ra.o: ra_pack.h +ra.o: ra_profits.h +ra.o: ra_xform.h +ra_allocl.o: ../share/alloc.h +ra_allocl.o: ../share/aux.h +ra_allocl.o: ../share/cset.h +ra_allocl.o: ../share/debug.h +ra_allocl.o: ../share/def.h +ra_allocl.o: ../share/global.h +ra_allocl.o: ../share/lset.h +ra_allocl.o: ../share/map.h +ra_allocl.o: ../share/types.h +ra_allocl.o: ra.h +ra_allocl.o: ra_allocl.h +ra_allocl.o: ra_aux.h +ra_allocl.o: ra_interv.h +ra_allocl.o: ra_items.h +ra_aux.o: ../share/alloc.h +ra_aux.o: ../share/debug.h +ra_aux.o: ../share/def.h +ra_aux.o: ../share/global.h +ra_aux.o: ../share/lset.h +ra_aux.o: ../share/types.h +ra_aux.o: ra.h +ra_aux.o: ra_aux.h +ra_interv.o: ../share/alloc.h +ra_interv.o: ../share/debug.h +ra_interv.o: ../share/global.h +ra_interv.o: ../share/lset.h +ra_interv.o: ../share/types.h +ra_interv.o: ra.h +ra_interv.o: ra_interv.h +ra_items.o: ../share/alloc.h +ra_items.o: ../share/aux.h +ra_items.o: ../share/debug.h +ra_items.o: ../share/def.h +ra_items.o: ../share/global.h +ra_items.o: ../share/lset.h +ra_items.o: ../share/types.h +ra_items.o: itemtab.h +ra_items.o: ra.h +ra_items.o: ra_aux.h +ra_items.o: ra_items.h +ra_lifet.o: ../share/alloc.h +ra_lifet.o: ../share/aux.h +ra_lifet.o: ../share/debug.h +ra_lifet.o: ../share/def.h +ra_lifet.o: ../share/global.h +ra_lifet.o: ../share/lset.h +ra_lifet.o: ../share/types.h +ra_lifet.o: ra.h +ra_lifet.o: ra_aux.h +ra_lifet.o: ra_items.h +ra_lifet.o: ra_lifet.h +ra_pack.o: ../share/alloc.h +ra_pack.o: ../share/aux.h +ra_pack.o: ../share/cset.h +ra_pack.o: ../share/debug.h +ra_pack.o: ../share/def.h +ra_pack.o: ../share/global.h +ra_pack.o: ../share/lset.h +ra_pack.o: ../share/types.h +ra_pack.o: ra.h +ra_pack.o: ra_aux.h +ra_pack.o: ra_interv.h +ra_profits.o: ../share/debug.h +ra_profits.o: ../share/global.h +ra_profits.o: ../share/lset.h +ra_profits.o: ../share/types.h +ra_profits.o: ra.h +ra_profits.o: ra_aux.h +ra_profits.o: ra_profits.h +ra_xform.o: ../share/alloc.h +ra_xform.o: ../share/aux.h +ra_xform.o: ../share/debug.h +ra_xform.o: ../share/def.h +ra_xform.o: ../share/global.h +ra_xform.o: ../share/lset.h +ra_xform.o: ../share/types.h +ra_xform.o: ra.h +ra_xform.o: ra_interv.h +ra_xform.o: ra_items.h +ra_xform.o: ra_xform.h diff --git a/util/ego/share/makedepend b/util/ego/share/makedepend new file mode 100755 index 00000000..733f55b6 --- /dev/null +++ b/util/ego/share/makedepend @@ -0,0 +1,11 @@ +for file in *.c +do ofile=`basename $file .c`.o + grep '^# *include.*"' $file|sed "s/.*\"\(.*\)\".*/$ofile: \1/" +done | sort -u >depend +ed - Makefile <<'!' +/AUTOAUTOAUTO/+,$d +$r depend +w +q +! +rm depend diff --git a/util/ego/share/makewlen.c b/util/ego/share/makewlen.c new file mode 100644 index 00000000..61ae1090 --- /dev/null +++ b/util/ego/share/makewlen.c @@ -0,0 +1,10 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +main() +{ + printf("#define WORDLENGTH %d\n",sizeof(int) * 8); + exit(0); +} diff --git a/util/ego/sp/Makefile b/util/ego/sp/Makefile new file mode 100644 index 00000000..d6bb4a50 --- /dev/null +++ b/util/ego/sp/Makefile @@ -0,0 +1,79 @@ +EMHOME=../../.. +EMH=$(EMHOME)/h +EMLIB=$(EMHOME)/lib +SHR=../share + +LDFLAGS= +CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) +CFLAGS=$(CPPFLAGS) -O +LINTFLAGS=-hbu + +CFILES=\ +sp.c + +OFILES=\ +sp.o + +HFILES= + +PRFILES=\ +$(CFILES) $(HFILES) Makefile + +SHARE_OFILES=\ +$(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/debug.o \ +$(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/aux.o \ +$(SHR)/stack_chg.o $(SHR)/go.o + +SHARE_MFILES=\ +$(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/debug.m \ +$(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/aux.m \ +$(SHR)/stack_chg.m $(SHR)/go.m + +all: sp + +sp: $(OFILES) + $(CC) -o sp $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a + +sp_ack: $(CFILES) $(SHARE_MFILES) + $(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES) + $(CC) -o sp -.c $(LDFLAGS) sp.o $(EMLIB)/em_data.a + +install: all + ../install sp + +cmp: all + -../compare sp + +pr: + @pr $(PRFILES) + +opr: + make pr | opr + +clean: + rm -f sp *.o Out out nohup.out + +lint: + lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) + +print: $(PRFILES) + @pr $? + @touch print + +depend: + $(SHR)/makedepend + +# the next lines are generated automatically +# AUTOAUTOAUTOAUTOAUTOAUTO +sp.o: ../share/alloc.h +sp.o: ../share/aux.h +sp.o: ../share/debug.h +sp.o: ../share/files.h +sp.o: ../share/get.h +sp.o: ../share/global.h +sp.o: ../share/go.h +sp.o: ../share/lset.h +sp.o: ../share/map.h +sp.o: ../share/put.h +sp.o: ../share/stack_chg.h +sp.o: ../share/types.h diff --git a/util/ego/sr/Makefile b/util/ego/sr/Makefile new file mode 100644 index 00000000..5d1d62eb --- /dev/null +++ b/util/ego/sr/Makefile @@ -0,0 +1,142 @@ +EMHOME=../../.. +EMH=$(EMHOME)/h +EMLIB=$(EMHOME)/lib +SHR=../share + +LDFLAGS= +CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) +CFLAGS=$(CPPFLAGS) -O +LINTFLAGS=-hbu + +CFILES=\ +sr.c sr_iv.c sr_reduce.c sr_cand.c sr_xform.c sr_expr.c sr_aux.c + +OFILES=\ +sr.o sr_expr.o sr_reduce.o sr_iv.o sr_cand.o sr_xform.o sr_aux.o + +HFILES=\ +sr.h sr_iv.h sr_reduce.h sr_cand.h sr_xform.h sr_expr.h sr_aux.h + +PRFILES=\ +$(CFILES) $(HFILES) Makefile + +SHARE_OFILES=\ +$(SHR)/get.o $(SHR)/put.o $(SHR)/alloc.o $(SHR)/global.o $(SHR)/debug.o \ +$(SHR)/files.o $(SHR)/map.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/aux.o \ +$(SHR)/go.o + +SHARE_MFILES=\ +$(SHR)/get.m $(SHR)/put.m $(SHR)/alloc.m $(SHR)/global.m $(SHR)/debug.m \ +$(SHR)/files.m $(SHR)/map.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/aux.m \ +$(SHR)/go.m + +all: sr + +sr: $(OFILES) + $(CC) -o sr $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a + +sr_ack: $(CFILES) $(SHARE_MFILES) + $(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES) + $(CC) -o sr -.c $(LDFLAGS) sr.o $(EMLIB)/em_data.a + +install: all + ../install sr + +cmp: all + -../compare sr + +pr: + @pr $(PRFILES) + +opr: + make pr | opr + +clean: + rm -f sr *.o Out out nohup.out + +lint: + lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) + +print: $(PRFILES) + @pr $? + @touch print + +depend: + $(SHR)/makedepend + +# the next lines are generated automatically +# AUTOAUTOAUTOAUTOAUTOAUTO +sr.o: ../share/alloc.h +sr.o: ../share/aux.h +sr.o: ../share/debug.h +sr.o: ../share/files.h +sr.o: ../share/get.h +sr.o: ../share/global.h +sr.o: ../share/go.h +sr.o: ../share/lset.h +sr.o: ../share/map.h +sr.o: ../share/put.h +sr.o: ../share/types.h +sr.o: sr.h +sr.o: sr_aux.h +sr.o: sr_iv.h +sr_aux.o: ../share/aux.h +sr_aux.o: ../share/debug.h +sr_aux.o: ../share/global.h +sr_aux.o: ../share/lset.h +sr_aux.o: ../share/types.h +sr_aux.o: sr.h +sr_aux.o: sr_aux.h +sr_aux.o: sr_xform.h +sr_cand.o: ../share/aux.h +sr_cand.o: ../share/cset.h +sr_cand.o: ../share/debug.h +sr_cand.o: ../share/global.h +sr_cand.o: ../share/lset.h +sr_cand.o: ../share/map.h +sr_cand.o: ../share/types.h +sr_cand.o: sr.h +sr_cand.o: sr_aux.h +sr_cand.o: sr_cand.h +sr_expr.o: ../share/aux.h +sr_expr.o: ../share/debug.h +sr_expr.o: ../share/global.h +sr_expr.o: ../share/lset.h +sr_expr.o: ../share/types.h +sr_expr.o: sr.h +sr_expr.o: sr_aux.h +sr_expr.o: sr_iv.h +sr_iv.o: ../share/alloc.h +sr_iv.o: ../share/aux.h +sr_iv.o: ../share/cset.h +sr_iv.o: ../share/debug.h +sr_iv.o: ../share/global.h +sr_iv.o: ../share/lset.h +sr_iv.o: ../share/types.h +sr_iv.o: sr.h +sr_iv.o: sr_aux.h +sr_iv.o: sr_cand.h +sr_iv.o: sr_iv.h +sr_reduce.o: ../share/alloc.h +sr_reduce.o: ../share/aux.h +sr_reduce.o: ../share/debug.h +sr_reduce.o: ../share/def.h +sr_reduce.o: ../share/global.h +sr_reduce.o: ../share/lset.h +sr_reduce.o: ../share/types.h +sr_reduce.o: sr.h +sr_reduce.o: sr_aux.h +sr_reduce.o: sr_expr.h +sr_reduce.o: sr_reduce.h +sr_reduce.o: sr_xform.h +sr_xform.o: ../share/alloc.h +sr_xform.o: ../share/aux.h +sr_xform.o: ../share/debug.h +sr_xform.o: ../share/def.h +sr_xform.o: ../share/get.h +sr_xform.o: ../share/global.h +sr_xform.o: ../share/lset.h +sr_xform.o: ../share/types.h +sr_xform.o: sr.h +sr_xform.o: sr_aux.h +sr_xform.o: sr_xform.h diff --git a/util/ego/ud/Makefile b/util/ego/ud/Makefile new file mode 100644 index 00000000..bcfc380b --- /dev/null +++ b/util/ego/ud/Makefile @@ -0,0 +1,136 @@ +EMHOME=../../.. +EMH=$(EMHOME)/h +EMLIB=$(EMHOME)/lib +SHR=../share + +LDFLAGS= +CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) +CFLAGS=$(CPPFLAGS) -O +LINTFLAGS=-hbu + +CFILES=\ +ud.c ud_defs.c ud_const.c ud_copy.c ud_aux.c + +OFILES=\ +ud.o ud_const.o ud_copy.o ud_aux.o ud_defs.o + +HFILES=\ +ud.h ud_defs.h ud_const.h ud_copy.h ud_aux.h + +PRFILES=\ +$(CFILES) $(HFILES) Makefile + +SHARE_OFILES=\ +$(SHR)/get.o $(SHR)/put.o $(SHR)/map.o $(SHR)/alloc.o $(SHR)/global.o \ +$(SHR)/debug.o $(SHR)/lset.o $(SHR)/cset.o $(SHR)/files.o $(SHR)/aux.o \ +$(SHR)/locals.o $(SHR)/init_glob.o $(SHR)/go.o + +SHARE_MFILES=\ +$(SHR)/get.m $(SHR)/put.m $(SHR)/map.m $(SHR)/alloc.m $(SHR)/global.m \ +$(SHR)/debug.m $(SHR)/lset.m $(SHR)/cset.m $(SHR)/files.m $(SHR)/aux.m \ +$(SHR)/locals.m $(SHR)/init_glob.m $(SHR)/go.m + +all: ud + +ud: $(OFILES) + $(CC) -o ud $(LDFLAGS) $(OFILES) $(SHARE_OFILES) $(EMLIB)/em_data.a + +ud_ack: $(CFILES) $(SHARE_MFILES) + $(CC) -c.o $(CFLAGS) $(CFILES) $(SHARE_MFILES) + $(CC) -o ud -.c $(LDFLAGS) ud.o $(EMLIB)/em_data.a + +install: all + ../install ud + +cmp: all + -../compare ud + +pr: + @pr $(PRFILES) + +opr: + make pr | opr + +clean: + rm -f ud *.o Out out nohup.out + +lint: + lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) + +print: $(PRFILES) + @pr $? + @touch print + +depend: + $(SHR)/makedepend + +# the next lines are generated automatically +# AUTOAUTOAUTOAUTOAUTOAUTO +ud.o: ../share/alloc.h +ud.o: ../share/aux.h +ud.o: ../share/cset.h +ud.o: ../share/debug.h +ud.o: ../share/def.h +ud.o: ../share/files.h +ud.o: ../share/get.h +ud.o: ../share/global.h +ud.o: ../share/go.h +ud.o: ../share/init_glob.h +ud.o: ../share/locals.h +ud.o: ../share/lset.h +ud.o: ../share/map.h +ud.o: ../share/put.h +ud.o: ../share/types.h +ud.o: ud.h +ud.o: ud_const.h +ud.o: ud_copy.h +ud.o: ud_defs.h +ud_aux.o: ../share/alloc.h +ud_aux.o: ../share/aux.h +ud_aux.o: ../share/cset.h +ud_aux.o: ../share/debug.h +ud_aux.o: ../share/def.h +ud_aux.o: ../share/global.h +ud_aux.o: ../share/locals.h +ud_aux.o: ../share/lset.h +ud_aux.o: ../share/types.h +ud_aux.o: ud.h +ud_aux.o: ud_defs.h +ud_const.o: ../share/alloc.h +ud_const.o: ../share/aux.h +ud_const.o: ../share/cset.h +ud_const.o: ../share/debug.h +ud_const.o: ../share/def.h +ud_const.o: ../share/global.h +ud_const.o: ../share/locals.h +ud_const.o: ../share/lset.h +ud_const.o: ../share/types.h +ud_const.o: ud.h +ud_const.o: ud_aux.h +ud_const.o: ud_const.h +ud_const.o: ud_defs.h +ud_copy.o: ../share/alloc.h +ud_copy.o: ../share/aux.h +ud_copy.o: ../share/cset.h +ud_copy.o: ../share/debug.h +ud_copy.o: ../share/def.h +ud_copy.o: ../share/global.h +ud_copy.o: ../share/locals.h +ud_copy.o: ../share/lset.h +ud_copy.o: ../share/types.h +ud_copy.o: ../ud/ud_defs.h +ud_copy.o: ud.h +ud_copy.o: ud_aux.h +ud_copy.o: ud_const.h +ud_copy.o: ud_copy.h +ud_defs.o: ../share/alloc.h +ud_defs.o: ../share/aux.h +ud_defs.o: ../share/cset.h +ud_defs.o: ../share/debug.h +ud_defs.o: ../share/global.h +ud_defs.o: ../share/locals.h +ud_defs.o: ../share/lset.h +ud_defs.o: ../share/map.h +ud_defs.o: ../share/types.h +ud_defs.o: ud.h +ud_defs.o: ud_defs.h diff --git a/util/ego/ud/ud_locals.h b/util/ego/ud/ud_locals.h new file mode 100644 index 00000000..c6bfbdd8 --- /dev/null +++ b/util/ego/ud/ud_locals.h @@ -0,0 +1,23 @@ +/* $Header$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* U S E - D E F I N I T I O N A N A L Y S I S + * + * U D _ L O C A L S . H + */ + +extern local_p *locals; /* table of locals, index is local-number */ +extern short nrlocals; /* number of locals for which we keep ud-info */ + +extern make_localtab(); /* (proc_p p) + * Analyse the text of procedure p to determine + * which local variable p has. Make a table of + * these variables ('locals') and count them + * ('nrlocals'). Also collect register messages. + */ +extern var_nr(); /* (line_p l; short *nr_out;bool *found_out) + * Compute the 'variable number' of the + * variable referenced by EM instruction l. + */ diff --git a/util/flex/makefile b/util/flex/makefile new file mode 100644 index 00000000..ba2a2ea5 --- /dev/null +++ b/util/flex/makefile @@ -0,0 +1,158 @@ +# Note: this is a modified version of Makefile, for ACK installation. The +# original flex makefile has a capital M (Makefile). + +EMHOME = ../.. + +# make file for "flex" tool + +# Porting considerations: +# +# For System V Unix machines, add -DUSG to CFLAGS (if it's not +# automatically defined) +# For Vax/VMS, add "-DVMS -DUSG" to CFLAGS. +# For MS-DOS, add "-DMS_DOS -DUSG" to CFLAGS. Create \tmp if not present. +# You will also want to rename flex.skel to something with a three +# character extension, change SKELETON_FILE below appropriately, +# See MSDOS.notes for more info. +# For Amiga, add "-DAMIGA -DUSG" to CFLAGS. +# For SCO Unix, add "-DSCO_UNIX" to CFLAGS. +# +# For C compilers which don't know about "void", add -Dvoid=int to CFLAGS. +# +# If your C compiler is ANSI standard but does not include the +# header file (some installations of gcc have this problem), then add +# -DDONT_HAVE_STDLIB_H to CFLAGS. +# +# By default, flex will be configured to generate 8-bit scanners only +# if the -8 flag is given. If you want it to always generate 8-bit +# scanners, add "-DDEFAULT_CSIZE=256" to CFLAGS. Note that doing +# so will double the size of all uncompressed scanners. +# +# If on your system you have trouble building flex due to 8-bit +# character problems, remove the -8 from FLEX_FLAGS and the +# "#define FLEX_8_BIT_CHARS" from the beginning of flexdef.h. + + +# the first time around use "make first_flex" + + +# Installation targeting. Files will be installed under the tree rooted +# at DESTDIR. User commands will be installed in BINDIR, library files +# in LIBDIR (which will be created if necessary), auxiliary files in +# AUXDIR, manual pages will be installed in MANDIR with extension MANEXT. +# Raw, unformatted troff source will be installed if INSTALLMAN=man, nroff +# preformatted versions will be installed if INSTALLMAN=cat. +DESTDIR = +BINDIR = $(EMHOME)/bin +AUXDIR = $(EMHOME)/lib/flex +MANDIR = $(EMHOME)/man +MANEXT = 1 +INSTALLMAN = man + +# MAKE = make + +SKELETON_FILE = \"`cd $(AUXDIR); pwd`/flex.skel\" +SKELFLAGS = -DDEFAULT_SKELETON_FILE=$(SKELETON_FILE) +CFLAGS = -O -Dvoid=int -DACK_MOD +LDFLAGS = -s + +COMPRESSION = +FLEX_FLAGS = -ist8 -Sflex.skel +# which "flex" to use to generate scan.c from scan.l +FLEX = ./flex +# CC = cc + +AR = ar +RANLIB = ranlib + +FLEXOBJS = \ + ccl.o \ + dfa.o \ + ecs.o \ + gen.o \ + main.o \ + misc.o \ + nfa.o \ + parse.o \ + scan.o \ + sym.o \ + tblcmp.o \ + yylex.o + +FLEX_C_SOURCES = \ + ccl.c \ + dfa.c \ + ecs.c \ + gen.c \ + main.c \ + misc.c \ + nfa.c \ + parse.c \ + scan.c \ + sym.c \ + tblcmp.c \ + yylex.c + + +all : flex + +flex : $(FLEXOBJS) + $(CC) $(CFLAGS) -o flex $(LDFLAGS) $(FLEXOBJS) + +first_flex: + cp initscan.c scan.c + $(MAKE) $(MFLAGS) flex + +parse.h parse.c : parse.y + $(YACC) -d parse.y + @mv y.tab.c parse.c + @mv y.tab.h parse.h + +scan.c : scan.l + $(FLEX) $(FLEX_FLAGS) $(COMPRESSION) scan.l >scan.c + +scan.o : scan.c parse.h flexdef.h + +main.o : main.c flexdef.h + -mkdir $(AUXDIR) + $(CC) $(CFLAGS) -c $(SKELFLAGS) main.c + +ccl.o : ccl.c flexdef.h +dfa.o : dfa.c flexdef.h +ecs.o : ecs.c flexdef.h +gen.o : gen.c flexdef.h +misc.o : misc.c flexdef.h +nfa.o : nfa.c flexdef.h +parse.o : parse.c flexdef.h +sym.o : sym.c flexdef.h +tblcmp.o : tblcmp.c flexdef.h +yylex.o : yylex.c flexdef.h + +lint : $(FLEX_C_SOURCES) + lint $(FLEX_C_SOURCES) > flex.lint + +install: first_flex flex.skel + rm -f $(BINDIR)flex + cp flex $(BINDIR)/flex + cp flex.skel $(AUXDIR)/flex.skel + cp flex.1 $(MANDIR)/flex.1 + cp flexdoc.1 $(MANDIR)/flexdoc.1 + +clean : + rm -f core errs flex *.o parse.c *.lint parse.h tags + +tags : + ctags $(FLEX_C_SOURCES) + +test : flex + ./flex $(FLEX_FLAGS) $(COMPRESSION) scan.l | diff scan.c - + +bigtest : + rm -f scan.c ; $(MAKE) COMPRESSION="-C" test + rm -f scan.c ; $(MAKE) COMPRESSION="-Ce" test + rm -f scan.c ; $(MAKE) COMPRESSION="-Cm" test + rm -f scan.c ; $(MAKE) COMPRESSION="-Cfe" test + rm -f scan.c ; $(MAKE) COMPRESSION="-CFe" test + rm -f scan.c ; $(MAKE) COMPRESSION="-Cf" test + rm -f scan.c ; $(MAKE) COMPRESSION="-CF" test + rm -f scan.c ; $(MAKE) diff --git a/util/grind/Amakefile b/util/grind/Amakefile new file mode 100644 index 00000000..07c95606 --- /dev/null +++ b/util/grind/Amakefile @@ -0,0 +1,127 @@ +AMAKELIB = { . , /usr/local/lib/amake } ; + +%include std-amake.amk ; +%include ack-defs.amk ; +%include cc_hh_tools.amk ; +%include tok_tools.amk ; +%include op_tools.amk ; +%include char_tools.amk ; + +%default grind ; + +%declare tokenname.c [ + gen_tokens, + cc-dest = symbol2str.c, + LL-dest = tokenfile.g +]; + +CMD_LLSRC = { + tokenname.c, + commands.g +} ; + +CSRC = { + main.c, + list.c, + tree.c, + expr.c, + position.c, + idf.c, + run.c, + symbol.c, + print.c, + type.c, + rd.c, + do_comm.c, + modula-2.c, + pascal.c, + c.c +} ; + +HSRC = { + tokenname.h, + operator.h, + class.h, + position.h, + idf.h, + message.h, + avl.h, + scope.h, + langdep.h, + sizes.h, + token.h, + expr.h, + rd.h +} ; + +HHSRC = { + file.hh, + type.hh, + symbol.hh, + tree.hh, + avl.cc, + scope.cc, + itemlist.cc, + langdep.cc +} ; + +LIBRARIES = { + $EMHOME/modules/lib/libassert.a, + $EMHOME/modules/lib/liballoc.a, + $EMHOME/modules/lib/malloc.o, + $EMHOME/modules/lib/libstring.a, + $EMHOME/modules/lib/libobject.a, + $EMHOME/modules/lib/libsystem.a +} ; + +DBFLAGS = { -O, -DDEBUG } ; +PROFFLAGS = { } ; + +LDFLAGS = { + -Bstatic, + $PROFFLAGS, + $DBFLAGS +} ; + +INCLUDES = { + -I$EMHOME/modules/h, + -I$EMHOME/modules/pkg, + -I$EMHOME/h +} ; + +CFLAGS = { + $INCLUDES, + $PROFFLAGS, + $DBFLAGS +} ; + +DBS_LLTARGETS = { + db_symtab.c, + DBSpars.c, + DBSpars.h +} ; + +DBS_LLSRC = { + db_symtab.g +} ; + +%cluster { + %targets $DBS_LLTARGETS ; + %sources $DBS_LLSRC ; + %use LLgen(prefix => DBS) ; +} ; + +LINTFLAGS = { + $INCLUDES +} ; + +%cluster { + %targets lint.out[type = lint-output]; + %sources $CSRC + $CMD_LLSRC + $DBS_LLTARGETS + $HHSRC + char.ct + operators.ot ; + %use lint(realdest => lint.out) ; +} ; + +%cluster { + %targets grind[type = program]; + %sources $CSRC + $CMD_LLSRC + $DBS_LLTARGETS + $HHSRC + char.ct + operators.ot ; +} ; diff --git a/util/grind/LLgen.amk b/util/grind/LLgen.amk new file mode 100644 index 00000000..8f8a5add --- /dev/null +++ b/util/grind/LLgen.amk @@ -0,0 +1,39 @@ +# LLgen: LL(1) parser generator +# variables: LLGEN, LLFLAGS + +# tool definition for the new version of LLgen that allows for more than +# one parser in one program. Unfortunately, for historical reasons there +# is no proper default prefix for LLgen-generated files (LL.output versus +# Lpars.[ch]). If LLgen would generate LLpars.[ch] instead of Lpars.[ch], +# we could have a default value for prefix of 'LL', which would make +# things a bit more simple. + +%instance deftypesuffix(LLgen-src, '%.g') ; + +%include ack-defs.amk; + +%if (%not defined(LLGEN), { + LLGEN = $EMHOME/bin/LLgen; +}); + +%if (%not defined(LLFLAGS), { + LLFLAGS = {}; +}); + +%tool LLgen ( + verbose: %boolean => %false; + flags: %string %list => $LLFLAGS; + prefix: %string => ''; + src: %in %list [type = LLgen-src]; + parser: %out %list [type = C-src] + => match($src) + if($prefix == '', Lpars.c, $prefix'pars.c'); + tokens: %out [type = C-incl, compare] + => if($prefix == '', Lpars.h, $prefix'pars.h'); + diagn: %out [type = text] + => if($prefix == '', LL.output, $prefix.output) %conform $verbose; + cmd: %in [type = command] => $LLGEN; +) +{ + exec($cmd, args => if($verbose, {'-vvv'}, {}) + $flags + $src); + echo({'LLgen ', $src, ' done'}); +}; diff --git a/util/grind/ack-defs.amk b/util/grind/ack-defs.amk new file mode 100644 index 00000000..0357a290 --- /dev/null +++ b/util/grind/ack-defs.amk @@ -0,0 +1,5 @@ +# definition of EMHOME + +%if (%not defined(EMHOME), { + EMHOME = /usr/proj/em/Work; +}); diff --git a/util/grind/cc_hh_tools.amk b/util/grind/cc_hh_tools.amk new file mode 100644 index 00000000..e03ee525 --- /dev/null +++ b/util/grind/cc_hh_tools.amk @@ -0,0 +1,43 @@ +%instance deftypesuffix(hh-src, '%.hh') ; +%instance deftypesuffix(cc-src, '%.cc') ; + +ALLOCD = make.allocd; +NEXT = make.next; + +%tool allochd ( + hhsrc: %in [type = hh-src, persistent]; + hsrc: %out [type = C-incl] => match($hhsrc); + prog: %in [type = command] => $ALLOCD; +) +{ + exec($prog, stdin => $hhsrc, stdout => $hsrc); + echo({$hsrc ,'created'}); +}; + + +%tool alloccd ( + ccsrc: %in [type = cc-src, persistent]; + csrc: %out [type = C-src] => match($ccsrc); + prog: %in [type = command] => $ALLOCD; +) +{ + exec($prog, stdin => $ccsrc, stdout => $csrc); + echo({$csrc ,'created'}); +}; + + +# Possibly there's only one type of { cc-src, hh-src } available, +# so introduce a new attribute. + +%derive f[cc-or-hh-src] %when get($f, type) == cc-src + %or get($f, type) == hh-src; + +%tool mknext ( + cchhsrc: %in %list [cc-or-hh-src]; + next: %out [type = C-src] => next.c; + prog: %in [type = command] => $NEXT; +) +{ + exec($prog, args => $cchhsrc, stdout => $next); + echo({$next ,'created'}); +}; diff --git a/util/grind/char_tools.amk b/util/grind/char_tools.amk new file mode 100644 index 00000000..9126a016 --- /dev/null +++ b/util/grind/char_tools.amk @@ -0,0 +1,24 @@ +# tabgen: tool definition for character table generator +# variables: TABGEN, CHTAB + +%include ack-defs.amk; + +%if (%not defined(TABGEN), { + TABGEN = $EMHOME/bin/tabgen; +}); + +%if (%not defined(CHTAB), { + CHTAB = chtab.c; +}); + +%instance deftypesuffix(char_tab, '%.ct'); + +%tool gen_tab ( + chtab: %in [type = char_tab]; + cfile: %out [type = C-src] => $CHTAB; + mktab: %in [type = command] => $TABGEN; +) +{ + exec($mktab, args => '-f' $chtab, stdout => $cfile); + echo({$cfile, 'created'}); +}; diff --git a/util/grind/dbx_string.g b/util/grind/dbx_string.g new file mode 100644 index 00000000..4a181b66 --- /dev/null +++ b/util/grind/dbx_string.g @@ -0,0 +1,709 @@ +/* $Header$ + Grammar of a string of a debugger symbol table entry. +*/ + +{ +#include +#include + +#include "type.h" +#include "symbol.h" +#include "scope.h" +#include "class.h" +#include "idf.h" + +extern char *strindex(); +extern long str2long(); +extern double atof(); +extern int saw_code; +extern long pointer_size; + +static char *DbxPtr; /* current pointer in DBX string */ +static int AllowName; /* set if NAME legal at this point */ +static long ival; +static double fval; +static char *strval; +static int last_index[2]; +static struct outname *currnam; + +static struct literal *get_literal_space(); +static struct fields *get_field_space(); +static end_field(); +static char *string_val(); +} + +%start DbxParser, debugger_string; + +%prefix DBS; + +%lexical DBSlex; + +%onerror DBSonerror; + +%token INTEGER, REAL, STRING, NAME; + +debugger_string + { register p_symbol s; + char *str; + p_type tmp = 0; + } +: + name(&str) + [ /* constant name */ + { s = NewSymbol(str, CurrentScope, CONST, currnam); } + 'c' const_name(s) + + | /* type name */ + { s = NewSymbol(str, CurrentScope, TYPE, currnam); } + 't' type_name(&(s->sy_type), s) + { if (! s->sy_type->ty_sym) s->sy_type->ty_sym = s; + if ((s->sy_type->ty_class == T_ENUM || + s->sy_type->ty_class == T_SUBRANGE) && + currnam->on_desc != 0) { + s->sy_type->ty_size = currnam->on_desc; + } + } + | /* tag name (only C?) */ + { s = NewSymbol(str, CurrentScope, TAG, currnam); } + 'T' type_name(&(s->sy_type), s) + { if (! s->sy_type->ty_sym) s->sy_type->ty_sym = s; + if (s->sy_type->ty_class != T_CROSS) { + resolve_cross(s->sy_type); + } + } + | /* end scope */ + 'E' INTEGER + { close_scope(); } + + | /* module begin */ + { s = NewSymbol(str, CurrentScope, MODULE, currnam); } + 'M' INTEGER + { open_scope(s, 1); + s->sy_name.nm_scope = CurrentScope; + CurrentScope->sc_start = currnam->on_valu; + CurrentScope->sc_proclevel = currnam->on_desc; + add_scope_addr(CurrentScope); + } + + | /* external procedure */ + { s = NewSymbol(str, FileScope, PROC, currnam); } + 'P' routine(s) + + | /* private procedure */ + { s = NewSymbol(str, CurrentScope, PROC, currnam); } + 'Q' routine(s) + + | /* external function */ + { s = NewSymbol(str, FileScope, FUNCTION, currnam); } + 'F' function(s) + + | /* private function */ + { s = NewSymbol(str, CurrentScope, FUNCTION, currnam); } + 'f' function(s) + + | /* global variable, external */ + /* maybe we already know it; but we need + the type information anyway for other + types. + */ + { s = Lookup(findidf(str), FileScope, VAR); + if (s) { + tmp = s->sy_type; + s->sy_type = 0; + } else s = NewSymbol(str, FileScope, VAR, currnam); + } + 'G' type(&(s->sy_type), (int *) 0, s) + { if (tmp) s->sy_type = tmp; } + + | /* static variable */ + { s = NewSymbol(str, CurrentScope, VAR, currnam); } + 'S' type(&(s->sy_type), (int *) 0, s) + + | /* static variable, local scope */ + { s = NewSymbol(str, CurrentScope, VAR, currnam); } + 'V' type(&(s->sy_type), (int *) 0, s) + + | /* register variable */ + { s = NewSymbol(str, CurrentScope, REGVAR, currnam); } + 'r' type(&(s->sy_type), (int *) 0, s) + + | /* value parameter */ + { s = NewSymbol(str, CurrentScope, LOCVAR, currnam); } + 'p' type(&(s->sy_type), (int *) 0, s) + { add_param_type('p', s); } + + | /* value parameter but address passed */ + { s = NewSymbol(str, CurrentScope, VARPAR, currnam); } + 'i' type(&(s->sy_type), (int *) 0, s) + { add_param_type('i', s); } + + | /* variable parameter */ + { s = NewSymbol(str, CurrentScope, VARPAR, currnam); } + 'v' type(&(s->sy_type), (int *) 0, s) + { add_param_type('v', s); } + + | /* local variable */ + { s = NewSymbol(str, CurrentScope, LOCVAR, currnam); } + type_name(&(s->sy_type), s) + + | /* function result in Pascal; ignore ??? */ + { s = NewSymbol(str, CurrentScope, LOCVAR, currnam); } + 'X' type_name(&(s->sy_type), s) + ] + ';'? +; + +name(char **s;) +: + /* anything up to a ':' */ + NAME { *s = strval; } +; + +const_name(p_symbol cst;) + { int type_index[2]; + long iconst; + register char *p; + } +: + '=' + [ +/* + 'b' integer_const(&(cst->sy_const.co_ival)) /* boolean */ +/* | +*/ + 'c' integer_const(&(cst->sy_const.co_ival)) /* character */ + { cst->sy_type = char_type; } + | + 'i' integer_const(&(cst->sy_const.co_ival)) /* integer */ + { cst->sy_type = long_type; } + | + 'r' real_const(&(cst->sy_const.co_rval)) /* real */ + { cst->sy_type = double_type; } + | + 's' string_const /* string */ + { cst->sy_const.co_sval = string_val(strval); + cst->sy_type = string_type; + } + | + 'e' type_index(type_index) ',' integer_const(&(cst->sy_const.co_ival)) + /* enumeration constant; + * enumeration type, value + */ + { cst->sy_type = *tp_lookup(type_index); } + + | + 'S' type_index(type_index) + { cst->sy_type = *tp_lookup(type_index); + cst->sy_const.co_setval = p = + Malloc((unsigned) cst->sy_type->ty_size); + } + [ ',' integer_const(&iconst) + { *p++ = iconst; } + ]+ + /* set constant: + * settype, values of the bytes + * in the set. + */ + ] +; + +integer_const(long *iconst;) + { int sign = 0; } +: + [ '+' | '-' { sign = 1; } ]? + INTEGER { *iconst = sign ? -ival : ival; } +; + +real_const(double *f;) + { int sign = 0; } +: + [ '+' | '-' { sign = 1; } ]? + REAL { *f = sign ? fval : -fval; } +; + +string_const +: + STRING /* has SINGLE quotes! */ +; + +type_name(p_type *t; p_symbol sy;) + { int type_index[2]; p_type *p; } +: + type_index(type_index) { p = tp_lookup(type_index); } + [ + { if (*p && (*p)->ty_class != 0 && + (*p)->ty_class != T_CROSS) { + error("Redefining (%d,%d) %d", + type_index[0], + type_index[1], + (*p)->ty_class); + } + } + '=' + type(p, type_index, sy) + | + ] + { if (*p == 0) *p = new_type(); + *t = *p; + } +; + +type_index(int *type_index;) +: +[ + INTEGER { type_index[0] = 0; type_index[1] = ival; } +| + '(' INTEGER { type_index[0] = ival; } + ',' INTEGER { type_index[1] = ival; } + ')' +] + { last_index[0] = type_index[0]; + last_index[1] = type_index[1]; + } +; + +function(p_symbol p;) +: + { p->sy_type = new_type(); + p->sy_type->ty_class = T_PROCEDURE; + p->sy_type->ty_size = pointer_size; + } + type(&(p->sy_type->ty_retval), (int *) 0, (p_symbol) 0) + { if (CurrentScope != FileScope && + saw_code) { + /* if saw_code is not set, it is a nested + procedure + */ + close_scope(); + } + saw_code = 0; + open_scope(p, 1); + p->sy_name.nm_scope = CurrentScope; + CurrentScope->sc_start = currnam->on_valu; + add_scope_addr(CurrentScope); + CurrentScope->sc_proclevel = currnam->on_desc; + } +; + +routine(p_symbol p;) +: + { p->sy_type = new_type(); + p->sy_type->ty_class = T_PROCEDURE; + p->sy_type->ty_size = pointer_size; + if (CurrentScope != FileScope && + saw_code) { + /* if saw_code is not set, it is a nested + procedure + */ + close_scope(); + } + saw_code = 0; + open_scope(p, 1); + p->sy_name.nm_scope = CurrentScope; + CurrentScope->sc_start = currnam->on_valu; + add_scope_addr(CurrentScope); + CurrentScope->sc_proclevel = currnam->on_desc; + } + INTEGER ';' + type(&(p->sy_type->ty_retval), (int *) 0, (p_symbol) 0) +; + +type(p_type *ptp; int *type_index; p_symbol sy;) + { register p_type tp = *ptp ? *ptp : new_type(); + p_type t1 = 0, t2 = 0; + long ic1, ic2; + int A_used = 0; + int tclass; + int tp_index[2]; + char *str; + } +: + [ + /* type cross reference */ + /* these are used in C for references to a struct, union or + * enum that has not been declared (yet) + */ + 'x' + [ 's' /* struct */ + { tclass = T_STRUCT; } + | 'u' /* union */ + { tclass = T_UNION; } + | 'e' /* enum */ + { tclass = T_ENUM; } + ] + { AllowName = 1; } + name(&str) + { sy = Lookfromscope(str2idf(str,0),TAG,CurrentScope); + if (sy && + (sy->sy_type->ty_class == tclass || + sy->sy_type->ty_class == T_CROSS)) { + if (tp != *ptp) free_type(tp); + tp = sy->sy_type; + } + else { + tp->ty_class = T_CROSS; + tp->ty_size = tclass; + sy = NewSymbol(str, CurrentScope, TAG, (struct outname *) 0); + sy->sy_type = tp; + } + } + | + /* subrange */ + /* the integer_const's represent the lower and the upper bound. + * A subrange type defined as subrange of itself is an integer type. + * If the second integer_const == 0, but the first is not, we + * have a floating point type with size equal to the first + * integer_const. + * Upperbound -1 means unsigned int or unsigned long. + */ + 'r' type_index(tp_index) ';' + [ 'A' integer_const(&ic1) { A_used = 1; } + | integer_const(&ic1) + ] + ';' + [ 'A' integer_const(&ic2) { A_used |= 2; } + | integer_const(&ic2) + ] + { if (tp != *ptp) free_type(tp); + tp = subrange_type(A_used, + tp_index, + ic1, + ic2, + type_index); + } + | + /* array; first type is bound type, next type + * is element type + */ + 'a' type(&t1, (int *) 0, (p_symbol) 0) ';' type(&t2, (int *) 0, (p_symbol) 0) + { if (tp != *ptp) free_type(tp); + tp = array_type(t1, t2); + } + | + /* structure type */ + 's' { tp->ty_class = T_STRUCT; } + structure_type(tp, sy) + | + /* union type */ + 'u' { tp->ty_class = T_UNION; } + structure_type(tp, sy) + | + /* enumeration type */ + 'e' { tp->ty_class = T_ENUM; } + enum_type(tp) + | + /* pointer type */ + '*' { tp->ty_class = T_POINTER; + tp->ty_size = pointer_size; + } + type(&(tp->ty_ptrto), (int *) 0, (p_symbol) 0) + | + /* function type */ + 'f' { tp->ty_class = T_PROCEDURE; + tp->ty_size = pointer_size; + } + type(&(tp->ty_retval), (int *) 0, (p_symbol) 0) +/* + [ %prefer + ',' param_list(tp) + | + ] +*/ + | + /* procedure type */ + 'Q' { tp->ty_class = T_PROCEDURE; + tp->ty_size = pointer_size; + } + type(&(tp->ty_retval), (int *) 0, (p_symbol) 0) + ',' param_list(tp) + | + /* another procedure type */ + 'p' { tp->ty_class = T_PROCEDURE; + tp->ty_size = pointer_size; + tp->ty_retval = void_type; + } + param_list(tp) + | + /* set type */ + /* the first integer_const represents the size in bytes, + * the second one represents the low bound + */ + 'S' { tp->ty_class = T_SET; } + type(&(tp->ty_setbase), (int *) 0, (p_symbol) 0) ';' + [ + integer_const(&(tp->ty_size)) ';' + integer_const(&(tp->ty_setlow)) ';' + | + { set_bounds(tp); } + ] + | + /* file type of Pascal */ + 'L' { tp->ty_class = T_FILE; } + type(&(tp->ty_fileof), (int *) 0, (p_symbol) 0) + | + type_name(ptp, (p_symbol) 0) + { if (type_index && + (*ptp)->ty_class == 0 && + type_index[0] == last_index[0] && + type_index[1] == last_index[1]) { + **ptp = *void_type; + if (*ptp != tp) free_type(tp); + } + tp = *ptp; + } + ] + { if (*ptp && *ptp != tp) **ptp = *tp; + else *ptp = tp; + } +; + +structure_type(register p_type tp; p_symbol sy;) + { register struct fields *fldp; + char *str; + } +: + integer_const(&(tp->ty_size)) /* size in bytes */ + { open_scope(sy, 0); + if (sy) sy->sy_name.nm_scope = CurrentScope; + } + [ + name(&str) { fldp = get_field_space(tp, str); } + type(&(fldp->fld_type), (int *) 0, (p_symbol) 0) ',' + integer_const(&(fldp->fld_pos)) ',' /* offset in bits */ + integer_const(&(fldp->fld_bitsize)) ';' /* size in bits */ + ]* + ';' { end_field(tp); + close_scope(); + } +; + +enum_type(register p_type tp;) + { register struct literal *litp; + long maxval = 0; + register p_symbol s; + } +: + [ { litp = get_literal_space(tp); } + name(&(litp->lit_name)) + integer_const(&(litp->lit_val)) ',' + { if (maxval < litp->lit_val) maxval = litp->lit_val; + AllowName = 1; + s = NewSymbol(litp->lit_name, CurrentScope, CONST, (struct outname *) 0); + s->sy_const.co_ival = litp->lit_val; + s->sy_type = tp; + } + ]* + ';' { end_literal(tp, maxval); } +; + +param_list(p_type t;) + { register struct param *p; + long iconst; + } +: + integer_const(&iconst) ';' /* number of parameters */ + { t->ty_nparams = iconst; + t->ty_params = p = (struct param *) + Malloc((unsigned)(t->ty_nparams * sizeof(struct param))); + } + [ + [ 'p' { p->par_kind = 'p'; } + | 'v' { p->par_kind = 'v'; } + | 'i' { p->par_kind = 'i'; } + ] + type(&(p->par_type), (int *) 0, (p_symbol) 0) ';' + { t->ty_nbparams += + param_size(p->par_type, p->par_kind); + p++; + } + ]* +; + +{ +static char *dbx_string; +static char *DbxOldPtr; + +struct outname * +DbxString(n) + struct outname *n; +{ + currnam = n; + DbxPtr = n->on_mptr; + dbx_string = DbxPtr; + AllowName = 1; + DbxParser(); + return currnam; +} + +/*ARGSUSED*/ +DBSmessage(n) +{ + fatal("error in Dbx string \"%s\", DbxPtr = \"%s\", DbxOldPtr = \"%s\"", + dbx_string, + DbxPtr, + DbxOldPtr); + +} + +DBSonerror(tk, p) + int *p; +{ + DbxPtr = DbxOldPtr; +/* ??? if (DBSsymb < 0) { + while (*p && *p != ';') p++; + if (*p) DbxPtr = ";"; + return; + } +*/ + if (! tk) { + while (*p && *p != NAME) p++; + if (*p) { + AllowName = 1; + } + } + else if (tk == NAME) AllowName = 1; +} + +DBSlex() +{ + register char *cp = DbxPtr; + int allow_name = AllowName; + register int c; + + AllowName = 0; + DbxOldPtr = cp; + c = *cp; + if (c == '\\' && *(cp+1) == '\0') { + currnam++; + cp = currnam->on_mptr; + DbxOldPtr = cp; + c = *cp; + } + if (! c) { + DbxPtr = cp; + return -1; + } + if ((! allow_name && is_token(c)) || c == ';') { + DbxPtr = cp+1; + return c; + } + if (is_dig(c)) { + int retval = INTEGER; + + while (++cp, is_dig(*cp)) /* nothing */; + c = *cp; + if (c == '.') { + retval = REAL; + while (++cp, is_dig(*cp)) /* nothing */; + c = *cp; + } + if (c == 'e' || c == 'E') { + char *oldcp = cp; + + cp++; + c = *cp; + if (c == '-' || c == '+') { + cp++; + c = *cp; + } + if (is_dig(c)) { + retval = REAL; + while (++cp, is_dig(*cp)) /* nothing */; + } + else cp = oldcp; + } + c = *cp; + *cp = 0; + if (retval == INTEGER) { + ival = str2long(DbxOldPtr, 10); + } + else { + fval = atof(DbxOldPtr); + } + *cp = c; + DbxPtr = cp; + return retval; + } + if (c == '\'') { + cp++; + strval = cp; + while ((c = *cp) && c != '\'') { + if (c == '\\') cp++; /* backslash escapes next character */ + if (!(c = *cp)) break; /* but not a null byte */ + cp++; + } + if (! c) DBSmessage(0); /* no return */ + *cp = 0; + DbxPtr = cp + 1; + return STRING; + } + strval = cp; + while ((c = *cp) && c != ':' && c != ',') cp++; + DbxPtr = *cp ? cp+1 : cp; + *cp = 0; + return NAME; +} + +static struct fields * +get_field_space(tp, s) + register p_type tp; + char *s; +{ + register struct fields *p; + p_symbol sy; + + if (! (tp->ty_nfields & 07)) { + tp->ty_fields = (struct fields *) + Realloc((char *) tp->ty_fields, + (tp->ty_nfields+8)*sizeof(struct fields)); + } + p = &tp->ty_fields[tp->ty_nfields++]; + p->fld_name = s; + p->fld_type = 0; + sy = NewSymbol(s, CurrentScope, FIELD, currnam); + sy->sy_field = p; + return p; +} + +static +end_field(tp) + register p_type tp; +{ + tp->ty_fields = (struct fields *) + Realloc((char *) tp->ty_fields, + tp->ty_nfields * sizeof(struct fields)); +} + +static struct literal * +get_literal_space(tp) + register p_type tp; +{ + if (! (tp->ty_nenums & 07)) { + tp->ty_literals = (struct literal *) + Realloc((char *) tp->ty_literals, + (tp->ty_nenums+8)*sizeof(struct literal)); + } + return &tp->ty_literals[tp->ty_nenums++]; +} + +static char * +string_val(s) + char *s; +{ + register char *ns = s, *os = s; + register unsigned int i = 1; + + for (;;) { + if (!*os) break; + i++; + if (*os == '\\') { + os++; + *ns++ = *os++; + } + else *ns++ = *os++; + } + *ns = '\0'; + return Salloc(s, i); +} + +} diff --git a/util/grind/dbxread.c b/util/grind/dbxread.c new file mode 100644 index 00000000..7b4b51e9 --- /dev/null +++ b/util/grind/dbxread.c @@ -0,0 +1,194 @@ +/* $Header$ + Read the symbol table from an ACK a.out format file. +*/ + +#include +#include +#include + +#include "position.h" +#include "file.h" +#include "symbol.h" +#include "idf.h" +#include "scope.h" +#include "rd.h" + +extern char *strindex(); +extern struct outname *DbxString(); + +int saw_code = 0; + +static char *AckStrings; /* ACK a.out string table */ +static struct outname *AckNames; /* ACK a.out symbol table entries */ +static unsigned int NAckNames; /* Number of ACK symbol table entries */ +static struct outname *EndAckNames; /* &AckNames[NAckNames] */ + +/* Read the symbol table from file 'f', which is supposed to be an + ACK a.out format file. Offer DBX strings to the DBX string parser. +*/ +int +DbxRead(f) + char *f; +{ + struct outhead h; + register struct outname *n; + register struct outname *line_file = 0; + long OffsetStrings; + int had_lbrac = 0; + + /* Open file, read header, and check magic word */ + if (! rd_open(f)) { + fatal("%s: could not open", f); + } + rd_ohead(&h); + if (BADMAGIC(h) && h.oh_magic != O_CONVERTED) { + fatal("%s: not an object file", f); + } + + /* Allocate space for name table and read it */ + AckNames = (struct outname *) + Malloc((unsigned)(sizeof(struct outname) * h.oh_nname)); + AckStrings = Malloc((unsigned) h.oh_nchar); + rd_name(AckNames, h.oh_nname); + rd_string(AckStrings, h.oh_nchar); + + /* Adjust file offsets in name table to point at strings */ + OffsetStrings = OFF_CHAR(h); + NAckNames = h.oh_nname; + EndAckNames = &AckNames[h.oh_nname]; + for (n = EndAckNames; --n >= AckNames;) { + if (n->on_foff) { + if ((unsigned)(n->on_foff - OffsetStrings) >= h.oh_nchar) { + fatal("%s: error in object file", f); + } + n->on_mptr = AckStrings + (n->on_foff - OffsetStrings); + } + else n->on_mptr = 0; + } + + /* Offer strings to the DBX string parser if they contain a ':'. + Also offer filename-line number information to add_position_addr(). + Here, the order may be important. + */ + for (n = &AckNames[0]; n < EndAckNames; n++) { + int tp = n->on_type >> 8; + register p_symbol sym; + + if (tp & (S_STB >> 8)) { + switch(tp) { +#ifdef N_BINCL + case N_BINCL: + n->on_valu = (long) line_file; + line_file = n; + break; + case N_EINCL: + if (line_file) { + line_file = (struct outname *) line_file->on_valu; + } + break; +#endif + case N_SO: + if (n->on_mptr[strlen(n->on_mptr)-1] == '/') { + /* another N_SO follows ... */ + break; + } + while (CurrentScope != PervasiveScope) { + close_scope(); + } + saw_code = 0; + sym = add_file(n->on_mptr); + + if (! listfile) newfile(sym->sy_idf); + open_scope(sym, 0); + sym->sy_file->f_scope = CurrentScope; + FileScope = CurrentScope; + clean_tp_tab(); + /* fall through */ + case N_SOL: + if (! line_file) line_file = n; + else line_file->on_mptr = n->on_mptr; + break; + case N_MAIN: + newfile(FileScope->sc_definedby->sy_idf); + break; + case N_SLINE: + assert(line_file); + if (! saw_code && !CurrentScope->sc_bp_opp) { + CurrentScope->sc_bp_opp = n->on_valu; + if (! CurrentScope->sc_start) { + CurrentScope->sc_start = n->on_valu; + if (CurrentScope->sc_has_activation_record) { + add_scope_addr(CurrentScope); + } + } + } + saw_code = 1; + add_position_addr(line_file->on_mptr, n); + break; + case N_LBRAC: /* block, desc = nesting level */ + if (had_lbrac) { + open_scope((p_symbol) 0, 0); + saw_code = 0; + } + else { + register p_scope sc = + get_scope_from_addr(n->on_valu); + + if (!sc || sc->sc_bp_opp) { + had_lbrac = 1; + } + else CurrentScope = sc; + } + break; +#ifdef N_SCOPE + case N_SCOPE: + if (n->on_mptr && strindex(n->on_mptr, ':')) { + n = DbxString(n); + } + break; +#endif + case N_RBRAC: /* end block, desc = nesting level */ + had_lbrac = 0; + if (CurrentScope != FileScope) close_scope(); + saw_code = 0; + break; + case N_FUN: /* function, value = address */ + case N_GSYM: /* global variable */ + case N_STSYM: /* data, static, value = address */ + case N_LCSYM: /* bss, static, value = address */ + case N_RSYM: /* register var, value = reg number */ + case N_SSYM: /* struct/union el, value = offset */ + case N_PSYM: /* parameter, value = offset from AP */ + case N_LSYM: /* local sym, value = offset from FP */ + if (had_lbrac) { + open_scope((p_symbol) 0, 0); + saw_code = 0; + had_lbrac = 0; + } + if (n->on_mptr && strindex(n->on_mptr, ':')) { + n = DbxString(n); + } + break; + default: +/* + if (n->on_mptr && (n->on_type&S_TYP) >= S_MIN) { + struct idf *id = str2idf(n->on_mptr, 0); + + sym = new_symbol(); + sym->sy_next = id->id_def; + id->id_def = sym; + sym->sy_class = SYMENTRY; + sym->sy_onam = *n; + sym->sy_idf = id; + } +*/ + break; + } + } + } + close_scope(); + add_position_addr((char *) 0, (struct outname *) 0); + clean_tp_tab(); + rd_close(); + return (h.oh_magic == O_CONVERTED); +} diff --git a/util/grind/default.c b/util/grind/default.c new file mode 100644 index 00000000..c2bbb0e0 --- /dev/null +++ b/util/grind/default.c @@ -0,0 +1,341 @@ +/* $Header$ */ + +/* Language dependant support; this one is default */ + +#include +#include + +#include "position.h" +#include "class.h" +#include "langdep.h" +#include "Lpars.h" +#include "idf.h" +#include "token.h" +#include "expr.h" +#include "tree.h" +#include "operator.h" + +extern FILE *db_out, *db_in; + +extern int + get_name(); + +extern double + atof(); + +static int + print_string(), + get_number(), + get_string(), + get_token(), + print_op(), + op_prio(); + +static long + array_elsize(); + +static struct langdep def = { + 0, + + "%ld", + "0%lo", + "0x%lX", + "%lu", + "0x%lX", + "%g", + "'\\%o'", + + "[", + "]", + "(", + ")", + "{", + "}", + + print_string, + array_elsize, + op_prio, + get_string, + get_name, + get_number, + get_token, + print_op +}; + +struct langdep *def_dep = &def; + +static int +print_string(s, len) + char *s; + int len; +{ + register char *str = s; + int delim = '\''; + + while (*str) { + if (*str++ == '\'') delim = '"'; + } + fprintf(db_out, "%c%.*s%c", delim, len, s, delim); +} + +extern long int_size; + +static long +array_elsize(size) + long size; +{ + if (! (int_size % size)) return size; + if (! (size % int_size)) return size; + return ((size + int_size - 1) / int_size) * int_size; +} + +/*ARGSUSED*/ +static int +op_prio(op) + int op; +{ + return 1; +} + +static int +val_in_base(c, base) + register int c; +{ + return is_dig(c) + ? c - '0' + : base != 16 + ? -1 + : is_hex(c) + ? (c - 'a' + 10) & 017 + : -1; +} + +static int +get_number(c) + register int c; +{ + char buf[512+1]; + register int base = 10; + register char *p = &buf[0]; + register long val = 0; + register int val_c; + + if (c == '0') { + /* check if next char is an 'x' or an 'X' */ + c = getc(db_in); + if (c == 'x' || c == 'X') { + base = 16; + c = getc(db_in); + } + else base = 8; + } + while (val_c = val_in_base(c, base), val_c >= 0) { + val = val * base + val_c; + if (p - buf < 512) *p++ = c; + c = getc(db_in); + } + if (base == 16 || !((c == '.' || c == 'e' || c == 'E'))) { + ungetc(c, db_in); + tok.ival = val; + return INTEGER; + } + if (c == '.') { + if (p - buf < 512) *p++ = c; + c = getc(db_in); + } + while (is_dig(c)) { + if (p - buf < 512) *p++ = c; + c = getc(db_in); + } + if (c == 'e' || c == 'E') { + if (p - buf < 512) *p++ = c; + c = getc(db_in); + if (c == '+' || c == '-') { + if (p - buf < 512) *p++ = c; + c = getc(db_in); + } + if (! is_dig(c)) { + error("malformed floating constant"); + } + while (is_dig(c)) { + if (p - buf < 512) *p++ = c; + c = getc(db_in); + } + } + ungetc(c, db_in); + *p++ = 0; + if (p == &buf[512+1]) { + error("floating point constant too long"); + } + tok.fval = atof(buf); + return REAL; +} + +static int +get_token(c) + register int c; +{ + switch(c) { + case '`': + case ':': + case ',': + return c; + case '.': + return get_number(c); + default: + error("illegal character 0%o", c); + return LLlex(); + } +} + +static int +quoted(ch) + int ch; +{ + /* quoted() replaces an escaped character sequence by the + character meant. + */ + /* first char after backslash already in ch */ + if (!is_oct(ch)) { /* a quoted char */ + switch (ch) { + case 'n': + ch = '\n'; + break; + case 't': + ch = '\t'; + break; + case 'b': + ch = '\b'; + break; + case 'r': + ch = '\r'; + break; + case 'f': + ch = '\f'; + break; + } + } + else { /* a quoted octal */ + register int oct = 0, cnt = 0; + + do { + oct = oct*8 + (ch-'0'); + ch = getc(db_in); + } while (is_oct(ch) && ++cnt < 3); + ungetc(ch, db_in); + ch = oct; + } + return ch&0377; + +} + +static int +get_string(c) + int c; +{ + register int ch; + char buf[512]; + register int len = 0; + + while (ch = getc(db_in), ch != c) { + if (ch == '\n') { + error("newline in string"); + break; + } + if (ch == '\\') { + ch = getc(db_in); + ch = quoted(ch); + } + buf[len++] = ch; + } + buf[len++] = 0; + tok.str = Salloc(buf, (unsigned) len); + return STRING; +} + +static int +print_op(p) + p_tree p; +{ + switch(p->t_oper) { + case OP_UNOP: + switch(p->t_whichoper) { + case E_MIN: + fputs("-", db_out); + print_node(p->t_args[0], 0); + break; + case E_PLUS: + fputs("+", db_out); + print_node(p->t_args[0], 0); + break; + case E_NOT: + fputs("~", db_out); + print_node(p->t_args[0], 0); + break; + case E_DEREF: + fputs("*", db_out); + print_node(p->t_args[0], 0); + break; + } + break; + case OP_BINOP: + fputs("(", db_out); + print_node(p->t_args[0], 0); + switch(p->t_whichoper) { + case E_AND: + fputs("&&", db_out); + break; + case E_OR: + fputs("||", db_out); + break; + case E_ZDIV: + fputs("/", db_out); + break; + case E_ZMOD: + fputs("%", db_out); + break; + case E_DIV: + fputs(" div ", db_out); + break; + case E_MOD: + fputs(" mod ", db_out); + break; + case E_IN: + fputs(" in ", db_out); + break; + case E_PLUS: + fputs("+", db_out); + break; + case E_MIN: + fputs("-", db_out); + break; + case E_MUL: + fputs("*", db_out); + break; + case E_EQUAL: + fputs("==", db_out); + break; + case E_NOTEQUAL: + fputs("!=", db_out); + break; + case E_LTEQUAL: + fputs("<=", db_out); + break; + case E_GTEQUAL: + fputs(">=", db_out); + break; + case E_LT: + fputs("<", db_out); + break; + case E_GT: + fputs(">", db_out); + break; + case E_SELECT: + fputs(".", db_out); + break; + } + print_node(p->t_args[1], 0); + fputs(")", db_out); + break; + } +} diff --git a/util/grind/dump.c b/util/grind/dump.c new file mode 100644 index 00000000..5f6c0c22 --- /dev/null +++ b/util/grind/dump.c @@ -0,0 +1,88 @@ +/* $Header$ */ + +#include +#include + +#include "operator.h" +#include "position.h" +#include "tree.h" +#include "message.h" +#include "type.h" +#include "expr.h" + +extern long pointer_size; +extern p_tree get_from_item_list(); + +struct dump { + char *globals, *stack; + struct message_hdr mglobal, mstack; + struct dump *next; +}; + +static struct dump *last_dump; + +/* dumping and restoring of child process. +*/ +do_dump(p) + p_tree p; +{ + struct dump *d = (struct dump *) malloc(sizeof(struct dump)); + + if (! d) { + error("could not allocate enough memory"); + return; + } + if (! get_dump(&d->mglobal, &d->globals, &d->mstack, &d->stack)) { + free((char *) d); + return; + } + p->t_args[0] = (struct tree *) d; + p->t_address = (t_addr) get_int(d->mglobal.m_buf+PC_OFF*pointer_size, pointer_size, T_UNSIGNED); + add_to_item_list(p); + d->next = last_dump; + last_dump = d; +} + +/* dumping and restoring of child process. +*/ +do_restore(p) + p_tree p; +{ + struct dump *d; + + if (p->t_args[0]) { + p = get_from_item_list((int) p->t_args[0]->t_ival); + if (!p || p->t_oper != OP_DUMP) { + error("no such dump"); + return; + } + d = (struct dump *) p->t_args[0]; + } + else d = last_dump; + + if (! d) { + error("no dumps"); + return; + } + + if (! put_dump(&d->mglobal, d->globals, &d->mstack, d->stack)) { + } + do_items(); +} + +free_dump(p) + p_tree p; +{ + struct dump *d = (struct dump *) p->t_args[0]; + + free(d->globals); + free(d->stack); + if (d == last_dump) last_dump = d->next; + else { + register struct dump *d1 = last_dump; + + while (d1->next != d) d1 = d1->next; + d1->next = d->next; + } + free((char *) d); +} diff --git a/util/grind/op_tools.amk b/util/grind/op_tools.amk new file mode 100644 index 00000000..fd5b0476 --- /dev/null +++ b/util/grind/op_tools.amk @@ -0,0 +1,14 @@ +MAKE_OPS = make.ops; + +%instance deftypesuffix(op_tab, '%.ot'); + +%tool gen_ops ( + ops: %in [type = op_tab]; + cfile: %out [type = C-src] => ops.c; + hfile: %out [type = C-incl] => ops.h; + mkops: %in [type = command] => $MAKE_OPS; +) +{ + exec($mkops, args => $ops); + echo({$cfile, 'and', $hfile, 'created'}); +}; diff --git a/util/grind/sizes.h b/util/grind/sizes.h new file mode 100644 index 00000000..93a16a1f --- /dev/null +++ b/util/grind/sizes.h @@ -0,0 +1,10 @@ +/* $Header$ */ + +/* For the time being ... */ + +#define SZ_INT 4 +#define SZ_SHORT 2 +#define SZ_POINTER 4 +#define SZ_LONG 4 +#define SZ_FLOAT 4 +#define SZ_DOUBLE 8 diff --git a/util/grind/tok_tools.amk b/util/grind/tok_tools.amk new file mode 100644 index 00000000..48d4cb35 --- /dev/null +++ b/util/grind/tok_tools.amk @@ -0,0 +1,15 @@ +MAKE_TOKFILE = make.tokfile; +MAKE_TOKCASE = make.tokcase; + +%tool gen_tokens ( + csrc: %in [type = C-src, gen_tokens, persistent]; + tokfile: %out [type = LLgen-src] => get($csrc, LL-dest); + symbols: %out [type = C-src] => get($csrc, cc-dest); + mktok: %in [type = command] => $MAKE_TOKFILE; + mkcase: %in [type = command] => $MAKE_TOKCASE; +) +{ + exec($mktok, stdin => $csrc, stdout => $tokfile); + exec($mkcase, stdin => $csrc, stdout => $symbols); + echo({$tokfile, 'and', $symbols, 'created'}); +}; diff --git a/util/grind/value.c b/util/grind/value.c new file mode 100644 index 00000000..8262f8fc --- /dev/null +++ b/util/grind/value.c @@ -0,0 +1,182 @@ +/* $Header$ */ + +#include +#include + +#include "position.h" +#include "scope.h" +#include "idf.h" +#include "symbol.h" +#include "type.h" +#include "message.h" +#include "langdep.h" +#include "expr.h" + +int stack_offset; /* for up and down commands */ + +extern long pointer_size; +extern t_addr *get_EM_regs(); +extern char *memcpy(); + +/* Get the address of the object indicated by sym. + Return 0 on failure, + address on success. + *psize will contain size of object. +*/ +t_addr +get_addr(sym, psize) + register p_symbol sym; + long *psize; +{ + p_type tp = sym->sy_type; + long size = tp->ty_size; + t_addr *EM_regs; + int i; + p_scope sc, symsc; + + *psize = size; + switch(sym->sy_class) { + case VAR: + /* exists if child exists; nm_value contains addres */ + return (t_addr) sym->sy_name.nm_value; + case VARPAR: + case LOCVAR: + /* first find the stack frame in which it resides */ + symsc = base_scope(sym->sy_scope); + + /* now symsc contains the scope where the storage for sym is + allocated. Now find it on the stack of child. + */ + i = stack_offset; + for (;;) { + sc = 0; + if (! (EM_regs = get_EM_regs(i++))) { + return 0; + } + if (! EM_regs[1]) { + error("%s not available", sym->sy_idf->id_text); + return 0; + } + sc = base_scope(get_scope_from_addr(EM_regs[2])); + if (! sc || sc->sc_start > EM_regs[2]) { + error("%s not available", sym->sy_idf->id_text); + sc = 0; + return 0; + } + if (sc == symsc) break; /* found it */ + } + + if (sym->sy_class == LOCVAR) { + /* Either local variable or value parameter */ + return EM_regs[sym->sy_name.nm_value < 0 ? 0 : 1] + + (t_addr) sym->sy_name.nm_value; + } + + /* If we get here, we have a var parameter. Get the parameters + of the current procedure invocation. + */ + { + p_type proctype = sc->sc_definedby->sy_type; + t_addr a; + char *AB; + + size = proctype->ty_nbparams; + if (has_static_link(sc)) size += pointer_size; + AB = malloc((unsigned) size); + if (! AB) { + error("could not allocate enough memory"); + break; + } + if (! get_bytes(size, EM_regs[1], AB)) { + break; + } + if ((size = tp->ty_size) == 0) { + size = compute_size(tp, AB); + *psize = size; + } + a = (t_addr) get_int(AB+sym->sy_name.nm_value, pointer_size, T_UNSIGNED); + free(AB); + return a; + } + default: + error("%s is not a variable", sym->sy_idf->id_text); + break; + } + return 0; +} + +/* Get the value of the symbol indicated by sym. + Return 0 on failure, + 1 on success. + On success, 'buf' contains the value, and 'size' contains the size. + For 'buf', storage is allocated by malloc; this storage must + be freed by caller (I don't like this any more than you do, but caller + does not know sizes). +*/ +int +get_value(sym, buf, psize) + register p_symbol sym; + char **buf; + long *psize; +{ + p_type tp = sym->sy_type; + int retval = 0; + t_addr a; + long size = tp->ty_size; + + *buf = 0; + switch(sym->sy_class) { + case CONST: + *buf = malloc((unsigned) size); + if (! *buf) { + error("could not allocate enough memory"); + break; + } + switch(tp->ty_class) { + case T_REAL: + put_real(*buf, size, sym->sy_const.co_rval); + break; + case T_INTEGER: + case T_SUBRANGE: + case T_UNSIGNED: + case T_ENUM: + put_int(*buf, size, sym->sy_const.co_ival); + break; + case T_SET: + memcpy(*buf, sym->sy_const.co_setval, (int) size); + break; + case T_STRING: + memcpy(*buf, sym->sy_const.co_sval, (int) size); + break; + default: + fatal("strange constant"); + } + retval = 1; + break; + case VAR: + case VARPAR: + case LOCVAR: + a = get_addr(sym, psize); + if (a) { + size = *psize; + *buf = malloc((unsigned) size); + if (! *buf) { + error("could not allocate enough memory"); + break; + } + if (get_bytes(size, a, *buf)) { + retval = 1; + } + } + break; + } + + if (retval == 0) { + if (*buf) free(*buf); + *buf = 0; + *psize = 0; + } + else *psize = size; + + return retval; +} diff --git a/util/int/Makefile b/util/int/Makefile new file mode 100644 index 00000000..c0ab33a8 --- /dev/null +++ b/util/int/Makefile @@ -0,0 +1,175 @@ +# $Header$ + +EM = ../..# # EM tree + +CC = cc# # C comp used for compiling the interpreter +CFLAGS = -O# # passed to C compiler +LFLAGS = # # passed to loader + +IDIRS = -I$(EM)/h# # passed to C compiler and lint + +LINT = lint# # lint to be used +LINTFLAGS = -h# # passed to lint + +INT = ./int# # name of resulting interpreter + +IP_SPEC = $(EM)/etc/ip_spec.t +TRAPS = $(EM)/etc/traps +APP_A = $(EM)/doc/int/appA # to be moved later + +SRC = alloc.c core.c data.c do_array.c do_branch.c do_comp.c do_conv.c \ + do_fpar.c do_incdec.c do_intar.c do_load.c do_logic.c do_misc.c \ + do_proc.c do_ptrar.c do_sets.c do_store.c do_unsar.c dump.c \ + disassemble.c fra.c global.c init.c io.c log.c m_ioctl.c m_sigtrp.c \ + main.c moncalls.c monstruct.c proctab.c read.c rsb.c segment.c \ + stack.c switch.c tally.c text.c trap.c warn.c + +OBJ = alloc.o core.o data.o do_array.o do_branch.o do_comp.o do_conv.o \ + do_fpar.o do_incdec.o do_intar.o do_load.o do_logic.o do_misc.o \ + do_proc.o do_ptrar.o do_sets.o do_store.o do_unsar.o dump.o \ + disassemble.o fra.o global.o init.o io.o log.o m_ioctl.o m_sigtrp.o \ + main.o moncalls.o monstruct.o proctab.o read.o rsb.o segment.o \ + stack.o switch.o tally.o text.o trap.o warn.o + +HDR = alloc.h fra.h global.h linfil.h log.h mem.h memdirect.h monstruct.h \ + opcode.h proctab.h read.h rsb.h shadow.h text.h trap.h \ + logging.h debug.h nofloat.h segcheck.h sysidf.h v7ioctl.h \ + e.out.h# should be in $(EM)/h or so, or in $(EM/h/em_abs.h + +.SUFFIXES: .o +.c.o: + $(CC) $(CFLAGS) $(IDIRS) -c $< + + +# Main entries +all: test + +install: $(INT) + cp $(INT) $(EM)/bin/int + cp int.1 $(EM)/man/int.1 + +cmp: $(INT) + -cmp $(INT) $(EM)/bin/int + -cmp int.1 $(EM)/man/int.1 + +test: $(INT) test/awa.em22 test/awa.em24 test/awa.em44 + @rm -f int.mess + -echo 3 5 7 2 -1 | time $(INT) test/awa.em22 + cat int.mess + @rm -f int.mess + -echo 3 5 7 2 -1 | time $(INT) test/awa.em24 + cat int.mess + @rm -f int.mess + -echo 3 5 7 2 -1 | time $(INT) test/awa.em44 + cat int.mess + +$(INT): $(OBJ) Makefile + $(CC) $(LFLAGS) -o $(INT) $(OBJ) + @size $(INT) + + +# Generated files +trap_msg: M.trap_msg $(TRAPS) + M.trap_msg $(TRAPS) + +warn_msg: M.warn_msg $(APP_A) + M.warn_msg $(APP_A) + +warn.h: M.warn_h $(APP_A) + M.warn_h $(APP_A) + +switch/DoCases: + (cd switch; make DoCases) + +switch/PrCases: + (cd switch; make PrCases) + +test/awa.em22: + (cd test; make awa.em22) + +test/awa.em24: + (cd test; make awa.em24) + +test/awa.em44: + (cd test; make awa.em44) + + +# Auxiliary entries +lint: $(SRC) trap_msg warn_msg warn.h switch/DoCases switch/PrCases + $(LINT) $(LINTFLAGS) $(IDIRS) $(SRC) -lc + +tags: $(HDR) $(SRC) + ctags $(HDR) $(SRC) + +MFILES = M.trap_msg M.warn_h M.warn_msg + +ALL = READ_ME Makefile $(MFILES) $(HDR) $(SRC) +DISTR = $(ALL) int.1 switch test + +print: + @pr $(ALL) + +pr: print + +opr: + make pr | opr + +distr: .distr + (cd switch; make distr) + (cd test; make distr) + +.distr: Makefile + echo $(DISTR) | tr ' ' '\012' >.distr + +clean: + rm -f core mon.out int.mess int.log int.core int.tally \ + trap_msg warn_msg warn.h tags print \ + $(OBJ) $(INT) + (cd switch; make clean) + (cd test; make clean) + +bare: clean + (cd switch; make bare) + + +#---------------------------------------------------------------- +alloc.o: alloc.h debug.h global.h +core.o: fra.h global.h logging.h shadow.h +data.o: alloc.h global.h log.h logging.h mem.h memdirect.h nofloat.h shadow.h trap.h warn.h +disassemble.o: alloc.h global.h memdirect.h opcode.h proctab.h switch/PrCases +do_array.o: fra.h global.h log.h logging.h mem.h text.h trap.h +do_branch.o: fra.h global.h log.h logging.h mem.h text.h trap.h warn.h +do_comp.o: fra.h global.h log.h logging.h mem.h nofloat.h shadow.h text.h trap.h warn.h +do_conv.o: fra.h global.h log.h logging.h mem.h nofloat.h text.h trap.h warn.h +do_fpar.o: fra.h global.h log.h logging.h mem.h nofloat.h text.h trap.h warn.h +do_incdec.o: fra.h global.h log.h logging.h mem.h nofloat.h text.h trap.h warn.h +do_intar.o: fra.h global.h log.h logging.h mem.h text.h trap.h warn.h +do_load.o: fra.h global.h log.h logging.h mem.h rsb.h text.h trap.h warn.h +do_logic.o: fra.h global.h log.h logging.h mem.h shadow.h text.h trap.h warn.h +do_misc.o: fra.h global.h linfil.h log.h logging.h mem.h memdirect.h read.h rsb.h shadow.h text.h trap.h warn.h +do_proc.o: fra.h global.h linfil.h log.h logging.h mem.h memdirect.h proctab.h rsb.h shadow.h text.h trap.h warn.h +do_ptrar.o: fra.h global.h log.h logging.h mem.h segcheck.h text.h trap.h warn.h +do_sets.o: fra.h global.h log.h logging.h mem.h text.h trap.h +do_store.o: fra.h global.h log.h logging.h mem.h text.h trap.h warn.h +do_unsar.o: fra.h global.h log.h logging.h mem.h text.h trap.h warn.h +dump.o: fra.h global.h linfil.h log.h logging.h mem.h memdirect.h proctab.h rsb.h shadow.h text.h +fra.o: alloc.h fra.h global.h logging.h mem.h shadow.h +global.o: global.h +init.o: alloc.h global.h log.h logging.h mem.h read.h shadow.h trap.h warn.h +io.o: global.h linfil.h logging.h mem.h +log.o: global.h linfil.h logging.h +m_ioctl.o: global.h mem.h sysidf.h v7ioctl.h warn.h +m_sigtrp.o: global.h log.h logging.h trap.h warn.h +main.o: e.out.h global.h log.h logging.h nofloat.h opcode.h read.h rsb.h text.h trap.h warn.h +moncalls.o: alloc.h global.h log.h logging.h mem.h shadow.h sysidf.h trap.h warn.h +monstruct.o: global.h mem.h monstruct.h sysidf.h v7ioctl.h +proctab.o: alloc.h global.h log.h logging.h proctab.h +read.o: e.out.h global.h log.h logging.h mem.h nofloat.h read.h shadow.h text.h warn.h +rsb.o: global.h linfil.h logging.h mem.h proctab.h rsb.h shadow.h warn.h +segment.o: alloc.h global.h mem.h segcheck.h +stack.o: alloc.h global.h log.h logging.h mem.h memdirect.h nofloat.h rsb.h shadow.h trap.h warn.h +switch.o: global.h opcode.h switch/DoCases text.h trap.h warn.h +tally.o: alloc.h global.h linfil.h +text.o: alloc.h global.h proctab.h read.h text.h trap.h warn.h +trap.o: fra.h global.h linfil.h log.h logging.h mem.h rsb.h shadow.h trap.h trap_msg warn.h +warn.o: alloc.h global.h linfil.h log.h logging.h warn.h warn_msg diff --git a/util/int/switch/Makefile b/util/int/switch/Makefile new file mode 100644 index 00000000..25aa6188 --- /dev/null +++ b/util/int/switch/Makefile @@ -0,0 +1,54 @@ +# $Header$ + +EM = ../../.. +IP_SPEC = $(EM)/etc/ip_spec.t +CFLAGS = -I$(EM) + +SRC = mkiswitch.c mkswitch.c +OBJ = mkiswitch.o mkswitch.o + +mkiswitch: mkiswitch.o + $(CC) -o mkiswitch mkiswitch.o $(EM)/lib/em_data.a + +mkswitch: mkswitch.o + $(CC) -o mkswitch mkswitch.o + +DoCases: mkiswitch $(IP_SPEC) + mkiswitch Do $(IP_SPEC) DoCases + wc DoCases + +PrCases: mkswitch $(IP_SPEC) + mkswitch Pr $(IP_SPEC) PrCases + wc PrCases + +lint: + lint $(SRC) + +distr: .distr + +.distr: Makefile + echo READ_ME Makefile $(SRC) | tr ' ' '\012' >.distr + +.SUFFIXES: .o +.c.o: + $(CC) $(CFLAGS) -c $< + +clean: # NOT the cases files ! + rm -f a.out core $(OBJ) mkswitch mkiswitch + +bare: clean + rm -f DoCases PrCases + +all: mkswitch + +install: + echo "Nothing to install" + +cmp: + echo "Nothing to compare" + +pr: + @pr READ_ME Makefile $(SRC) + +opr: + make pr | opr diff --git a/util/int/test/Makefile b/util/int/test/Makefile new file mode 100644 index 00000000..0bf41bb9 --- /dev/null +++ b/util/int/test/Makefile @@ -0,0 +1,34 @@ +# $Header$ + +EM = ../../..# # EM tree + +.SUFFIXES: .em22 .em24 .em44 + +.c.em22: + $(EM)/bin/em22 $*.c -o $*.em22 + +.p.em22: + $(EM)/bin/em22 $*.p -o $*.em22 + +.c.em24: + $(EM)/bin/em24 $*.c -o $*.em24 + +.p.em24: + $(EM)/bin/em24 $*.p -o $*.em24 + +.c.em44: + $(EM)/bin/em44 $*.c -o $*.em44 + +.p.em44: + $(EM)/bin/em44 $*.p -o $*.em44 + +clean: + rm -f e.out core mon.out int.mess int.log int.core int.tally \ + *.k *.m *.o *.s *.em?? a.out + +distr: .distr + +.distr: + echo *.[cp] Makefile READ_ME | tr ' ' '\012' > .distr + +all install cmp pr opr: diff --git a/util/led/Makefile b/util/led/Makefile new file mode 100644 index 00000000..b0feaf80 --- /dev/null +++ b/util/led/Makefile @@ -0,0 +1,103 @@ +# +# Author: L.J. Bekema @ VU Informatica, Amsterdam +# + +# Definitions for the making programs. + +EMHOME = ../.. +LIBDIR= $(EMHOME)/lib +MODLIBDIR = $(EMHOME)/modules/lib +PREFLAGS= -I$(EMHOME)/h -DNDEBUG -DNASSERT +CFLAGS = $(PREFLAGS) -O +LDFLAGS = +LDLIBS = $(MODLIBDIR)/libstring.a $(MODLIBDIR)/libobject.a +LINTFLAGS=-phbxa $(PREFLAGS) +PR = pr +PRFLAGS = + +# Some convenient macro definitions. + +CFILES = archive.c error.c extract.c finish.c main.c memory.c\ + output.c read.c relocate.c save.c scan.c sym.c write.c +HFILES = assert.h const.h debug.h defs.h memory.h orig.h scan.h +OFILES = archive.o error.o extract.o finish.o main.o memory.o\ + output.o read.o relocate.o save.o scan.o sym.o write.o + +# Things that can be made. + +led: $(OFILES) + $(CC) $(LDFLAGS) $(OFILES) $(LDLIBS) -o led + +install:led + rm -f $(LIBDIR)/em_led $(EMHOME)/man/led.6 $(EMHOME)/man/ack.out.5 + cp led $(LIBDIR)/em_led + cp led.6 $(EMHOME)/man/led.6 + cp ack.out.5 $(EMHOME)/man/ack.out.5 + +cmp: led + cmp led $(LIBDIR)/em_led + +lint: + lint $(LINTFLAGS) $(CFILES) + +pr: $(CFILES) $(HFILES) mach.c + $(PR) $(PRFLAGS) $? + @touch pr +opr: + make pr | opr + +clean: + rm -f Out *.o led nohup.out + +depend: + makedepend $(CFILES) + +# The next lines are generated automatically. +# AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO +archive.o: const.h +archive.o: debug.h +archive.o: defs.h +archive.o: memory.h +error.o: const.h +extract.o: const.h +extract.o: debug.h +extract.o: defs.h +extract.o: memory.h +extract.o: orig.h +extract.o: scan.h +finish.o: const.h +finish.o: defs.h +finish.o: memory.h +finish.o: orig.h +finish.o: scan.h +main.o: const.h +main.o: debug.h +main.o: defs.h +main.o: memory.h +main.o: orig.h +memory.o: assert.h +memory.o: const.h +memory.o: debug.h +memory.o: mach.c +memory.o: memory.h +output.o: const.h +output.o: memory.h +read.o: assert.h +read.o: const.h +relocate.o: const.h +relocate.o: debug.h +relocate.o: defs.h +relocate.o: orig.h +save.o: assert.h +save.o: const.h +save.o: memory.h +scan.o: assert.h +scan.o: const.h +scan.o: memory.h +scan.o: scan.h +sym.o: const.h +sym.o: memory.h +write.o: assert.h +write.o: const.h +write.o: memory.h +write.o: orig.h diff --git a/util/led/READ_ME b/util/led/READ_ME new file mode 100644 index 00000000..e612fa34 --- /dev/null +++ b/util/led/READ_ME @@ -0,0 +1,600 @@ +You may want to change mach.c in this directory. + +Archives MUST have a table of contents. Arch in subdirectory arch +automatically makes one when you change an archive. + +Several changes in the assembler were needed to have it generate the +necessary output. +A contextual diff follows. You can apply them as follows: +patch -d /usr/em/philips/mach/68000/as < READ_ME + +*** comm0.h.old Thu Dec 6 16:18:39 1984 +--- comm0.h Thu Dec 6 17:49:51 1984 +*************** +*** 213,218 + + /* + * extra type bits out of S_ETC, internal use only + * S_COM: + * - symbols declared by .comm + * S_VAR: + +--- 213,219 ----- + + /* + * extra type bits out of S_ETC, internal use only ++ #ifndef DUK + * S_COM: + * - symbols declared by .comm + #endif DUK +*************** +*** 215,220 + * extra type bits out of S_ETC, internal use only + * S_COM: + * - symbols declared by .comm + * S_VAR: + * - type not known at end of PASS_1 (S_VAR|S_UND) + * - value not known at end of PASS_2 (S_VAR|S_ABS) + +--- 216,222 ----- + #ifndef DUK + * S_COM: + * - symbols declared by .comm ++ #endif DUK + * S_VAR: + * - type not known at end of PASS_1 (S_VAR|S_UND) + * - value not known at end of PASS_2 (S_VAR|S_ABS) +*************** +*** 221,226 + * S_DOT: + * - dot expression + */ + #define S_COM 0x0100 + #define S_VAR 0x0200 + #define S_DOT 0x0400 + +--- 223,229 ----- + * S_DOT: + * - dot expression + */ ++ #ifndef DUK + #define S_COM 0x0100 + #endif DUK + #define S_VAR 0x0200 +*************** +*** 222,227 + * - dot expression + */ + #define S_COM 0x0100 + #define S_VAR 0x0200 + #define S_DOT 0x0400 + /* should be tested by preprocessor + +--- 225,231 ----- + */ + #ifndef DUK + #define S_COM 0x0100 ++ #endif DUK + #define S_VAR 0x0200 + #define S_DOT 0x0400 + /* should be tested by preprocessor +*** comm2.y.old Thu Dec 6 16:19:07 1984 +--- comm2.y Thu Dec 6 16:02:19 1984 +*************** +*** 229,234 + { + #ifdef RELOCATION + if (rflag != 0 && PASS_RELO) + newrelo($1.typ, (int)$0); + #endif + emitx($1.val, (int)$0); + +--- 229,239 ----- + { + #ifdef RELOCATION + if (rflag != 0 && PASS_RELO) ++ #ifdef DUK ++ newrelo($1.typ, ++ (int)$0 | RELBR | RELWR ++ ); ++ #else DUK + newrelo($1.typ, (int)$0); + #endif DUK + #endif +*************** +*** 230,235 + #ifdef RELOCATION + if (rflag != 0 && PASS_RELO) + newrelo($1.typ, (int)$0); + #endif + emitx($1.val, (int)$0); + } + +--- 235,241 ----- + ); + #else DUK + newrelo($1.typ, (int)$0); ++ #endif DUK + #endif + emitx($1.val, (int)$0); + } +*************** +*** 237,242 + { + #ifdef RELOCATION + if (rflag != 0 && PASS_RELO) + newrelo($3.typ, (int)$0); + #endif + emitx($3.val, (int)$0); + +--- 243,253 ----- + { + #ifdef RELOCATION + if (rflag != 0 && PASS_RELO) ++ #ifdef DUK ++ newrelo($3.typ, ++ (int)$0 | RELBR | RELWR ++ ); ++ #else DUK + newrelo($3.typ, (int)$0); + #endif DUK + #endif +*************** +*** 238,243 + #ifdef RELOCATION + if (rflag != 0 && PASS_RELO) + newrelo($3.typ, (int)$0); + #endif + emitx($3.val, (int)$0); + } + +--- 249,255 ----- + ); + #else DUK + newrelo($3.typ, (int)$0); ++ #endif DUK + #endif + emitx($3.val, (int)$0); + } +*** comm3.c.old Wed Jul 11 09:22:24 1984 +--- comm3.c Fri Dec 7 13:06:26 1984 +*************** +*** 11,16 + + struct outhead outhead = { + O_MAGIC, O_STAMP, 0 + #ifdef BYTES_REVERSED + | HF_BREV + #endif + +--- 11,17 ----- + + struct outhead outhead = { + O_MAGIC, O_STAMP, 0 ++ #ifndef DUK + #ifdef BYTES_REVERSED + | HF_BREV + #endif +*************** +*** 17,22 + #ifdef WORDS_REVERSED + | HF_WREV + #endif + }; + + #include "y.tab.h" + +--- 18,24 ----- + #ifdef WORDS_REVERSED + | HF_WREV + #endif ++ #endif DUK + }; + + #include "y.tab.h" +*** comm5.c.old Thu Dec 6 16:19:40 1984 +--- comm5.c Thu Oct 11 14:03:27 1984 +*************** +*** 162,167 + #endif + case STRING: + p = stringbuf; + *p++ = n = getc(tempfile); break; + case OP_EQ: + case OP_NE: + +--- 162,172 ----- + #endif + case STRING: + p = stringbuf; ++ #ifdef DUK ++ *p++ = n = getc(tempfile); ++ p[n] = '\0'; ++ break; ++ #else DUK + *p++ = n = getc(tempfile); break; + #endif DUK + case OP_EQ: +*************** +*** 163,168 + case STRING: + p = stringbuf; + *p++ = n = getc(tempfile); break; + case OP_EQ: + case OP_NE: + case OP_LE: + +--- 168,174 ----- + break; + #else DUK + *p++ = n = getc(tempfile); break; ++ #endif DUK + case OP_EQ: + case OP_NE: + case OP_LE: +*************** +*** 354,359 + break; + if (c == '\\') + c = inescape(); + if (p >= &stringbuf[STRINGMAX]) + fatal("string buffer overflow"); + *p++ = c; + +--- 360,368 ----- + break; + if (c == '\\') + c = inescape(); ++ #ifdef DUK ++ if (p >= &stringbuf[STRINGMAX - 1]) ++ #else DUK + if (p >= &stringbuf[STRINGMAX]) + #endif DUK + fatal("string buffer overflow"); +*************** +*** 355,360 + if (c == '\\') + c = inescape(); + if (p >= &stringbuf[STRINGMAX]) + fatal("string buffer overflow"); + *p++ = c; + } + +--- 364,370 ----- + if (p >= &stringbuf[STRINGMAX - 1]) + #else DUK + if (p >= &stringbuf[STRINGMAX]) ++ #endif DUK + fatal("string buffer overflow"); + *p++ = c; + } +*************** +*** 359,364 + *p++ = c; + } + stringbuf[0] = p - stringbuf - 1; + return(STRING); + } + + +--- 369,377 ----- + *p++ = c; + } + stringbuf[0] = p - stringbuf - 1; ++ #ifdef DUK ++ *p = '\0'; ++ #endif DUK + return(STRING); + } + +*** comm6.c.old Thu Dec 6 16:20:22 1984 +--- comm6.c Wed Oct 3 15:59:31 1984 +*************** +*** 106,111 + sp = §[typ - S_MIN]; + sp->s_item = ip; + sp->s_lign = ALIGNSECT; + ip->i_type = typ | S_EXT; + ip->i_valu = 0; + } else if (typ >= S_MIN) { + +--- 106,114 ----- + sp = §[typ - S_MIN]; + sp->s_item = ip; + sp->s_lign = ALIGNSECT; ++ #ifdef DUK ++ ip->i_type = typ; ++ #else DUK + ip->i_type = typ | S_EXT; + #endif DUK + ip->i_valu = 0; +*************** +*** 107,112 + sp->s_item = ip; + sp->s_lign = ALIGNSECT; + ip->i_type = typ | S_EXT; + ip->i_valu = 0; + } else if (typ >= S_MIN) { + sp = §[typ - S_MIN]; + +--- 110,116 ----- + ip->i_type = typ; + #else DUK + ip->i_type = typ | S_EXT; ++ #endif DUK + ip->i_valu = 0; + } else if (typ >= S_MIN) { + sp = §[typ - S_MIN]; +*************** +*** 180,185 + * for possible relocation + */ + ip->i_valu = outhead.oh_nname; + newsymb(ip->i_name, S_EXT|DOTTYP, (short)0, val); + #endif + } + +--- 184,192 ----- + * for possible relocation + */ + ip->i_valu = outhead.oh_nname; ++ #ifdef DUK ++ newsymb(ip->i_name, S_COM|S_EXT|DOTTYP, (short)0, val); ++ #else DUK + newsymb(ip->i_name, S_EXT|DOTTYP, (short)0, val); + #endif DUK + #endif +*************** +*** 181,186 + */ + ip->i_valu = outhead.oh_nname; + newsymb(ip->i_name, S_EXT|DOTTYP, (short)0, val); + #endif + } + + +--- 188,194 ----- + newsymb(ip->i_name, S_COM|S_EXT|DOTTYP, (short)0, val); + #else DUK + newsymb(ip->i_name, S_EXT|DOTTYP, (short)0, val); ++ #endif DUK + #endif + } + +*************** +*** 255,260 + short s; + { + struct outrelo outrelo; + + if (rflag == 0) + return; + +--- 263,271 ----- + short s; + { + struct outrelo outrelo; ++ #ifdef DUK ++ int iscomm; ++ #endif DUK + + if (rflag == 0) + return; +*************** +*** 272,277 + * b=a + * a: .data2 0 + */ + s &= ~S_COM; + if ((n & RELPC) == 0 && s == S_ABS) + return; + +--- 283,291 ----- + * b=a + * a: .data2 0 + */ ++ #ifdef DUK ++ iscomm = s & S_COM; ++ #endif DUK + s &= ~S_COM; + if ((n & RELPC) == 0 && s == S_ABS) + return; +*************** +*** 285,290 + outrelo.or_type = (char)n; + outrelo.or_sect = (char)DOTTYP; + #ifndef ASLD + if (s == S_UND) { + assert(relonami != 0); + outrelo.or_nami = relonami-1; + +--- 299,307 ----- + outrelo.or_type = (char)n; + outrelo.or_sect = (char)DOTTYP; + #ifndef ASLD ++ #ifdef DUK ++ if (s == S_UND || iscomm) { ++ #else DUK + if (s == S_UND) { + #endif DUK + assert(relonami != 0); +*************** +*** 286,291 + outrelo.or_sect = (char)DOTTYP; + #ifndef ASLD + if (s == S_UND) { + assert(relonami != 0); + outrelo.or_nami = relonami-1; + relonami = 0; + +--- 303,309 ----- + if (s == S_UND || iscomm) { + #else DUK + if (s == S_UND) { ++ #endif DUK + assert(relonami != 0); + outrelo.or_nami = relonami-1; + relonami = 0; +*** comm7.c.old Thu Dec 6 16:20:50 1984 +--- comm7.c Wed Oct 3 16:35:31 1984 +*************** +*** 19,24 + return(ip->i_valu); + return(ip->i_valu + sect[typ].s_base); + #else + if ((ip->i_type & S_TYP) == S_UND) { + if (pass == PASS_3) { + if (relonami != 0) + +--- 19,27 ----- + return(ip->i_valu); + return(ip->i_valu + sect[typ].s_base); + #else ++ #ifdef DUK ++ if ((ip->i_type & S_TYP) == S_UND || (ip->i_type & S_COM)) { ++ #else DUK + if ((ip->i_type & S_TYP) == S_UND) { + #endif DUK + if (pass == PASS_3) { +*************** +*** 20,25 + return(ip->i_valu + sect[typ].s_base); + #else + if ((ip->i_type & S_TYP) == S_UND) { + if (pass == PASS_3) { + if (relonami != 0) + serror("relocation error"); + +--- 23,29 ----- + if ((ip->i_type & S_TYP) == S_UND || (ip->i_type & S_COM)) { + #else DUK + if ((ip->i_type & S_TYP) == S_UND) { ++ #endif DUK + if (pass == PASS_3) { + if (relonami != 0) + serror("relocation error"); +*** mach0.c.old Thu Dec 6 16:21:11 1984 +--- mach0.c Fri Sep 14 14:15:54 1984 +*************** +*** 1,3 + /* @(#)mach0.c 1.5 */ + /* + * Motorola 68000/68010 options + +--- 1,4 ----- ++ #define DUK + /* @(#)mach0.c 1.5 */ + /* + * Motorola 68000/68010 options +*** mach4.c.old Thu Dec 6 16:21:30 1984 +--- mach4.c Thu Dec 6 16:05:00 1984 +*************** +*** 21,26 + fit(fitw($4.val)); + emit2($1 | $2); + #ifdef RELOCATION + newrelo($4.typ, RELPC|RELO2); + #endif + emit2(loww($4.val)); + +--- 21,29 ----- + fit(fitw($4.val)); + emit2($1 | $2); + #ifdef RELOCATION ++ #ifdef DUK ++ newrelo($4.typ, RELPC|RELO2|RELBR|RELWR); ++ #else DUK + newrelo($4.typ, RELPC|RELO2); + #endif DUK + #endif +*************** +*** 22,27 + emit2($1 | $2); + #ifdef RELOCATION + newrelo($4.typ, RELPC|RELO2); + #endif + emit2(loww($4.val)); + } + +--- 25,31 ----- + newrelo($4.typ, RELPC|RELO2|RELBR|RELWR); + #else DUK + newrelo($4.typ, RELPC|RELO2); ++ #endif DUK + #endif + emit2(loww($4.val)); + } +*** mach5.c.old Thu Dec 6 16:21:54 1984 +--- mach5.c Thu Dec 6 16:07:05 1984 +*************** +*** 37,42 + #ifdef RELOCATION + RELOMOVE(relonami, rel_1); + if (flag & ~0xFF) + newrelo(exp_1.typ, flag>>8); + #endif + if (flag & PUTL) + +--- 37,45 ----- + #ifdef RELOCATION + RELOMOVE(relonami, rel_1); + if (flag & ~0xFF) ++ #ifdef DUK ++ newrelo(exp_1.typ, (flag>>8) | RELBR | RELWR); ++ #else DUK + newrelo(exp_1.typ, flag>>8); + #endif DUK + #endif +*************** +*** 38,43 + RELOMOVE(relonami, rel_1); + if (flag & ~0xFF) + newrelo(exp_1.typ, flag>>8); + #endif + if (flag & PUTL) + emit4(exp_1.val); + +--- 41,47 ----- + newrelo(exp_1.typ, (flag>>8) | RELBR | RELWR); + #else DUK + newrelo(exp_1.typ, flag>>8); ++ #endif DUK + #endif + if (flag & PUTL) + emit4(exp_1.val); +*************** +*** 357,362 + fit(fitw(exp.val)); + emit2(opc); + #ifdef RELOCATION + newrelo(exp.typ, RELPC|RELO2); + #endif + emit2(loww(exp.val)); + +--- 361,369 ----- + fit(fitw(exp.val)); + emit2(opc); + #ifdef RELOCATION ++ #ifdef DUK ++ newrelo(exp.typ, RELPC|RELO2|RELBR|RELWR); ++ #else DUK + newrelo(exp.typ, RELPC|RELO2); + #endif DUK + #endif +*************** +*** 358,363 + emit2(opc); + #ifdef RELOCATION + newrelo(exp.typ, RELPC|RELO2); + #endif + emit2(loww(exp.val)); + } + +--- 365,371 ----- + newrelo(exp.typ, RELPC|RELO2|RELBR|RELWR); + #else DUK + newrelo(exp.typ, RELPC|RELO2); ++ #endif DUK + #endif + emit2(loww(exp.val)); + } diff --git a/util/led/byte_order.c b/util/led/byte_order.c new file mode 100644 index 00000000..08120b0b --- /dev/null +++ b/util/led/byte_order.c @@ -0,0 +1,90 @@ +#ifndef lint +static char rcsid[] = "$Header$"; +#endif lint + +#include "const.h" +#include "assert.h" + +bool bytes_reversed = FALSE; +bool words_reversed = FALSE; + +/* + * Determine the byte/word order in shorts/longs, assuming the size of a short + * is 2 chars, and the size of a long is 4 chars. Not all theoretical + * possibilities are tested; only bytes reversed and/or words reversed. + */ +determine_ordering() +{ + short s; + long l; + register char *cp; + register short *sp; + + cp = (char *)&s; + cp[0] = 0x01; cp[1] = 0x02; + if (s != 0x01 + (0x02 << 8)) + bytes_reversed = TRUE; + sp = (short *)&l; + sp[0] = 0x0001; sp[1] = 0x0002; + if (l != 0x0001 + (0x0002L << 16)) + words_reversed = TRUE; +} + +/* + * `Format' is a string of digits indicating how many bytes must be taken + * from `buf' to form an integer of some type. E.g. if the digit is '2', two + * bytes are taken to form a short. + */ +swap(buf, format) + register char *buf; + register char *format; +{ + register char savebyte; + + while (*format) { + switch (*format++) { + case '1': + buf += 1; + break; + case '2': + if (bytes_reversed) { + savebyte = buf[0]; + buf[0] = buf[1]; + buf[1] = savebyte; + } + buf += 2; + break; + case '4': + /* + * Written out to save recursive calls. + */ + if (bytes_reversed && words_reversed) { + savebyte = buf[0]; + buf[0] = buf[3]; + buf[3] = savebyte; + savebyte = buf[1]; + buf[1] = buf[2]; + buf[2] = savebyte; + } else if (bytes_reversed) { + savebyte = buf[0]; + buf[0] = buf[1]; + buf[1] = savebyte; + savebyte = buf[2]; + buf[2] = buf[3]; + buf[3] = savebyte; + } else if (words_reversed) { + savebyte = buf[0]; + buf[0] = buf[2]; + buf[2] = savebyte; + savebyte = buf[1]; + buf[1] = buf[3]; + buf[3] = savebyte; + } + buf += 4; + break; + default: + assert(FALSE); + break; + } + } +} diff --git a/util/led/makedepend b/util/led/makedepend new file mode 100755 index 00000000..3726c27b --- /dev/null +++ b/util/led/makedepend @@ -0,0 +1,23 @@ +: 'Without arguments, this program clears the dependencies between' +: '.o files and included files in Makefile.' +: 'With arguments, it replaces the dependencies between the .o files' +: 'resulting from the argument files, and the included files in Makefile.' +: 'Makefile must contain a line with on it the pattern AUTOAUTOAUTO.' +: 'WARNING: a temporary file is created in the current directory.' +: 'It is however rather unlikely that this file already exists' +grep -s AUTOAUTOAUTO Makefile || { + echo "Makefile has wrong format." 1>&2 + exit 1 +} +for file do + ofile=`echo $file | sed 's/.$/o/'` + grep '^# *include.*"' $file | sed "s/.*\"\(.*\)\".*/$ofile: \1/" +done | sort -u > @@**##$$ +echo "Non-empty line." >> Makefile +ed - Makefile <<'!' +/AUTOAUTOAUTO/+,$d +w +q +! +cat @@**##$$ >> Makefile +rm -f @@**##$$ diff --git a/util/misc/Makefile b/util/misc/Makefile new file mode 100644 index 00000000..143555c3 --- /dev/null +++ b/util/misc/Makefile @@ -0,0 +1,62 @@ +# $Header$ + +EMHOME=../.. +h=$(EMHOME)/h +l=$(EMHOME)/lib +ml=$(EMHOME)/modules/lib +mh=$(EMHOME)/modules/h + +DEC_PATH=decode +ENC_PATH=encode +DATA_PATH=$l/em_data.a +DECLIBS=$(ml)/libread_emkV.a $(ml)/libeme.a $(ml)/liballoc.a $(ml)/libprint.a $(ml)/libstring.a \ + $(ml)/libsystem.a +ENCLIBS=$(ml)/libread_emeV.a $(ml)/libemk.a $(ml)/liballoc.a $(ml)/libprint.a $(ml)/libstring.a \ + $(ml)/libsystem.a +HFILES=$h/em_mnem.h $h/em_spec.h $h/em_pseu.h $h/em_flag.h $h/em_ptyp.h \ + $h/em_mes.h $(mh)/em.h $(mh)/em_comp.h + +CFLAGS=-O -I$(mh) -I$h +LDFLAGS = + +all: $(DEC_PATH) $(ENC_PATH) esize + +$(DEC_PATH): decode.o $(DATA_PATH) + $(CC) $(LDFLAGS) -o $(DEC_PATH) decode.o $(DECLIBS) $(DATA_PATH) + +$(ENC_PATH): encode.o $(DATA_PATH) + $(CC) $(LDFLAGS) -o $(ENC_PATH) encode.o $(ENCLIBS) $(DATA_PATH) + +esize: esize.o + $(CC) -o esize esize.o + +convert.o: $(HFILES) + +encode.o: convert.o + cp convert.o encode.o + +decode.o: convert.o + cp convert.o decode.o + +clean: + rm -f $(DEC_PATH) $(ENC_PATH) esize *.o *.old + +install : all + rm -f $l/em_$(DEC_PATH) $l/em_$(ENC_PATH) $(EMHOME)/bin/esize $(EMHOME)/man/em_decode.6 $(EMHOME)/man/esize.1 + cp $(DEC_PATH) $l/em_$(DEC_PATH) + cp $(ENC_PATH) $l/em_$(ENC_PATH) + cp esize $(EMHOME)/bin/esize + cp em_decode.6 $(EMHOME)/man/em_decode.6 + cp esize.1 $(EMHOME)/man/esize.1 + +cmp : all + -cmp $(DEC_PATH) $l/em_$(DEC_PATH) + -cmp $(ENC_PATH) $l/em_$(ENC_PATH) + -cmp esize $(EMHOME)/bin/esize + -cmp em_decode.6 $(EMHOME)/man/em_decode.6 + -cmp esize.1 $(EMHOME)/man/esize.1 + +opr: + make pr ^ opr +pr: + @pr -n Makefile convert.c esize.c diff --git a/util/misc/decode.c b/util/misc/decode.c new file mode 100644 index 00000000..55950546 --- /dev/null +++ b/util/misc/decode.c @@ -0,0 +1,499 @@ +/* + * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. + * + * This product is part of the Amsterdam Compiler Kit. + * + * Permission to use, sell, duplicate or disclose this software must be + * obtained in writing. Requests for such permissions may be sent to + * + * Dr. Andrew S. Tanenbaum + * Wiskundig Seminarium + * Vrije Universiteit + * Postbox 7161 + * 1007 MC Amsterdam + * The Netherlands + * + */ + +#ifndef NORCSID +static char rcsid[] = "$Header$"; +#endif + +/* + * Decode compact EM assembly language + * + * Author: Johan Stevenson, Vrije Universiteit, Amsterdam + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define get8() ((unsigned)getchar()) + +#define check(x) if (!(x)) fail_check() + +#define MAXSTR 256 + +/* + * global variables + */ + +int opcode; +int offtyp; +long argval; +int dlbval; +char string[MAXSTR]; +int strsiz; + +int wsize; +int psize; +int lineno; +int argnum; +int errors; +char *progname; +char *filename; + +long wordmask[] = { /* allowed bits in a word */ + 0x00000000, + 0x000000FF, + 0x0000FFFF, + 0x00000000, + 0xFFFFFFFF +}; + +long sizemask[] = { /* allowed bits in multiples of 'wsize' */ + 0x00000000, + 0x7FFFFFFF, + 0x7FFFFFFE, + 0x00000000, + 0x7FFFFFFC +}; + +/* + * external tables + */ + +extern char em_flag[]; +extern short em_ptyp[]; +extern char em_mnem[][4]; +extern char em_pseu[][4]; + +/* + * routines + */ + +int get16(); +long get32(); + +main(argc,argv) char **argv; { + + progname = argv[0]; + if (argc >= 2) { + filename = argv[1]; + if (freopen(argv[1],"r",stdin) == NULL) + fatal("can't open %s",argv[1]); + } + if (argc >= 3) + if (freopen(argv[2],"w",stdout) == NULL) + fatal("can't create %s",argv[2]); + if (get16() != sp_magic) + fatal("bad magic word"); + /* In System III the array is called _ctype[] without the trailing '_' */ + (_ctype_+1)['_'] = (_ctype_+1)['a']; + while (nextline()) + ; + return(errors ? -1 : 0); +} + +/* ----- copy ----- */ + +int nextline() { + register t; + + lineno++; + argnum = 1; + switch (t = table1()) { + case EOF: + return(0); + case sp_fmnem: + instr(); + break; + case sp_fpseu: + pseudo(); + break; + case sp_ilb1: + case sp_ilb2: + argnum = 0; + putarg(sp_cst2); + break; + case sp_dlb1: + case sp_dlb2: + case sp_dnam: + argnum = 0; + putarg(t); + break; + default: + error("unknown opcode %d",t); + } + putchar('\n'); + return(1); +} + +instr() { + register i,j,t; + register long l; + + i = opcode - sp_fmnem; + printf(" %s",em_mnem[i]); + j = em_flag[i] & EM_PAR; + if (j == PAR_NO) + return; + t = em_ptyp[j]; + t = getarg(t); + /* + * range checking + */ + switch (j) { + case PAR_N: + check(argval >= 0); + break; + case PAR_G: + if (t != sp_cst2 && t != sp_cst4) + break; + check(argval >= 0); + /* fall through */ + case PAR_L: + l = argval >= 0 ? argval : -argval; + check((l & ~wordmask[psize]) == 0); + break; + case PAR_W: + if (t == sp_cend) + break; + check((argval & ~wordmask[wsize]) == 0); + /* fall through */ + case PAR_S: + check(argval != 0); + /* fall through */ + case PAR_Z: + check((argval & ~sizemask[wsize]) == 0); + break; + case PAR_O: + check(argval != 0); + check((argval & ~sizemask[wsize])==0 || (wsize % argval)==0); + break; + case PAR_B: + t = sp_ilb2; + break; + case PAR_R: + check(argval >= 0 && argval <= 2); + break; + } + putarg(t); +} + +pseudo() { + register i,t; + + i = opcode; + printf(" %s",em_pseu[i - sp_fpseu]); + switch (i) { + case ps_bss: + case ps_hol: + putarg(getarg(cst_ptyp)); + putarg(getarg(val_ptyp)); + putarg(getarg(ptyp(sp_cst2))); + check(argval==0 || argval==1); + break; + case ps_rom: + case ps_con: + putarg(getarg(val_ptyp)); + while ((t = getarg(any_ptyp)) != sp_cend) + putarg(t); + break; + case ps_mes: + putarg(getarg(ptyp(sp_cst2))); + if (argval == ms_emx) { + putarg(getarg(ptyp(sp_cst2))); + check(argval > 0 && argval <= 4); + wsize = (int) argval; + putarg(getarg(ptyp(sp_cst2))); + check(argval > 0 && argval <= 4); + psize = (int) argval; + } + while ((t = getarg(any_ptyp)) != sp_cend) + putarg(t); + break; + case ps_exa: + case ps_ina: + putarg(getarg(sym_ptyp)); + break; + case ps_exp: + case ps_inp: + putarg(getarg(ptyp(sp_pnam))); + break; + case ps_exc: + putarg(getarg(ptyp(sp_cst2))); + putarg(getarg(ptyp(sp_cst2))); + break; + case ps_pro: + putarg(getarg(ptyp(sp_pnam))); + putarg(getarg(cst_ptyp|ptyp(sp_cend))); + break; + case ps_end: + putarg(getarg(cst_ptyp|ptyp(sp_cend))); + break; + default: + error("bad pseudo %d",i); + } +} + +/* ----- input ----- */ + +int getarg(typset) { + register t,argtyp; + + argtyp = t = table2(); + if (t == EOF) + fatal("unexpected EOF"); + t -= sp_fspec; + assert(t >= 0 && t < 16); + t = 1 << t; + if ((typset & t) == 0) + error("bad argument type %d",argtyp); + return(argtyp); +} + +int table1() { + register i; + + i = get8(); + if (i < sp_fmnem+sp_nmnem && i >= sp_fmnem) { + opcode = i; + return(sp_fmnem); + } + if (i < sp_fpseu+sp_npseu && i >= sp_fpseu) { + opcode = i; + return(sp_fpseu); + } + if (i < sp_filb0+sp_nilb0 && i >= sp_filb0) { + argval = i - sp_filb0; + return(sp_ilb2); + } + return(table3(i)); +} + +int table2() { + register i; + + i = get8(); + if (i < sp_fcst0+sp_ncst0 && i >= sp_fcst0) { + argval = i - sp_zcst0; + return(sp_cst2); + } + return(table3(i)); +} + +int table3(i) { + long consiz; + + switch(i) { + case sp_ilb1: + argval = get8(); + break; + case sp_dlb1: + dlbval = get8(); + break; + case sp_dlb2: + dlbval = get16(); + if ( dlbval<0 ) { + error("illegal data label .%d",dlbval); + dlbval=0 ; + } + break; + case sp_cst2: + argval = get16(); + break; + case sp_ilb2: + argval = get16(); + if ( argval<0 ) { + error("illegal instruction label %ld",argval); + argval=0 ; + } + break; + case sp_cst4: + argval = get32(); + break; + case sp_dnam: + case sp_pnam: + getstring(1); + break; + case sp_scon: + getstring(0); + break; + case sp_doff: + offtyp = getarg(sym_ptyp); + getarg(cst_ptyp); + break; + case sp_icon: + case sp_ucon: + case sp_fcon: + getarg(cst_ptyp); + consiz = (long) argval; + getstring(0); + argval = consiz; + break; + } + return(i); +} + +int get16() { + register int l_byte, h_byte; + + l_byte = get8(); + h_byte = get8(); + if ( h_byte>=128 ) h_byte -= 256 ; + return l_byte | (h_byte*256) ; +} + +long get32() { + register long l; + register int h_byte; + + l = get8(); l |= (unsigned)get8()*256 ; l |= get8()*256L*256L ; + h_byte = get8() ; + if ( h_byte>=128 ) h_byte -= 256 ; + return l | (h_byte*256L*256*256L) ; +} + +getstring(ident) { + register char *p; + register n; + + getarg(cst_ptyp); + if (argval < 0 || argval > MAXSTR) + fatal("string/identifier too long"); + strsiz = n = argval; + p = string; + while (--n >= 0) + *p++ = get8(); + if (ident) { + if (!isascii(string[0]) || !isalpha(string[0])) { + identerror(); + return; + } + for (n=strsiz,p=string+1;--n>0;p++) + if (!isascii(*p) || !isalnum(*p)) { + identerror(); + return; + } + } +} + +/* ----- output ----- */ + +putarg(t) { + + if (argnum != 0) + putchar(argnum == 1 ? ' ' : ','); + argnum++; + puttyp(t); +} + +puttyp(t) { + + switch (t) { + case sp_ilb1: + case sp_ilb2: + printf("*%d",(int) argval); + break; + case sp_dlb1: + case sp_dlb2: + printf(".%d",dlbval); + break; + case sp_dnam: + putstr(0,0); + break; + case sp_cst2: + case sp_cst4: + printf("%ld",argval); + break; + case sp_doff: + puttyp(offtyp); + if (argval >= 0) putchar('+'); + printf("%ld",argval); + break; + case sp_pnam: + putstr('$',0); + break; + case sp_scon: + putstr('\'','\''); + break; + case sp_icon: + putstr(0,'I'); + printf("%ld",argval); + break; + case sp_ucon: + putstr(0,'U'); + printf("%ld",argval); + break; + case sp_fcon: + putstr(0,'F'); + printf("%ld",argval); + break; + case sp_cend: + putchar('?'); + break; + } +} + +putstr(c,c2) register c; { + register char *p; + + if (c) + putchar(c); + p = string; + while (--strsiz >= 0) { + c = *p++ & 0377; + if (c >= 040 && c < 0177) { + if (c == '\'' || c == '\\') + putchar('\\'); + putchar(c); + } else + printf("\\%03o",c); + } + if (c2) + putchar(c2); +} + +/* ----- error handling ----- */ + +fail_check() { + error("argument range error"); +} + +identerror() { + error("'%s' is not a correct identifier",string); +} + +/* VARARGS */ +error(s,a1,a2,a3,a4) char *s; { + fprintf(stderr, + "%s: line %d: ", + filename ? filename : progname, + lineno); + fprintf(stderr,s,a1,a2,a3,a4); + fprintf(stderr,"\n"); + errors++; +} + +/* VARARGS */ +fatal(s,a1,a2,a3,a4) char *s; { + error(s,a1,a2,a3,a4); + exit(-1); +} diff --git a/util/misc/encode.c b/util/misc/encode.c new file mode 100644 index 00000000..0aee6277 --- /dev/null +++ b/util/misc/encode.c @@ -0,0 +1,761 @@ +/* + * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. + * + * This product is part of the Amsterdam Compiler Kit. + * + * Permission to use, sell, duplicate or disclose this software must be + * obtained in writing. Requests for such permissions may be sent to + * + * Dr. Andrew S. Tanenbaum + * Wiskundig Seminarium + * Vrije Universiteit + * Postbox 7161 + * 1007 MC Amsterdam + * The Netherlands + * + */ + +#ifndef NORCSID +static char rcsid[] = "$Header$"; +#endif + +/* + * Encode to compact EM assembly language + * + * Author: Johan Stevenson, Vrije Universiteit, Amsterdam + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define put8(x) putchar(x) + +#define check(x) if (!(x)) fail_check() + +#define fit16i(x) ((x) >= 0xFFFF8000 && (x) <= 0x00007FFF) +#define fit8u(x) ((x) >= 0 && (x) <= 0xFF) + +#define MAXSTR 256 +#define HSIZE 256 +#define EMPTY (EOF-1) + +/* + * global variables + */ + +int opcode; +int offtyp; +long argval; +int dlbval; +char string[MAXSTR]; +int strsiz; + +int wsize; +int psize; +int lineno; +int argnum; +int errors; +char *progname; +char *filename = "INPUT"; + +long wordmask[] = { /* allowed bits in a word */ + 0x00000000, + 0x000000FF, + 0x0000FFFF, + 0x00000000, + 0xFFFFFFFF +}; + +long sizemask[] = { /* allowed bits in multiples of 'wsize' */ + 0x00000000, + 0x7FFFFFFF, + 0x7FFFFFFE, + 0x00000000, + 0x7FFFFFFC +}; + +int peekc = EMPTY; +int hashtab[HSIZE]; +jmp_buf recover; + +/* + * external tables + */ + +extern char em_flag[]; +extern short em_ptyp[]; +extern char em_mnem[][4]; +extern char em_pseu[][4]; + +int main(argc,argv) char **argv; { + + progname = argv[0]; + if (argc >= 2) { + filename = argv[1]; + if (freopen(filename,"r",stdin) == NULL) + fatal("can't open %s",filename); + } + if (argc >= 3) + if (freopen(argv[2],"w",stdout) == NULL) + fatal("can't create %s",argv[2]); + init(); + put16(sp_magic); + setjmp(recover); + while (nextline()) + ; + return(errors ? -1 : 0); +} + +/* ----- copy ----- */ + +int nextline() { + register c,i; + + lineno++; + argnum = 1; + c = nextchar(); + if (c == EOF) + return(0); + if (isspace(c) && c != '\n') { + c = nospace(); + if (isalpha(c)) { + inmnem(c); + if (opcode <= sp_lmnem) + instr(); + else + pseudo(); + } else + peekc = c; + } else if (c == '#') { + line_line(); + } else { + peekc = c; + i = gettyp(sym_ptyp | ptyp(sp_cst2) | ptyp(sp_cend)); + switch (i) { + case sp_cst2: + i = (int) argval; + if (i >= 0 && i < sp_nilb0) + put8(i + sp_filb0); + else + putarg(sp_ilb2); + break; + case sp_dlb2: + case sp_dnam: + putarg(i); + break; + case sp_cend: + break; + } + } + if (nospace() != '\n') + syntax("end of line expected"); + return(1); +} + +instr() { + register i,j,t; + register long l; + + i = opcode; + put8(i); + i -= sp_fmnem; + j = em_flag[i] & EM_PAR; + if (j == PAR_NO) + return; + t = em_ptyp[j]; + if (j == PAR_B) + t = ptyp(sp_ilb2); + t = getarg(t); + /* + * range checking + */ + switch (j) { + case PAR_N: + check(argval >= 0); + break; + case PAR_G: + if (t != sp_cst2 && t != sp_cst4) + break; + check(argval >= 0); + /* fall through */ + case PAR_L: + l = argval >= 0 ? argval : -argval; + check((l & ~wordmask[psize]) == 0); + break; + case PAR_W: + if (t == sp_cend) + break; + check((argval & ~wordmask[wsize]) == 0); + /* fall through */ + case PAR_S: + check(argval != 0); + /* fall through */ + case PAR_Z: + check((argval & ~sizemask[wsize]) == 0); + break; + case PAR_O: + check(argval != 0); + check((argval & ~sizemask[wsize])==0 || (wsize % argval)==0); + break; + case PAR_B: + t = sp_cst2; + break; + case PAR_R: + check(argval >= 0 && argval <= 2); + break; + } + putarg(t); +} + +pseudo() { + register i,t; + + i = opcode; + put8(i); + switch (i) { + case ps_bss: + case ps_hol: + putarg(getarg(cst_ptyp)); + putarg(getarg(val_ptyp)); + putarg(getarg(ptyp(sp_cst2))); + check(argval==0 || argval==1); + break; + case ps_rom: + case ps_con: + putarg(getarg(val_ptyp)); + do + putarg(t = getarg(any_ptyp)); + while (t != sp_cend); + break; + case ps_mes: + putarg(getarg(ptyp(sp_cst2))); + if (argval == ms_emx) { + putarg(getarg(ptyp(sp_cst2))); + check(argval > 0 && argval <= 4); + wsize = (int) argval; + putarg(getarg(ptyp(sp_cst2))); + check(argval > 0 && argval <= 4); + psize = (int) argval; + } + do + putarg(t = getarg(any_ptyp)); + while (t != sp_cend); + break; + case ps_exa: + case ps_ina: + putarg(getarg(sym_ptyp)); + break; + case ps_exp: + case ps_inp: + putarg(getarg(ptyp(sp_pnam))); + break; + case ps_exc: + putarg(getarg(ptyp(sp_cst2))); + putarg(getarg(ptyp(sp_cst2))); + break; + case ps_pro: + putarg(getarg(ptyp(sp_pnam))); + putarg(getarg(cst_ptyp|ptyp(sp_cend))); + break; + case ps_end: + putarg(getarg(cst_ptyp|ptyp(sp_cend))); + break; + default: + syntax("bad pseudo %d",i); + } +} + +/* ----- input ----- */ + +int getarg(typset) { + register c; + + if (argnum != 1) { + c = nospace(); + if (c != ',') { + if (c != '\n') + syntax("comma expected"); + peekc = c; + } + } + argnum++; + return(gettyp(typset)); +} + +int gettyp(typset) { + register c,t,sp; + + c = nospace(); + if (c == '\n') { + peekc = c; + sp = sp_cend; + } else if (isdigit(c) || c == '+' || c == '-' || c == '(') { + sp = inexpr1(c); + if (sp == sp_cst4 && fit16i(argval)) + sp = sp_cst2; + } else if (isalpha(c)) { + inname(c); + sp = offsetted(sp_dnam); + } else if (c == '.') { + in15u(); + dlbval = (int) argval; + sp = offsetted(sp_dlb2); + } else if (c == '*') { + in15u(); + sp = sp_ilb2; + } else if (c == '$') { + inname(nextchar()); + sp = sp_pnam; + } else if (c == '"' || c == '\'') { + sp = instring(c); + } else if (c == '?') { + sp = sp_cend; + } else + syntax("operand expected"); + t = sp - sp_fspec; + assert(t >= 0 && t < 16); + t = 1 << t; + if ((typset & t) == 0) + error("bad argument type %d",sp); + return(sp); +} + +int offsetted(sp) { + register c; + + c = nospace(); + if (c == '+' || c == '-') { + gettyp(cst_ptyp); + if (c == '-') + argval = -argval; + offtyp = sp; + return(sp_doff); + } + peekc = c; + return(sp); +} + +inname(c) register c; { + register char *p; + + if (isalpha(c) == 0) + syntax("letter expected"); + p = string; + do { + if (p < &string[MAXSTR-1]) + *p++ = c; + c = nextchar(); + } while (isalnum(c)); + peekc = c; + *p = '\0'; + strsiz = p - string; +} + +int inmnem(c) register c; { + register unsigned h; + register i; + + inname(c); + h = hash(string); + for (;;) { + h++; + h %= HSIZE; + i = hashtab[h]; + if (i == 0) + syntax("bad mnemonic"); + if (i <= sp_lmnem) { + assert(i >= sp_fmnem); + if (strcmp(string,em_mnem[i - sp_fmnem]) != 0) + continue; + return(opcode = i); + } + assert(i <= sp_lpseu && i >= sp_fpseu); + if (strcmp(string,em_pseu[i - sp_fpseu]) != 0) + continue; + return(opcode = i); + } +} + +int inexpr1(c) register c; { + long left; + + if ((c = inexpr2(c)) != sp_cst4) + return(c); + for (;;) { + c = nospace(); + if (c != '+' && c != '-') { + peekc = c; + break; + } + left = argval; + if (inexpr2(nospace()) != sp_cst4) + syntax("term expected"); + if (c == '+') + argval += left; + else + argval = left - argval; + } + return(sp_cst4); +} + +int inexpr2(c) register c; { + long left; + + if ((c = inexpr3(c)) != sp_cst4) + return(c); + for (;;) { + c = nospace(); + if (c != '*' && c != '/' && c != '%') { + peekc = c; + break; + } + left = argval; + if (inexpr3(nospace()) != sp_cst4) + syntax("factor expected"); + if (c == '*') + argval *= left; + else if (c == '/') + argval = left / argval; + else + argval = left % argval; + } + return(sp_cst4); +} + +inexpr3(c) register c; { + + if (c == '(') { + if (inexpr1(nospace()) != sp_cst4) + syntax("expression expected"); + if (nospace() != ')') + syntax("')' expected"); + return(sp_cst4); + } + return(innumber(c)); +} + +int innumber(c) register c; { + register char *p; + register n; + int expsign; + static char numstr[MAXSTR]; + long atol(); + + p = numstr; + expsign = 0; + if (c == '+' || c == '-') { + if (c == '-') + *p++ = c; + c = nextchar(); + } + if (isdigit(c) == 0) + syntax("digit expected"); + n = sp_cst4; + for (;;) { + if (p >= &numstr[MAXSTR-1]) + fatal("number too long"); + *p++ = c; + c = nextchar(); + if (c == '.' || c == 'e' || c == 'E') { + expsign = c != '.'; + n = sp_fcon; + continue; + } + if (expsign) { + expsign = 0; + if (c == '+' || c == '-') + continue; + } + if (isdigit(c) == 0) + break; + } + peekc = c; + *p = '\0'; + c = nospace(); + if (n == sp_fcon && c != 'F') + syntax("'F' expected"); + if (c == 'I' || c == 'U' || c == 'F') + return(incon(numstr,c)); + peekc = c; + argval = atol(numstr); + return(sp_cst4); +} + +in15u() { + + if (innumber(nextchar()) != sp_cst4) + syntax("integer expected"); + check((argval & ~077777) == 0); +} + +int incon(p,c) register char *p; { + register char *q; + + q = string; + while (*q++ = *p++) + ; + strsiz = q - string - 1; + gettyp(cst_ptyp); + return(c == 'I' ? sp_icon : (c == 'U' ? sp_ucon : sp_fcon)); +} + +int instring(termc) { + register char *p; + register c; + + p = string; + for (;;) { + c = nextchar(); + if (c == '\n' || c == EOF) { + peekc = c; + syntax("non-terminated string"); + } + if (c == termc) { + if (termc == '"') + *p++ = '\0'; + break; + } + if (c == '\\') + c = inescape(); + if (p >= &string[MAXSTR-1]) + fatal("string too long"); + *p++ = c; + } + strsiz = p - string; + return(sp_scon); +} + +int inescape() { + register c,j,r; + + c = nextchar(); + if (c >= '0' && c <= '7') { + r = c - '0'; + for (j = 0; j < 2; j++) { + c = nextchar(); + if (c < '0' || c > '7') { + peekc = c; + return(r); + } + r <<= 3; + r += (c - '0'); + } + return(r); + } + switch (c) { + case 'b': return('\b'); + case 'f': return('\f'); + case 'n': return('\n'); + case 'r': return('\r'); + case 't': return('\t'); + } + return(c); +} + +int nospace() { + register c; + + do + c = nextchar(); + while (isspace(c) && c != '\n'); + if (c == ';') + do + c = nextchar(); + while (c != '\n' && c != EOF); + return(c); +} + +int nextchar() { + register c; + + if (peekc != EMPTY) { + c = peekc; + peekc = EMPTY; + return(c); + } + c = getchar(); + if (isascii(c) == 0 && c != EOF) + fatal("non-ascii char"); + return(c); +} + +line_line() { + register char *p,*q; + static char filebuff[MAXSTR+1]; + + gettyp(ptyp(sp_cst2)); + lineno = (int) (argval-1); + gettyp(ptyp(sp_scon)); + p = string; + q = filebuff; + while (--strsiz >= 0) + *q++ = *p++; + *q = '\0'; + filename = filebuff; +} + +init() { + register i; + + for (i = sp_fmnem; i <= sp_lmnem; i++) + pre_hash(i,em_mnem[i - sp_fmnem]); + for (i = sp_fpseu; i <= sp_lpseu; i++) + pre_hash(i,em_pseu[i - sp_fpseu]); + /* treat '_' as letter */ + /* In System III the array is called _ctype[] without the trailing '_' */ + (_ctype_+1)['_'] = (_ctype_+1)['a']; +} + +pre_hash(i,s) char *s; { + register unsigned h; + + assert(i != 0); + h = hash(s); + for (;;) { + h++; + h %= HSIZE; + if (hashtab[h] == 0) { + hashtab[h] = i; + return; + } + } +} + +int hash(s) register char *s; { + register h; + + h = 0; + while (*s) { + h <<= 1; + h += *s++; + } + return(h); +} + +/* ----- output ----- */ + +putarg(sp) register sp; { + register i; + + switch (sp) { + case sp_ilb2: + i = (int) argval; + if (fit8u(i)) { + put8(sp_ilb1); + put8(i); + break; + } + put8(sp); + put16(i); + break; + case sp_dlb2: + i = dlbval; + if (fit8u(i)) { + put8(sp_dlb1); + put8(i); + break; + } + put8(sp); + put16(i); + break; + case sp_cst2: + case sp_cst4: + if (fit16i(argval) == 0) { + put8(sp_cst4); + put32(argval); + break; + } + i = (int) argval; + if (i >= -sp_zcst0 && i < sp_ncst0 - sp_zcst0) { + put8(i + sp_zcst0 + sp_fcst0); + break; + } + put8(sp_cst2); + put16(i); + break; + case sp_doff: + put8(sp); + putarg(offtyp); + putarg(sp_cst4); + break; + case sp_dnam: + case sp_pnam: + case sp_scon: + put8(sp); + putstr(); + break; + case sp_icon: + case sp_ucon: + case sp_fcon: + put8(sp); + putarg(sp_cst4); + putstr(); + break; + case sp_cend: + put8(sp); + break; + } +} + +putstr() { + register char *p; + long consiz; + + consiz = argval; + argval = strsiz; + putarg(sp_cst4); + argval = consiz; + p = string; + while (--strsiz >= 0) + put8(*p++); +} + +put16(w) int w; { + + put8(w); + put8(w >> 8); +} + +put32(f) long f; { + + put16((int) f); + put16((int)(f >> 16)); +} + +/* ----- error handling ----- */ + +fail_check() { + error("argument range error"); +} + +/* VARARGS */ +error(s,a1,a2,a3,a4) char *s; { + fprintf(stderr,"%s: line %d: ", filename, lineno); + fprintf(stderr,s,a1,a2,a3,a4); + fprintf(stderr,"\n"); + errors++; +} + +/* VARARGS */ +fatal(s,a1,a2,a3,a4) char *s; { + error(s,a1,a2,a3,a4); + exit(-1); +} + +/* VARARGS */ +syntax(s,a1,a2,a3,a4) char *s; { + register c; + + error(s,a1,a2,a3,a4); + do + c = nextchar(); + while (c != '\n' && c != EOF); + longjmp(recover); +} diff --git a/util/ncgg/Makefile b/util/ncgg/Makefile new file mode 100644 index 00000000..1db16fac --- /dev/null +++ b/util/ncgg/Makefile @@ -0,0 +1,181 @@ +# $Header$ + +CFILES=cgg.c subr.c main.c coerc.c enterkeyw.c error.c emlookup.c expr.c instruct.c iocc.c lookup.c output.c set.c strlookup.c var.c hall.c +OFILES=cgg.o subr.o main.o coerc.o enterkeyw.o error.o emlookup.o expr.o instruct.o iocc.o lookup.o set.o strlookup.o var.o hall.o +SOURCES=*.h cgg.y scan.l cvtkeywords keywords coerc.c emlookup.c error.c expr.c hall.c instruct.c iocc.c lookup.c main.c output.c set.c strlookup.c subr.c var.c +EMHOME=../.. +EMH=$(EMHOME)/h +MANDIR=$(EMHOME)/man +INCLUDES=-I$(EMH) +CFLAGS=-O $(INCLUDES) +YFLAGS=-v -d +LDFLAGS= +LEXLIB=-ll + + +cgg: cgg.o $(OFILES) output.o + $(CC) $(LDFLAGS) $(OFILES) output.o $(EMHOME)/lib/em_data.a $(LEXLIB) -o cgg + +install: cgg + rm -f $(EMHOME)/lib/ncgg + cp cgg $(EMHOME)/lib/ncgg + rm -f $(MANDIR)/ncgg.6 + cp ncgg.6 $(MANDIR)/ncgg.6 + +cmp: cgg + -cmp cgg $(EMHOME)/lib/ncgg + -cmp ncgg.6 $(MANDIR)/ncgg.6 + +debugcgg: cgg.o $(OFILES) debugoutput.o + $(CC) $(LDFLAGS) $(OFILES) debugoutput.o $(EMHOME)/lib/em_data.a -ll -o cgg + +cgg.o: scan.c + +enterkeyw.c: cvtkeywords keywords y.tab.h + cvtkeywords keywords + +debugoutput.o: debugoutput.c + $(CC) $(CFLAGS) -DCODEDEBUG -c debugoutput.c + +debugoutput.c: output.c + cp output.c debugoutput.c + +lint: $(CFILES) + lint $(INCLUDES) $(CFILES) + touch lint + +clean: + rm -f cgg.c scan.c y.output y.tab.h enterkeyw.c + rm -f $(OFILES) output.o debugoutput.o cgg lint + +pr: + pr $(SOURCES) + +opr: + -make pr|opr + +depend: + makedepend + +cgg.o: $(EMH)/cgg_cg.h +coerc.o: $(EMH)/cgg_cg.h +debugoutput.o: $(EMH)/cgg_cg.h +expr.o: $(EMH)/cgg_cg.h +instruct.o: $(EMH)/cgg_cg.h +iocc.o: $(EMH)/cgg_cg.h +output.o: $(EMH)/cgg_cg.h +set.o: $(EMH)/cgg_cg.h +subr.o: $(EMH)/cgg_cg.h +var.o: $(EMH)/cgg_cg.h +# AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO +cgg.o: expr.h +cgg.o: extern.h +cgg.o: instruct.h +cgg.o: iocc.h +cgg.o: lookup.h +cgg.o: param.h +cgg.o: scan.c +cgg.o: set.h +cgg.o: varinfo.h +coerc.o: assert.h +coerc.o: extern.h +coerc.o: iocc.h +coerc.o: param.h +coerc.o: property.h +coerc.o: pseudo.h +coerc.o: reg.h +coerc.o: set.h +coerc.o: token.h +coerc.o: varinfo.h +debugoutput.o: assert.h +debugoutput.o: extern.h +debugoutput.o: instruct.h +debugoutput.o: lookup.h +debugoutput.o: param.h +debugoutput.o: property.h +debugoutput.o: pseudo.h +debugoutput.o: reg.h +debugoutput.o: regvar.h +debugoutput.o: set.h +debugoutput.o: token.h +debugoutput.o: varinfo.h +emlookup.o: expr.h +emlookup.o: param.h +enterkeyw.o: lookup.h +expr.o: assert.h +expr.o: expr.h +expr.o: extern.h +expr.o: lookup.h +expr.o: param.h +expr.o: property.h +expr.o: reg.h +expr.o: regvar.h +expr.o: set.h +expr.o: token.h +hall.o: assert.h +hall.o: param.h +hall.o: set.h +instruct.o: expr.h +instruct.o: extern.h +instruct.o: instruct.h +instruct.o: iocc.h +instruct.o: param.h +instruct.o: pseudo.h +instruct.o: set.h +instruct.o: varinfo.h +iocc.o: assert.h +iocc.o: expr.h +iocc.o: extern.h +iocc.o: iocc.h +iocc.o: lookup.h +iocc.o: param.h +iocc.o: property.h +iocc.o: regvar.h +iocc.o: set.h +iocc.o: token.h +lookup.o: assert.h +lookup.o: lookup.h +lookup.o: param.h +output.o: assert.h +output.o: extern.h +output.o: instruct.h +output.o: lookup.h +output.o: param.h +output.o: property.h +output.o: pseudo.h +output.o: reg.h +output.o: regvar.h +output.o: set.h +output.o: token.h +output.o: varinfo.h +scan.o: stdio.h +set.o: extern.h +set.o: lookup.h +set.o: param.h +set.o: property.h +set.o: reg.h +set.o: set.h +set.o: token.h +strlookup.o: param.h +subr.o: expr.h +subr.o: extern.h +subr.o: instruct.h +subr.o: lookup.h +subr.o: param.h +subr.o: property.h +subr.o: reg.h +subr.o: regvar.h +subr.o: set.h +subr.o: token.h +subr.o: varinfo.h +tables.o: data.h +tables.o: param.h +tables.o: tables.h +tables.o: types.h +var.o: instruct.h +var.o: lookup.h +var.o: param.h +var.o: property.h +var.o: reg.h +var.o: set.h +var.o: token.h diff --git a/util/ncgg/makedepend b/util/ncgg/makedepend new file mode 100755 index 00000000..31e2e20d --- /dev/null +++ b/util/ncgg/makedepend @@ -0,0 +1,15 @@ +: '$Header$' +for extension in c y +do + for file in *.$extension + do ofile=`basename $file .$extension`.o + grep '^# *include.*"' $file|sed "s/.*\"\(.*\)\".*/$ofile: \1/" + done +done | sort -u >depend +ed - Makefile <<'!' +/AUTOAUTOAUTO/+,$d +$r depend +w +q +! +rm -f depend diff --git a/util/opt/Makefile b/util/opt/Makefile new file mode 100644 index 00000000..c2c142f8 --- /dev/null +++ b/util/opt/Makefile @@ -0,0 +1,228 @@ +# $Header$ + +EMHOME=../.. +CFILES=main.c getline.c lookup.c var.c process.c backward.c util.c \ + alloc.c putline.c cleanup.c peephole.c flow.c reg.c tes.c \ + pop_push.c + +OFILES=main.o getline.o lookup.o var.o process.o backward.o util.o\ + alloc.o putline.o cleanup.o peephole.o flow.o tes.o pop_push.o +ONOGLOB=regnoglob.o +OGLOB=regglob.o +LIBS=$(EMHOME)/lib/em_data.a +CFLAGS=-O -DNDEBUG -I$(EMHOME)/h +LDFLAGS= +LINT=lint +OPR=opr +PROPTS= +CPP=$(EMHOME)/lib/cpp +# LEXLIB is implementation dependent, try -ll or -lln first +LEXLIB=-ll + +all: opt opt2 + +opt: $(OFILES) $(ONOGLOB) pattern.o $(LIBS) + $(CC) $(LDFLAGS) $(CFLAGS) $(OFILES) $(ONOGLOB) pattern.o $(LIBS) -o opt + +opt2: $(OFILES) $(OGLOB) pattern.o $(LIBS) + $(CC) $(LDFLAGS) $(CFLAGS) $(OFILES) $(OGLOB) pattern.o $(LIBS) -o opt2 + +test: opt testopt + testopt + +cmp: all + -cmp opt $(EMHOME)/lib/em_opt + -cmp opt2 $(EMHOME)/lib/em_opt2 + -cmp em_opt.6 $(EMHOME)/man/em_opt.6 + +install:all + -size opt $(EMHOME)/lib/em_opt + rm -f $(EMHOME)/lib/em_opt + cp opt $(EMHOME)/lib/em_opt + -size opt2 $(EMHOME)/lib/em_opt2 + rm -f $(EMHOME)/lib/em_opt2 + cp opt2 $(EMHOME)/lib/em_opt2 + rm -f $(EMHOME)/man/em_opt.6 + cp em_opt.6 $(EMHOME)/man/em_opt.6 + +pattern.c: patterns mktab + $(CPP) patterns | mktab > pattern.c + +mktab: mktab.o $(LIBS) + $(CC) $(CFLAGS) mktab.o $(LIBS) $(LEXLIB) -o mktab + +mktab.o: scan.c optim.h param.h pattern.h types.h + +pop_push.c pop_push.h: $(EMHOME)/etc/em_table pop_push.awk + awk -f pop_push.awk < $(EMHOME)/etc/em_table > pop_push.c + +depend: pattern.c + sed '/^#AUTOAUTO/,$$d' Makefile >Makefile.new + echo '#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO' >> Makefile.new + cp reg.c regglob.c + cp reg.c regnoglob.c + mkdep $(CFILES) pattern.c regglob.c regnoglob.c | sed 's/\.c:/.o:/' >> Makefile.new + rm -f regglob.c regnoglob.c + mv Makefile Makefile.old + mv Makefile.new Makefile + +lint: $(CFILES) pattern.c + $(LINT) $(CFLAGS) $(CFILES) pattern.c>lint 2>&1 + +printall: + -pr $(PROPTS) Makefile -n *.h `ls $(CFILES)` mktab.y scan.l patterns|$(OPR) + touch print + +print: Makefile *.h $(CFILES) mktab.y scan.l patterns + -pr $(PROPTS) -n $? | $(OPR) + touch print + +opr: + make pr | $(OPR) + +pr: + @pr $(PROPTS) -n Makefile *.h $(CFILES) mktab.y scan.l patterns + +clean: + rm -f *.o opt mktab mktab.c scan.c pattern.c opt2 Out \ + pop_push.c pop_push.h + +regnoglob.o: reg.c + $(CC) $(CFLAGS) -c reg.c + mv reg.o regnoglob.o + +regglob.o: reg.c + $(CC) $(CFLAGS) -c -DGLOBAL_OPT reg.c + mv reg.o regglob.o + +# the next lines are generated automatically +#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO +main.o: alloc.h +main.o: ext.h +main.o: param.h +main.o: tes.h +main.o: types.h +getline.o: alloc.h +getline.o: ext.h +getline.o: line.h +getline.o: lookup.h +getline.o: param.h +getline.o: proinf.h +getline.o: tes.h +getline.o: types.h +lookup.o: alloc.h +lookup.o: lookup.h +lookup.o: param.h +lookup.o: proinf.h +lookup.o: tes.h +lookup.o: types.h +var.o: lookup.h +var.o: param.h +var.o: proinf.h +var.o: tes.h +var.o: types.h +process.o: alloc.h +process.o: assert.h +process.o: ext.h +process.o: line.h +process.o: lookup.h +process.o: param.h +process.o: proinf.h +process.o: tes.h +process.o: types.h +backward.o: alloc.h +backward.o: assert.h +backward.o: ext.h +backward.o: line.h +backward.o: lookup.h +backward.o: param.h +backward.o: proinf.h +backward.o: tes.h +backward.o: types.h +util.o: assert.h +util.o: ext.h +util.o: lookup.h +util.o: optim.h +util.o: param.h +util.o: proinf.h +util.o: tes.h +util.o: types.h +alloc.o: alloc.h +alloc.o: assert.h +alloc.o: line.h +alloc.o: lookup.h +alloc.o: param.h +alloc.o: proinf.h +alloc.o: tes.h +alloc.o: types.h +putline.o: alloc.h +putline.o: assert.h +putline.o: ext.h +putline.o: line.h +putline.o: lookup.h +putline.o: optim.h +putline.o: param.h +putline.o: proinf.h +putline.o: tes.h +putline.o: types.h +cleanup.o: assert.h +cleanup.o: ext.h +cleanup.o: lookup.h +cleanup.o: param.h +cleanup.o: types.h +peephole.o: alloc.h +peephole.o: assert.h +peephole.o: ext.h +peephole.o: line.h +peephole.o: lookup.h +peephole.o: optim.h +peephole.o: param.h +peephole.o: pattern.h +peephole.o: proinf.h +peephole.o: tes.h +peephole.o: types.h +flow.o: alloc.h +flow.o: ext.h +flow.o: line.h +flow.o: optim.h +flow.o: param.h +flow.o: proinf.h +flow.o: tes.h +flow.o: types.h +reg.o: alloc.h +reg.o: assert.h +reg.o: ext.h +reg.o: line.h +reg.o: param.h +reg.o: proinf.h +reg.o: tes.h +reg.o: types.h +tes.o: alloc.h +tes.o: assert.h +tes.o: ext.h +tes.o: line.h +tes.o: param.h +tes.o: pop_push.h +tes.o: proinf.h +tes.o: tes.h +tes.o: types.h +pop_push.o: pop_push.h +pattern.o: param.h +pattern.o: pattern.h +pattern.o: types.h +regglob.o: alloc.h +regglob.o: assert.h +regglob.o: ext.h +regglob.o: line.h +regglob.o: param.h +regglob.o: proinf.h +regglob.o: tes.h +regglob.o: types.h +regnoglob.o: alloc.h +regnoglob.o: assert.h +regnoglob.o: ext.h +regnoglob.o: line.h +regnoglob.o: param.h +regnoglob.o: proinf.h +regnoglob.o: tes.h +regnoglob.o: types.h diff --git a/util/opt/makedepend b/util/opt/makedepend new file mode 100755 index 00000000..31e2e20d --- /dev/null +++ b/util/opt/makedepend @@ -0,0 +1,15 @@ +: '$Header$' +for extension in c y +do + for file in *.$extension + do ofile=`basename $file .$extension`.o + grep '^# *include.*"' $file|sed "s/.*\"\(.*\)\".*/$ofile: \1/" + done +done | sort -u >depend +ed - Makefile <<'!' +/AUTOAUTOAUTO/+,$d +$r depend +w +q +! +rm -f depend diff --git a/util/opt/shc.c b/util/opt/shc.c new file mode 100644 index 00000000..eabf04af --- /dev/null +++ b/util/opt/shc.c @@ -0,0 +1,226 @@ +/* + * This file contains the main part of the stackheight computation phase. + * + * Author: Hans van Eck. + */ + +#include +#include +#include +#include +#include "param.h" +#include "assert.h" +#include "types.h" +#include "shc.h" +#include "alloc.h" +#include "proinf.h" +#include "line.h" +#include "ext.h" +#include "pop_push.h" + +extern char *pop_push[]; +extern char flow_tab[]; + +#define NON_CONTINUABLE(i) (flow_tab[i]&JUMP) +#define ISABRANCH(i) (flow_tab[i]&HASLABEL) +#define ISCONDBRANCH(i) (flow_tab[i]&CONDBRA) + +lblst_p est_list = NULL; + +#define INSTR(lnp) (lnp->l_instr & BMASK) +#define TYPE(lnp) lnp->l_optyp +#define PREV(lnp) lnp->l_prev +#define SHORT(lnp) lnp->l_a.la_short +#define MINI(lnp) ((lnp->l_optyp & BMASK) - Z_OPMINI) + +#define IS_MINI(lnp) (lnp->l_optyp >= OPMINI) +#define IS_LOC(l) (l!=(line_p) 0 && INSTR(l)==op_loc && IS_MINI(l)) + +int state; +static int stack_height = 0; + +init_state() +{ + stack_height = 0; + change_state(KNOWN); + est_list = NULL; +} + +shc_pseudos() +{ + register line_p lp; + + for (lp = pseudos; lp != (line_p)0; lp = lp->l_next) { + switch(INSTR(lp)) { + case ps_con: + case ps_rom: + if (lp->l_optyp == OPLIST) { + register arg_p ap = lp->l_a.la_arg; + + while (ap != (arg_p) 0) { + if (ap->a_typ == ARGNUM) { + assign_label(ap->a_a.a_np->n_repl); + } + ap = ap->a_next; + } + } else if (lp->l_optyp == OPNUMLAB) + assign_label(lp->l_a.la_np->n_repl); + } + } +} + +shc_instr(lnp) +line_p lnp; +{ + char *s; + register instr = INSTR(lnp); + register int mult, arg, argdef; + line_p x = PREV(lnp); + line_p y = (x == (line_p) 0 ? (line_p) 0 : PREV(x)); + + if (state == NO_STACK_MES) return; + + if ( instr == op_lab) { + do_inst_label(lnp); + return; + } + if (instr < sp_fmnem || instr > sp_lmnem) { + return; + } + + if(state == NOTREACHED) return; /* What else ? */ + s = pop_push[instr]; + + if (*s != '0') + while (*s != '\0') { + if (*s++ == '-') mult = -1; + else mult = 1; + if (TYPE(lnp) == OPSHORT) { + arg = SHORT(lnp); + if (arg < wordsize) arg = wordsize; + argdef = TRUE; + } else if (IS_MINI(lnp)) { + arg = MINI(lnp); + if (arg > 0 && arg < wordsize) arg = wordsize; + if (arg < 0 && -arg < wordsize) arg = -wordsize; + argdef = TRUE; + } else argdef = FALSE; + switch (*s++) { + case 'w': stack_height += mult * wordsize; break; + case 'd': stack_height += mult * wordsize * 2; break; + case 'p': stack_height += mult * pointersize; break; + case 'a': + if (argdef == FALSE || instr == op_ass) { + change_state(NO_STACK_MES); + return; + } + stack_height += mult * arg; + break; + case 'x': + if (IS_LOC(x)) { + arg = MINI(x); + if (arg < wordsize) arg = wordsize; + stack_height += mult * arg; + break; + } + change_state(NO_STACK_MES); + return; + case 'y': + if (IS_LOC(y)) { + arg = MINI(y); + if (arg < wordsize) arg = wordsize; + stack_height += mult * arg; + break; + } + change_state(NO_STACK_MES); + return; + case '?': + /* Actually, the effect of a ret on the stack is + * known, but it has a '?' anyway. I think this + * should be changed in ~etc/em_table + */ + if (instr == op_ret) + break; + change_state(NO_STACK_MES); + return; + default: + assert(FALSE); + } + } + + if (ISABRANCH(instr)) do_inst_label(lnp); + if (NON_CONTINUABLE(instr)) change_state(NOTREACHED); +} + +change_state(mode) +int mode; +{ + state = mode; + if (mode != KNOWN) stack_height = 0; +} + +delete_labels() +{ + register lblst_p tmp; + + while ((tmp = est_list) != NULL) { + est_list = est_list->ll_next; + oldlblst(tmp); + } +} + +inst_old_label(lst_elt) +register lblst_p lst_elt; +{ + if (state != NOTREACHED) { + if (stack_height < 0 || lst_elt->ll_height != stack_height) { + change_state(NO_STACK_MES); + } + } else { /* after a label */ + stack_height = lst_elt->ll_height; + } +} + +inst_new_label(label) +register num_p label; +{ + register lblst_p lst_elt; + + lst_elt = newlblst(); + lst_elt->ll_next = est_list; + lst_elt->ll_num = label; + lst_elt->ll_height = stack_height; + + est_list = lst_elt; + + label->n_lst_elt = lst_elt; + label->n_flags |= NUMSET; +} + +assign_label(label) +num_p label; +{ + if (label->n_flags & NUMSET) + inst_old_label(label->n_lst_elt); + else inst_new_label(label); +} + +do_inst_label(lnp) /* (re-)install a label */ +line_p lnp; +{ + num_p label = lnp->l_a.la_np->n_repl; + int instr = INSTR(lnp); + + assign_label(label); + + if (instr == op_lab) { + if (state == NOTREACHED) { + label->n_lst_elt->ll_fallthrough = FALSE; + } else { + label->n_lst_elt->ll_fallthrough = TRUE; + } + } else if (ISCONDBRANCH(instr)) { /* conditional branch */ + label->n_flags |= NUMCOND; + } + if (state != NO_STACK_MES) change_state(KNOWN); +} diff --git a/util/opt/shc.h b/util/opt/shc.h new file mode 100644 index 00000000..5f76e65a --- /dev/null +++ b/util/opt/shc.h @@ -0,0 +1,20 @@ +/* + * Author: Hans van Eck. + */ + +typedef struct label_list *lblst_p; + +struct label_list { + lblst_p ll_next; /* pointer to next label in the list */ + num_p ll_num; /* pointer to label definition */ + short ll_height; /* the height of the stack at this label */ + char ll_fallthrough; /* is the label reached by fallthrough ? */ +}; + +typedef struct label_list lblst_t; + +extern lblst_p est_list; +extern int state; +#define KNOWN 1 +#define NOTREACHED 2 +#define NO_STACK_MES 3 diff --git a/util/shf/Makefile b/util/shf/Makefile new file mode 100644 index 00000000..813a5eff --- /dev/null +++ b/util/shf/Makefile @@ -0,0 +1,17 @@ +# $Header$ + +install: + -rm -f ../../bin/march + cp march.sh ../../bin/march + +clean: + @echo always clean + +cmp: + cmp march.sh ../../bin/march + +opr: + make pr|opr + +pr: + pr march.sh diff --git a/util/topgen/Makefile b/util/topgen/Makefile new file mode 100644 index 00000000..40687ea1 --- /dev/null +++ b/util/topgen/Makefile @@ -0,0 +1,40 @@ +EM = ../.. +CFLAGS = -O +SOURCE = token.h symtab.h misc.h tunable.h main.c topgen.g LLlex.c symtab.c pattern.c hash.c +CFILES = main.c topgen.c Lpars.c LLlex.c symtab.c pattern.c hash.c +OFILES = main.o topgen.o Lpars.o LLlex.o symtab.o pattern.o hash.o + +all: parser + @make topgen + +cmp: all + cmp topgen $(EM)/lib/topgen + +install: all + cp topgen $(EM)/lib/topgen + +clean: + rm -f topgen *.o Lpars.c Lpars.h topgen.c parser + +parser: topgen.g + $(EM)/bin/LLgen topgen.g + touch parser + +topgen.o: token.h Lpars.h symtab.h misc.h +Lpars.o: Lpars.h +LLlex.o: token.h Lpars.h tunable.h +symtab.o: symtab.h +hash.o: misc.h +pattern.o: misc.h symtab.h + +topgen: $(OFILES) + $(CC) $(OFILES) -o topgen + +lint: parser + lint $(CFILES) + +pr: + @pr $(SOURCE) Makefile + +opr: + make pr ^ opr