1 /* Loglan82 Compiler&Interpreter
2 Copyright (C) 1981-1993 Institute of Informatics, University of Warsaw
3 Copyright (C) 1993, 1994 LITA, Pau
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 contacts: Andrzej.Salwicki@univ-pau.fr
22 LITA Departement d'Informatique
24 Avenue de l'Universite
26 tel. ++33 59923154 fax. ++33 59841696
28 =======================================================================
41 /* Utility routines */
44 word entier(x) /* Compute entier (floor) */
58 if ((double)i <= x) return(i); else return(i-1);
63 word shift(x, n) /* shift x by n bits */
66 if (n == 0) return (x);
67 if (n > 0) return (x << n);
68 else return ( (x >> -n) & ~(~(word)0 << (8*sizeof(word)+n)) );
72 char *asciiz(virt) /* Get ASCIIZ string from arrayof char */
79 if (member(virt, &am))
81 len = M[ am ]-3; /* length of the string */
82 cp = ballocate(len+1); /* allocate buffer for the string */
83 if (cp == NULL) errsignal(RTEMEMOV);
84 for (i = 0; i < len; i++) cp[ i ] = (char) M[ am+3+i ];
85 cp[ len ] = '\0'; /* terminate string with 0 byte */
88 else errsignal(RTEREFTN); /* reference to none */
92 void addext(fname, ext) /* Add extension to a file name */
98 while (*cp != '\0' && *cp != '.') cp++;
106 fprintf(stderr,"Usage: int [-i] [-d] [-m memsize] [-r console] file\n");
109 fprintf(stderr,"Usage: int [-i] [-d] [-m memsize]\n");
110 fprintf(stderr,"\t[-r console_number #_of_slaves_to_wait_for|master_address]\n");
111 fprintf(stderr,"\tfile\n");
112 fprintf(stderr,"master address in form: nnn.nnn.nnn.nnn:[port]\n");
113 fprintf(stderr," or : host_name:[port]\n");
114 fprintf(stderr,"default port number : %d\n",PORT);
116 fprintf(stderr,"Usage: int [-i] [-d] [-m memsize] file\n");
122 void abend(msg) /* Print error message and abort */
125 fprintf(stderr, "Error: %s\n", msg);
133 /* Pseudo random number generator */
135 static int ranpat1 = 7, ranpat2 = 503, ranpat3 = 15661;
137 void ranset() /* Initialize generator */
142 ranpat1 = tim % 30269;
143 ranpat2 = tim % 30307;
144 ranpat3 = tim % 30323;
148 double prandom() /* Produce next pseudo random number */
153 ranpat1 = 171*(ranpat1 % 177)- 2*(ranpat1 / 177);
154 if (ranpat1 < 0) ranpat1 += 30269;
155 ranpat2 = 172*(ranpat2 % 176)-35*(ranpat2 / 176);
156 if (ranpat2 < 0) ranpat2 += 30307;
157 ranpat3 = 170*(ranpat3 % 178)-63*(ranpat3 / 178);
158 if (ranpat3 < 0) ranpat3 += 30323;
159 r = ranpat1/30269.0 + ranpat2/30307.0 + ranpat3/30323.0;
165 void moveblock(from, to, len) /* Copy a block of memory */
169 while (len-- > 0) *to++ = *from++;
170 } /* end moveblock */
173 /**************************************************************
176 void dump(pix, from, len)
183 M = process[ pix ].M;
186 printf("%6ld: ", (long) from);
187 for (i = 0; i < LINE; i++) printf("%7ld", (long)M[from++]);
193 **************************************************************/