1 /* $Id: ic_io.c,v 1.8 1994/06/24 10:24:12 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
6 /* I N T E R M E D I A T E C O D E
17 #include "../share/types.h"
18 #include "../share/debug.h"
20 #include "ic_lookup.h"
21 #include "../share/alloc.h"
25 STATIC short libstate;
28 STATIC FILE *infile; /* The current EM input file */
32 if (libstate == ARCHIVE && bytecnt-- == 0L) {
33 /* If we're reading from an archive file, we'll
34 * have to count the number of characters read,
35 * to know where the current module ends.
46 register int l_byte, h_byte;
50 if ( h_byte>=128 ) h_byte -= 256 ;
51 return l_byte | (h_byte*256) ;
60 l |= ((unsigned) readbyte())*256 ;
61 l |= readbyte()*256L*256L ;
63 if ( h_byte>=128 ) h_byte -= 256 ;
64 return l | (h_byte*256L*256*256L) ;
72 default: error("int expected");
88 default: error("offset expected");
90 return((offset) tabval);
98 STATIC make_string(n) int n; {
100 sprintf(string,".%u",n);
105 register char *p = string;
117 int table3(n) int n; {
120 case sp_ilb1: tabval = readbyte(); return(ILBX);
121 case sp_ilb2: tabval = readshort(); return(ILBX);
122 case sp_dlb1: make_string(readbyte()); return(DLBX);
123 case sp_dlb2: make_string(readshort()); return(DLBX);
124 case sp_dnam: inident(); return(DLBX);
125 case sp_pnam: inident(); return(n);
126 case sp_cst2: tabval = readshort(); return(CSTX1);
128 case sp_cst4: tabval2 = readoffset(); return(CSTX2);
130 case sp_doff: if (table2()!=DLBX) error("symbol expected");
132 default: error("offset expected");
133 case CSTX1: return(VALX1);
135 case CSTX2: return(VALX2);
148 if ((n <= sp_lmnem) && (n >= sp_fmnem)) {
152 if ((n <= sp_lpseu) && (n >= sp_fpseu)) {
156 if ((n < sp_filb0 + sp_nilb0) && (n >= sp_filb0)) {
157 tabval = n - sp_filb0;
167 if ((n < sp_fcst0 + sp_ncst0) && (n >= sp_fcst0)) {
168 tabval = n - sp_zcst0;
177 file_init(f,state,length)
189 if (n != (short) sp_magic) {
190 error("wrong magic number: %d", n);
203 if (n != (short)ARMAG && n != (short)AALMAG) {
204 error("wrong archive magic number: %d",n);