5 extern out(char *, ...);
18 /* This file contains some routines called from the parser in 'pars.g' */
23 /* Print : "if ( <str> ) {"
30 for ( c = *str++; c != '\0'; c= *str++)
31 if ( c == '$' && isdigit( *str)) {
33 arg_nr = *str++ - '0' - 1;
34 out( "%s", C_instr_info->arg_id[arg_nr]);
48 /* Print 'str' and handle the $i's. Also count the number of text-bytes
49 * that are generated, look for text?() and reloc?() calls.
54 extern int no_conversions;
56 if ( strncmp( "text", str, 4) == 0 && isdigit( *(str+4)))
57 cur_pos += *(str+4) - '0';
58 else if ( strncmp( "reloc", str, 5) == 0 && isdigit( *(str+5)) &&
60 cur_pos += *(str+5) - '0';
62 for ( c = *str++; c != '\0'; c= *str++)
63 if ( c == '$' && isdigit( *str)) {
65 arg_nr = *str++ - '0' - 1;
67 out( "%s", C_instr_info->arg_id[arg_nr]);
69 out( "%s", C_instr_info->arg_conv[arg_nr]);
81 out( "void %s%s", instr, C_instr_info->header);
90 case SEGTXT : out( "switchseg( SEGTXT);\n");
92 case SEGBSS : out( "switchseg( SEGBSS);\n");
93 out( "dump_label();\n");
95 case SEGHOL : out( "switchseg( SEGHOL);\n");
97 case SEGCON : out( "switchseg( SEGCON);\n");
98 out( "dump_label();\n");
100 case SEGROM : out( "switchseg( SEGROM);\n");
101 out( "dump_label();\n");
103 case UNKNOWN : break; /* dan niet! */
114 doprnt( outfile, fmt, pvar);
126 fmt = va_arg(pvar, char *);
127 doprnt( outfile, fmt, pvar);
132 char *suffix( str, suf)
136 char *s, *strncpy(), *strcat();
137 int strl, sufl, prefl;
142 for ( s = str + strl; --s >= str && *s != '.';)
150 if ( prefl + sufl + 1 > 14 )
151 prefl = 14 - 1 - sufl;
153 strncpy( res, str, prefl);
155 s = strcat( res, ".");
165 name = suffix( name, "c");
167 if ( !sys_open( name, OP_WRITE, &outfile))
168 fprint( STDERR, "!! can't create %s !!\n", name);
176 out( "#define CODE_EXPANDER\n");
177 out( "#include \"mach.h\"\n");
178 out( "#include \"back.h\"\n\n");
179 out( "extern int B_holno, B_procno;\n\n");