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 =======================================================================
40 /* Utility routines */
43 * Compute entier (floor)
65 word shift(word x, word n)
72 return ((x >> -n) & ~(~(word)0 << (8 * sizeof(word) + n)));
77 * Get ASCIIZ string from arrayof char
79 char *asciiz(virtaddr *virt)
85 if (member(virt, &am)) {
86 /* length of the string */
88 /* allocate buffer for the string */
89 cp = ballocate(len + 1);
94 for (i = 0; i < len; i++)
95 cp[i] = (char) M[am + 3 + i];
97 /* terminate string with 0 byte */
102 /* reference to none */
108 * Add extension to a file name
110 void addext(char *fname, char *ext)
115 while (*cp != '\0' && *cp != '.')
125 * Print error message and abort
127 void abend(char *msg)
129 fprintf(stderr, "Error: %s\n", msg);
134 /* Pseudo random number generator */
136 static int ranpat1 = 7, ranpat2 = 503, ranpat3 = 15661;
139 * Initialize generator
146 ranpat1 = tim % 30269;
147 ranpat2 = tim % 30307;
148 ranpat3 = tim % 30323;
152 * Produce next pseudo random number
159 ranpat1 = 171 * (ranpat1 % 177) - 2 * (ranpat1 / 177);
163 ranpat2 = 172 * (ranpat2 % 176) - 35 * (ranpat2 / 176);
168 ranpat3 = 170 * (ranpat3 % 178) - 63 * (ranpat3 / 178);
173 r = ranpat1 / 30269.0 + ranpat2 / 30307.0 + ranpat3 / 30323.0;
179 * Copy a block of memory
181 void moveblock(char *from, char *to, word len)
188 /**************************************************************
191 void dump(word pix, word from, int len)
198 printf("%6ld: ", (long) from);
199 for (i = 0; i < LINE; i++)
200 printf("%7ld", (long)M[from++]);
205 **************************************************************/