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