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".
8 static char rcs_m[]= "$Id: mach.c,v 1.10 1994/06/24 13:00:02 ceriel Exp $" ;
9 static char rcs_mh[]= ID_MH ;
13 * machine dependent back end routines for the Intel 8086
16 con_part(sz,w) register sz; word w; {
18 while (part_size % sz)
20 if (part_size == TEM_WSIZE)
34 con_mult(sz) word sz; {
38 fatal("bad icon/ucon size");
40 fprintf(codefile,"\t.data2 %d,%d\n",
41 (int)l&0xFFFF,(int)(l>>16)&0xFFFF);
44 #define CODE_GENERATOR
46 #define FL_MSL_AT_LOW_ADDRESS 0
47 #define FL_MSW_AT_LOW_ADDRESS 0
48 #define FL_MSB_AT_LOW_ADDRESS 0
53 string holstr(n) word n; {
55 sprintf(str,hol_off,n,holno);
56 return(mystrcpy(str));
64 prolog(nlocals) full nlocals; {
66 fputs("\tpush\tbp\n\tmov\tbp,sp\n", codefile);
71 case 4: fputs("\tpush\tax\n", codefile);
72 case 2: fputs("\tpush\tax\n", codefile);
75 fprintf(codefile, "\tsub\tsp,%d\n",nlocals); break;
85 regscore(off, size, typ, score, totyp)
88 if (size != 2) return -1;
91 if (typ == reg_pointer || typ == reg_loop) score += (score >> 2);
92 score -= 2; /* cost of saving */
93 if (off >= 0) score -= 3;
106 if (si_off != di_off) {
107 if (di_off == -lbytes) lbytes -= 2;
108 if (si_off == -lbytes) lbytes -= 2;
109 if (di_off == -lbytes) lbytes -= 2;
112 case 4: fputs("\tpush\tax\n", codefile);
113 case 2: fputs("\tpush\tax\n", codefile);
116 fprintf(codefile, "\tsub\tsp,%d\n",lbytes); break;
119 fputs("push di\n", codefile);
120 if (si_off != -1) fputs("push si\n", codefile);
122 else if (firstreg == -1) {
123 fputs("push si\n", codefile);
124 if (di_off != -1) fputs("push di\n", codefile);
127 fprintf(codefile, "mov di,%ld(bp)\n", di_off);
129 fprintf(codefile, "mov si,%ld(bp)\n", si_off);
132 regsave(regstr, off, size)
136 if (strcmp(regstr, "si") == 0) {
137 if (! firstreg) firstreg = -1;
141 if (! firstreg) firstreg = 1;
149 if (si_off != -1) fputs("jmp .sdret\n", codefile);
150 else fputs("jmp .dret\n", codefile);
152 else if (firstreg == -1) {
153 if (di_off != -1) fputs("jmp .dsret\n", codefile);
154 else fputs("jmp .sret\n", codefile);
156 else fputs("jmp .cret\n", codefile);
160 mes(type) word type ; {
163 switch ( (int)type ) {
166 switch ( argt=getarg(
167 ptyp(sp_cend)|ptyp(sp_pnam)|sym_ptyp) ) {
172 fprintf(codefile, ".define %s\n",argstr) ;
177 while ( getarg(any_ptyp) != sp_cend ) ;
183 ".sect .text", /* SEGTXT */
184 ".sect .data", /* SEGCON */
185 ".sect .rom", /* SEGROM */
186 ".sect .bss" /* SEGBSS */