2 static char rcsid[] = "$Id: putline.c,v 2.7 1994/06/24 10:40:51 ceriel Exp $";
21 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
22 * See the copyright notice in the ACK home directory, in the file "Copyright".
24 * Author: Hans van Staveren
27 #define outbyte(b) putc(b,outfile)
29 putlines(lnp) register line_p lnp; {
36 while ( lnp != (line_p) 0) {
37 instr = lnp->l_instr&BMASK;
38 switch(lnp->l_optyp) {
40 if ((lnp->l_instr&BMASK) == ps_sym)
41 outdef(lnp->l_a.la_sp);
43 outocc(lnp->l_a.la_sp);
46 outocc(lnp->l_a.la_sval.lasv_sp);
50 outocc(lnp->l_a.la_lval.lalv_sp);
55 while (ap != (arg_p) 0) {
61 outocc(ap->a_a.a_val.av_sp);
70 * global symbols now taken care of
83 switch(lnp->l_optyp) {
94 thislin = lnp->l_a.la_short;
97 thislin = (lnp->l_optyp&BMASK)-Z_OPMINI;
100 if (thislin == curlin && !nflag) {
106 } else if (thislin == curlin+1 && !nflag) {
114 lnp->l_instr = instr;
124 if ((em_flag[instr-sp_fmnem]&EM_FLO)==FLO_P)
129 switch(lnp->l_optyp) {
131 if ((em_flag[instr-sp_fmnem]&EM_PAR)!=PAR_NO)
132 outbyte( (byte) sp_cend) ;
135 outint((lnp->l_optyp&BMASK)-Z_OPMINI);
138 outint(lnp->l_a.la_short);
142 outoff(lnp->l_a.la_offset);
147 numlab(lnp->l_a.la_np->n_repl);
148 else if (instr < sp_fpseu) /* plain instruction */
149 outint((short) lnp->l_a.la_np->n_repl->n_number);
151 outnum(lnp->l_a.la_np->n_repl);
154 outsym(lnp->l_a.la_sp);
157 outbyte( (byte) sp_doff) ;
158 outsym(lnp->l_a.la_sval.lasv_sp);
159 outint(lnp->l_a.la_sval.lasv_short);
163 outbyte( (byte) sp_doff) ;
164 outsym(lnp->l_a.la_lval.lalv_sp);
165 outoff(lnp->l_a.la_lval.lalv_offset);
169 putargs(lnp->l_a.la_arg);
174 outbyte( (byte) sp_cend) ;
178 * instruction is output now.
179 * remove its useless body
186 error("write error");
190 putargs(ap) register arg_p ap; {
192 while (ap != (arg_p) 0) {
197 outoff(ap->a_a.a_offset);
200 outnum(ap->a_a.a_np->n_repl);
203 outsym(ap->a_a.a_sp);
206 outbyte( (byte) sp_doff) ;
207 outsym(ap->a_a.a_val.av_sp);
208 outoff(ap->a_a.a_val.av_offset);
211 outbyte( (byte) sp_scon) ;
212 putstr(&ap->a_a.a_string);
215 outbyte( (byte) sp_icon) ;
218 outbyte( (byte) sp_ucon) ;
221 outbyte( (byte) sp_fcon) ;
223 outint(ap->a_a.a_con.ac_length);
224 putstr(&ap->a_a.a_con.ac_con);
231 putstr(abp) register argb_p abp; {
237 while (tbp!= (argb_p) 0) {
238 length += tbp->ab_index;
242 while (abp != (argb_p) 0) {
243 for (length=0;length<abp->ab_index;length++)
244 outbyte( (byte) abp->ab_contents[length] );
249 outdef(sp) register sym_p sp; {
252 * The surrounding If statement is removed to be friendly
253 * to Backend writers having to deal with assemblers
254 * not following our conventions.
255 if ((sp->s_flags&SYMOUT)==0) {
257 sp->s_flags |= SYMOUT;
258 if (sp->s_flags&SYMGLOBAL) {
259 outinst(sp->s_flags&SYMPRO ? ps_exp : ps_exa);
267 outocc(sp) register sym_p sp; {
269 if ((sp->s_flags&SYMOUT)==0) {
270 sp->s_flags |= SYMOUT;
271 if ((sp->s_flags&SYMGLOBAL)==0) {
272 outinst(sp->s_flags&SYMPRO ? ps_inp : ps_ina);
280 outdef(curpro.symbol);
282 outsym(curpro.symbol);
283 outoff(curpro.localbytes);
289 outoff(curpro.localbytes);
297 outoff(off) offset off; {
300 if ((short) off == off)
305 outbyte( (byte) sp_cst4) ;
306 outshort( (short) (off&0177777L) );
307 outshort( (short) (off>>16) );
314 if (i>= -sp_zcst0 && i< sp_ncst0-sp_zcst0)
315 outbyte( (byte) (i+sp_zcst0+sp_fcst0) );
317 outbyte( (byte) sp_cst2) ;
322 outshort(i) short i; {
324 outbyte( (byte) (i&BMASK) );
325 outbyte( (byte) (i>>8) );
328 numlab(np) register num_p np; {
330 if (np->n_number < sp_nilb0)
331 outbyte( (byte) (np->n_number + sp_filb0) );
336 outnum(np) register num_p np; {
338 if(np->n_number<256) {
339 outbyte( (byte) sp_ilb1) ;
340 outbyte( (byte) (np->n_number) );
342 outbyte( (byte) sp_ilb2) ;
343 outshort((short) np->n_number);
347 outsym(sp) register sym_p sp; {
349 register unsigned num;
351 if (sp->s_name[0] == '.') {
352 num = atoi(&sp->s_name[1]);
354 outbyte( (byte) sp_dlb1) ;
355 outbyte( (byte) (num) );
357 outbyte( (byte) sp_dlb2) ;
358 outshort((short) num);
362 while (*p && p < &sp->s_name[IDL])
364 num = p - sp->s_name;
365 outbyte( (byte) (sp->s_flags&SYMPRO ? sp_pnam : sp_dnam) );
369 outbyte( (byte) *p++ );