2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
12 static char rcs_id[] = "$Id: ass50.c,v 2.5 1994/06/24 10:15:14 ceriel Exp $" ;
16 ** Pass 5 of EM1 assembler/loader
25 int afterlength, partype ;
26 register int inslength, ope;
31 for (lnp = pstate.s_fline ; lnp ; lnp= lnp->l_next, line_num++ ) {
32 ope = ctrunc(lnp->instr_num);
33 if ( ope==sp_ilb1 ) continue ;
34 if ( ope==sp_fpseu ) {
35 line_num = lnp->ad.ad_ln.ln_first ;
38 off1 = parval(lnp,&defined);
39 if ( (op_curr = lnp->opoff)==NO_OFF ) {
40 fatal("opoff assertion failed") ;
42 inslength = oplength(*op_curr) ;
43 afterlength += inslength ;
46 * Change absolute offset to a relative for branches.
50 partype= em_flag[ope]&EM_PAR ;
51 if ( partype==PAR_B && defined ) {
57 extern char em_mnem[][4] ;
58 printf("%s %ld\n",em_mnem[ope],off1) ;
62 if ( !defined && partype==PAR_G ) { /* must be external */
63 text_reloc((lnp->type1==GLOSYM ?
64 lnp->ad.ad_gp:lnp->ad.ad_df.df_gp),
65 (FOFFSET)(textbytes+afterlength-inslength) ,
67 xputarb(inslength,off1,tfile);
68 textoff += inslength ;
70 genop(op_curr,off1,partype) ;
76 textbytes += prog_size;
77 if ( textbytes>maxadr ) fatal("Maximum code area size exceeded") ;
81 genop(startc,value,i_flag) char *startc ; cons_t value ; int i_flag ; {
87 * Real code generation.
91 flag = ctrunc(*currc++);
93 if ( (flag&OPTYPE)!=OPNO ) {
95 if ( !opfit(flag,*currc,value,i_flag) ) {
96 fatal("parameter value unsuitable for selected opcode") ;
99 if ( value%wordsize!=0 ) {
100 error("parameter not word multiple");
105 if ( value<=0 ) error("negative parameter");
109 if ( flag&OPESC ) put8(ESC) ;
111 switch ( flag&OPTYPE ) {
113 opc += value<0 ? -1-value : value ;
117 opc += -1-(value>>8) ;
129 switch(flag&OPTYPE) {
132 opcnt3[opc&0377]= 1 ;
135 if ( flag&OPESC ) opcnt2[opc&0377]= 1 ;
136 else opcnt1[opc&0377]= 1 ;
143 switch( flag&OPTYPE ) {
153 put16(int_cast value) ;
168 if ( r= pstate.s_fdata ) {
173 for( ; r ; r= r->r_next ) {
174 if (r->r_typ == RELLOC) {
177 if (k->l_defined==YES)
178 r->r_val.rel_i = k->l_min + textbytes;
180 error("case label at line %d undefined",