annotate mc-code-ia32.c @ 92:e7f8515ba882

*** empty log message ***
author kono
date Fri, 07 Mar 2003 06:10:41 +0900
parents 917947ffeb7c
children 8f5d61239b93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1 /* Micro-C Code Generatation Part for intel386 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2 /* $Id$ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
4 #define EXTERN extern
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
5 #include "mc.h"
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
6 #include "mc-codegen.h"
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
7
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
8 #define TEXT_EMIT_MODE 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
9 #define DATA_EMIT_MODE 1
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
10 #define RODATA_EMIT_MODE 2
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
11
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
12 static int output_mode = TEXT_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
13 static int data_alignment = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
14
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
15 static int code_disp_label;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
16 static int func_disp_label;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
17
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
18 /*
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
19 -16 -8 local2
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
20 -12 -4 local1
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
21 -8 8 arg3
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
22 -4 4 arg2
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
23 0 0 arg1
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
24 local2 -20 4 0 (%edi)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
25 local1 <-- -16 0 local variable 0 (%esi)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
26 %edi -12 <- disp_offset %ebp
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
27 %esi -8
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
28 %ebx -4
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
29 %ebp = %esp 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
30 %eip 4 <- arg_offset
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
31 arg1 8 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
32 arg2 12 4
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
33 see enter/enter1/leave see code_enter
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
34 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
35 int arg_offset = 8;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
36 int disp_offset = -12;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
37 int func_disp_offset = -12;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
38 int code_disp_offset = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
39 int jump_offset = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
40
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
41 int size_of_int = 4;
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
42 int size_of_float = 4;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
43 int size_of_double = 8;
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
44 int size_of_longlong = 8;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
45 int endian = 0;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
46 int MAX_REGISTER=6; /* intel386のレジスタを6つまで使う*/
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
47 int REAL_MAX_REGISTER=8; /* intel386のレジスタが8つということ*/
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
48 int MAX_DATA_REG=4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
49 int MAX_POINTER=3;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
50 int MAX_REGISTGER_VAR=2;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
51 int MAX_FREGISTER=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
52
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
53
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
54 #define REG_EAX 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
55 #define REG_EBX 1
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
56 #define REG_ECX 2
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
57 #define REG_EDX 3
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
58 #define REG_ESI 4
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
59 #define REG_EDI 5
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
60 #define REG_EBP 6
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
61 #define REG_ESP 7
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
62
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
63
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
64 #define DATA_REG 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
65 #define POINTER_REG 3
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
66 static char *reg_name[8];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
67 static char *reg_name_l[4];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
68 static char *reg_name_w[4];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
69
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
70 void use_register(int virt, int real, int move);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
71 void code_preinc(int e1,int e2) ;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
72 void code_cmp_register(int e2) ;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
73 void code_assign_gvar(int e2,int byte) ;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
74 void tosop(int op,int oreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
75 void edx_cleanup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
76 void shift(char *op, int reg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
77 void ld_indexx(int byte, int n, int xreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
78 void jmp(int l);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
79 void local_table(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
80 void text_mode(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
81 void data_mode(char *name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
82
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
83 char *register_name(int i,int byte);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
84 int register_var(int r);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
85 int get_register_var(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
86 void emit_push(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
87 int emit_pop(int type);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
88 void code_crlvar(int e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
89 void code_preinc(int e1,int e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
90 void code_postinc(int e1,int e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
91 void code_bool(int e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
92 void string(int e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
93 void emit_copy(int from,int to,int length,int offset,int value,int det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
94 int struct_push(int e4,int t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
95 void function(int e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
96 void code_assop(int op,int byte);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
97 int edx_setup();
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
98 void code_opening(char *filename);
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
99 void code_closing();
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
100 void code_leave(char *name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
101 int lvar(int l);
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
102 void global_table(void);
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
103 int virtual(int real);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
104 char * fload(int d);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
105 int code_d1(double d);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
106 int code_d2(double d);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
107
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
108 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
109 code_init(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
110 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
111 arg_offset = 8;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
112 func_disp_offset = -12;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
113 disp_offset = -12;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
114 size_of_int = 4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
115 endian = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
116 MAX_REGISTER=6;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
117 MAX_DATA_REG=4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
118 MAX_POINTER=3;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
119 MAX_REGISTER_VAR=2;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
120
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
121 reg_name[REG_EAX] = "%eax";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
122 reg_name[REG_EBX] = "%ebx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
123 reg_name[REG_ECX] = "%ecx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
124 reg_name[REG_EDX] = "%edx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
125 reg_name[REG_ESI] = "%esi";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
126 reg_name[REG_EDI] = "%edi";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
127 reg_name[REG_EBP] = "%ebp";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
128 reg_name[REG_ESP] = "%esp";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
129 reg_name_l[REG_EAX] = "%al";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
130 reg_name_l[REG_EBX] = "%bl";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
131 reg_name_l[REG_ECX] = "%cl";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
132 reg_name_l[REG_EDX] = "%dl";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
133 reg_name_w[REG_EAX] = "%ax";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
134 reg_name_w[REG_EBX] = "%bx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
135 reg_name_w[REG_ECX] = "%cx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
136 reg_name_w[REG_EDX] = "%dx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
137
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
138 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
139
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
140 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
141 register_name(int i,int byte)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
142 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
143 if (i<0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
144 error(REG_ERR);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
145 return "%eax";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
146 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
147 if (byte && rname[i] <= REG_EDX) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
148 return reg_name_l[rname[i]];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
149 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
150 return reg_name[rname[i]]; /* should be error */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
151 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
152 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
153
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
154 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
155 gexpr_code_init(void){
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
156 use_register(creg,REG_EAX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
157 regv[dreg]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
158 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
159
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
160 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
161 register_var(int r) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
162 return virtual(r+REG_ESI);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
163 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
164
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
165
917947ffeb7c power pc version
kono
parents: 87
diff changeset
166
917947ffeb7c power pc version
kono
parents: 87
diff changeset
167 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
168 get_register(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
169 { /* 使われていないレジスタを調べる */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
170 int i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
171 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
172 if (! regs[i]) { /* 使われていないなら */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
173 regs[i]=1; /* そのレジスタを使うことを宣言し */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
174 return i; /* その場所を表す番号を返す */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
175 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
176 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
177 return -1; /* 空いている場所がないなら、それを表す -1 を返す */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
178 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
179
917947ffeb7c power pc version
kono
parents: 87
diff changeset
180 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
181 free_register(int i) { /* いらなくなったレジスタを開放 */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
182 regv[i]=regs[i]=0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
183 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
184
917947ffeb7c power pc version
kono
parents: 87
diff changeset
185 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
186 register_full(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
187 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
188 int i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
189 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
190 if (! regs[i]) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
191 return 0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
192 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
193 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
194 return 1;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
195 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
196
917947ffeb7c power pc version
kono
parents: 87
diff changeset
197 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
198 free_register_count(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
199 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
200 int i,count;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
201 count = 0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
202 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
203 if (! regs[i] && ! regv[i]) count++;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
204 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
205 return count;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
206 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
207
917947ffeb7c power pc version
kono
parents: 87
diff changeset
208 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
209 free_all_register(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
210 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
211 int i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
212 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
213 regs[i]=regv[i]=0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
214 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
215 creg = get_register();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
216 dreg = get_register();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
217 return;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
218 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
219
917947ffeb7c power pc version
kono
parents: 87
diff changeset
220 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
221 use_register_var(int i) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
222 regv[i]=1;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
223 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
224
917947ffeb7c power pc version
kono
parents: 87
diff changeset
225 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
226 set_register_var() {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
227 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
228
917947ffeb7c power pc version
kono
parents: 87
diff changeset
229 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
230 code_arg_register(int args)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
231 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
232 NMTBL *n;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
233 if (args) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
234 /* process in reverse order */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
235 n = (NMTBL*)caddr(args);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
236 if(n->sc==REGISTER) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
237 if ((n->dsp = get_register_var()) <0) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
238 error(-1); return;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
239 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
240 use_register_var(n->dsp); /* it has now value in it */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
241 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
242 code_arg_register(cadr(args));
917947ffeb7c power pc version
kono
parents: 87
diff changeset
243 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
244 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
245
917947ffeb7c power pc version
kono
parents: 87
diff changeset
246
917947ffeb7c power pc version
kono
parents: 87
diff changeset
247 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
248 register_usage(char *s)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
249 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
250 int i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
251 if (chk) return;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
252 printf("# %d: %s:",lineno,s);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
253 printf(" creg=%s dreg=%s ",register_name(creg,0),register_name(dreg,0));
917947ffeb7c power pc version
kono
parents: 87
diff changeset
254 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
255 printf("%d",regs[i]);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
256 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
257 printf(":");
917947ffeb7c power pc version
kono
parents: 87
diff changeset
258 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
259 printf("%d",regv[i]);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
260 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
261 #if 0
917947ffeb7c power pc version
kono
parents: 87
diff changeset
262 printf(" regs_stack",register_name(creg,0),register_name(dreg,0));
917947ffeb7c power pc version
kono
parents: 87
diff changeset
263 for(i=reg_sp;i>=0;i--) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
264 if(reg_stack[i]>=0)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
265 printf(" %s",register_name(reg_stack[i],0));
917947ffeb7c power pc version
kono
parents: 87
diff changeset
266 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
267 #endif
917947ffeb7c power pc version
kono
parents: 87
diff changeset
268 printf("\n");
917947ffeb7c power pc version
kono
parents: 87
diff changeset
269 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
270
917947ffeb7c power pc version
kono
parents: 87
diff changeset
271 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
272 gexpr_init(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
273 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
274 while(reg_sp > 0) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
275 free_register(reg_stack[--reg_sp]);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
276 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
277 text_mode();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
278 gexpr_code_init();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
279 register_usage("gexpr_init");
917947ffeb7c power pc version
kono
parents: 87
diff changeset
280 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
281
917947ffeb7c power pc version
kono
parents: 87
diff changeset
282
917947ffeb7c power pc version
kono
parents: 87
diff changeset
283 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
284 emit_init(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
285 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
286 int i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
287 for(i=0;i<MAX_REGISTER;i++) { regs[i]=0; regv[i]=0;rname[i]=i;}
917947ffeb7c power pc version
kono
parents: 87
diff changeset
288 free_all_register();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
289 reg_sp = 0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
290 text_mode();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
291 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
292
917947ffeb7c power pc version
kono
parents: 87
diff changeset
293 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
294 virtual(int real)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
295 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
296 int real_v,i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
297 real_v = -1;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
298 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
299 if (rname[i]==real) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
300 real_v=i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
301 break;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
302 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
303 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
304 return real_v;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
305 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
306
917947ffeb7c power pc version
kono
parents: 87
diff changeset
307 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
308 pop_register(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
309 { /* レジスタから値を取り出す */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
310 return reg_stack[--reg_sp];
917947ffeb7c power pc version
kono
parents: 87
diff changeset
311 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
312
917947ffeb7c power pc version
kono
parents: 87
diff changeset
313 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
314 stack_used(void) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
315 return reg_stack[--reg_sp]<0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
316 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
317
917947ffeb7c power pc version
kono
parents: 87
diff changeset
318 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
319 emit_pop_free(int xreg)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
320 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
321 if (xreg==dreg) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
322 regv[dreg]=0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
323 } else if (xreg!=-1) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
324 free_register(xreg);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
325 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
326 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
327
917947ffeb7c power pc version
kono
parents: 87
diff changeset
328
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
329 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
330 get_register_var(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
331 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
332 int i;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
333 for(i=REG_ESI;i<REG_ESP;i++) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
334 if (! regs[i]) { /* 使われていないなら */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
335 regs[i]=1; /* そのレジスタを使うことを宣言し */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
336 regv[i]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
337 return i; /* その場所を表す番号を返す */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
338 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
339 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
340 return -1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
341 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
342
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
343 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
344 use_register(int virt, int real, int move)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
345 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
346 int real_v;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
347 char *move_op;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
348 if (rname[virt]==real)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
349 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
350 real_v = virtual(real);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
351 move_op = regs[real_v]?"\txchg %s,%s\n":"\tmovl %s,%s\n";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
352 if (move || (regv[real_v])) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
353 printf(move_op,reg_name[rname[virt]],reg_name[real]);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
354 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
355 rname[real_v] = rname[virt];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
356 rname[virt] = real;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
357 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
358
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
359 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
360 use_pointer(int virt, int move)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
361 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
362 int i;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
363 if (rname[virt]>=POINTER_REG)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
364 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
365 for(i=POINTER_REG;i<MAX_REGISTER;i++) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
366 if (!regs[virtual(i)]) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
367 use_register(virt,i,move);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
368 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
369 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
370 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
371 /* we prefer EBX */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
372 use_register(virt,REG_EBX,move);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
373 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
374
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
375 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
376 use_data_reg(int virt, int move)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
377 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
378 int i;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
379 if (rname[virt]<MAX_DATA_REG)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
380 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
381 for(i=0;i<MAX_DATA_REG;i++) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
382 if (!regs[virtual(i)]) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
383 use_register(virt,i,move);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
384 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
385 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
386 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
387 /* we prefer EBX */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
388 use_register(virt,REG_EBX,move);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
389 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
390
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
391
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
392 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
393 emit_push(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
394 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
395 int new_reg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
396 new_reg = get_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
397 if(new_reg<0) { /* もうレジスタがない */
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
398 if (reg_sp>=MAX_MAX) error(-1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
399 reg_stack[reg_sp++] = -1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
400 printf("\tpushl %s\n",register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
401 /* creg is used soon, don't regv[creg]=0 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
402 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
403 reg_stack[reg_sp++] = creg; /* push するかわりにレジスタを使う */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
404 creg = new_reg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
405 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
406 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
407 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
408
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
409 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
410 emit_pop(int type)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
411 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
412 int xreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
413 if ((xreg=pop_register())==-1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
414 if (type==POINTER_REG)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
415 use_pointer(dreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
416 else if (type==DATA_REG)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
417 use_data_reg(dreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
418 if (regv[dreg]) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
419 printf("# emit_pop dreg conflict\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
420 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
421 printf("\tpopl %s\n",register_name(dreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
422 xreg = dreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
423 regv[xreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
424 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
425 return xreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
426 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
427
92
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
428 void
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
429 code_label(int labelno)
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
430 {
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
431 printf("_%d:\n",labelno);
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
432 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
433
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
434 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
435 code_gvar(int e1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
436 printf("\tmovl $%s,%s\n",(char *)caddr(e1),register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
437 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
438
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
439
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
440 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
441 code_rgvar(int e1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
442 printf("\tmovl %s,%s\n",(char *)caddr(e1),register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
443 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
444
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
445 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
446 code_crgvar(e1){
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
447 printf("\tmovsbl %s,%s\n",(char *)caddr(e1),register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
448 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
449
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
450
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
451 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
452 code_lvar(int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
453 printf("\tlea %d(%%ebp),%s\n",e2,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
454 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
455
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
456
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
457 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
458 code_register(int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
459 printf("\tmovl %s,%s\n",register_name(e2,0),register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
460 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
461
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
462
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
463 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
464 code_rlvar(int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
465 printf("\tmovl %d(%%ebp),%s\n",e2,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
466 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
467
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
468
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
469 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
470 code_crlvar(int e2) {
62
129f4802b027 separation done
kono
parents: 61
diff changeset
471 printf("\tmovsbl %d(%%ebp),%s\n",e2,register_name(creg,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
472 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
473
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
474
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
475 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
476 code_fname(char *e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
477 printf("\tmovl $%s,%s\n",e2,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
478 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
479
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
480
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
481 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
482 code_const(int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
483 printf("\tmovl $%d,%s\n",e2,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
484 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
485
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
486
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
487 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
488 code_neg() {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
489 printf("\tnegl %s\n", register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
490 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
491
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
492
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
493 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
494 code_not() {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
495 printf("\tnotl %s\n", register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
496 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
497
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
498
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
499 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
500 code_lnot() {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
501 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
502 use_data_reg(creg,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
503 xrn = register_name(creg,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
504 printf("\tcmpl $0,%s\n", register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
505 printf("\tsete %s\n", xrn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
506 printf("\tmovzbl %s,%s\n", xrn,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
507 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
508
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
509 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
510 code_preinc(int e1,int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
511 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
512 if (car(e2)==REGISTER) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
513 printf("\taddl $%d,%s\n",caddr(e1),register_name(cadr(e2),0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
514 printf("\tmovl %s,%s\n",register_name(cadr(e2),0),register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
515 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
516 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
517 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
518 xrn = register_name(creg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
519 printf("\taddl $%d,(%s)\n",caddr(e1),xrn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
520 printf("\tmovl (%s),%s\n",xrn,xrn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
521 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
522
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
523
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
524 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
525 code_postinc(int e1,int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
526 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
527 if (car(e2)==REGISTER) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
528 printf("\tmovl %s,%s\n",register_name(cadr(e2),0),register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
529 printf("\taddl $%d,%s\n",caddr(e1),register_name(cadr(e2),0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
530 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
531 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
532 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
533 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
534 xrn = register_name((e2=emit_pop(0)),0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
535 printf("\tmovl (%s),%s\n",xrn,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
536 printf("\taddl $%d,(%s)\n",caddr(e1),xrn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
537 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
538 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
539
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
540
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
541 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
542 code_cpostinc(int e1,int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
543 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
544 if (car(e2)==REGISTER) {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
545 printf("\tmovbl (%s),%s\n",register_name(cadr(e2),0),
917947ffeb7c power pc version
kono
parents: 87
diff changeset
546 register_name(creg,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
547 printf("\taddl $%d,%s\n",caddr(e1),register_name(cadr(e2),0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
548 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
549 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
550 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
551 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
552 xrn = register_name((e2=emit_pop(0)),1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
553 printf("\tmovsbl (%s),%s\n",xrn,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
554 printf("\tincl (%s)\n",xrn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
555 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
556 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
557
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
558
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
559 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
560 code_cpreinc(int e1,int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
561 if (car(e2)==REGISTER) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
562 printf("\taddl $%d,%s\n",caddr(e1),register_name(cadr(e2),0));
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
563 printf("\tmovsbl (%s),%s\n",register_name(cadr(e2),0),
917947ffeb7c power pc version
kono
parents: 87
diff changeset
564 register_name(creg,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
565 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
566 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
567 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
568 printf("\tincl (%s)\n",register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
569 printf("\tmovsbl (%s),%s\n",register_name(creg,0),register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
570 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
571
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
572
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
573 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
574 code_cpostdec(int e1,int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
575 if (car(e2)==REGISTER) {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
576 printf("\tmovsbl (%s),%s\n",register_name(cadr(e2),0),
917947ffeb7c power pc version
kono
parents: 87
diff changeset
577 register_name(creg,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
578 printf("\tdecl %s\n",register_name(cadr(e2),0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
579 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
580 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
581 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
582 printf("\tmovsbl (%s),%s\n",register_name(creg,0),register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
583 printf("\tdecl (%s)\n",register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
584 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
585
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
586
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
587 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
588 code_cpredec(int e1,int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
589 if (car(e2)==REGISTER) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
590 printf("\tdecl %s\n",register_name(cadr(e2),0));
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
591 printf("\tmovsbl (%s),%s\n",register_name(cadr(e2),0),
917947ffeb7c power pc version
kono
parents: 87
diff changeset
592 register_name(creg,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
593 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
594 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
595 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
596 e2 = emit_pop(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
597 printf("\tdecl (%s)\n",register_name(e2,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
598 printf("\tmovsbl (%s),%s\n",register_name(e2,0),register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
599 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
600 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
601
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
602
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
603 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
604 code_return() {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
605 printf("\tleal _%d,%s\n",retcont,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
606 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
607
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
608
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
609 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
610 code_environment() {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
611 printf("\tmovl %%ebp,%s\n",register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
612 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
613
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
614
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
615 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
616 code_bool(int e1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
617 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
618 int e2,e3;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
619 b_expr(e1,1,e2=fwdlabel(),1); /* including > < ... */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
620 xrn = register_name(creg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
621 printf("\txorl %s,%s\n",xrn,xrn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
622 jmp(e3=fwdlabel());
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
623 fwddef(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
624 printf("\tmovl $1,%s\n",xrn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
625 fwddef(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
626 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
627
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
628 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
629 code_gt(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
630 return (cond?"g":"le");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
631 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
632
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
633 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
634 code_ugt(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
635 return (cond?"a":"be");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
636 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
637
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
638 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
639 code_ge(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
640 return (cond?"ge":"l");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
641 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
642
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
643 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
644 code_uge(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
645 return (cond?"ae":"b");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
646 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
647
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
648 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
649 code_eq(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
650 return (cond?"e":"ne");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
651 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
652
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
653 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
654 code_cmp_crgvar(int e1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
655 printf("\tcmpb $0,%s\n",(char *)caddr(e1));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
656 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
657
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
658
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
659 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
660 code_cmp_crlvar(int e1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
661 printf("\tcmpb $0,%d(%%ebp)\n",e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
662 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
663
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
664
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
665 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
666 code_cmp_rgvar(int e1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
667 printf("\tcmpl $0,%s\n",(char *)caddr(e1));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
668 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
669
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
670
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
671 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
672 code_cmp_rlvar(int e1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
673 printf("\tcmpl $0,%d(%%ebp)\n",e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
674 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
675
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
676
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
677 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
678 code_cmp_register(int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
679 printf("\tcmpl $0,%s\n",register_name(e2,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
680 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
681
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
682
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
683 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
684 ascii(char *s)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
685 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
686 printf("\t.string \"");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
687 while(*s) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
688 if (*s=='\n')
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
689 printf("%cn",92);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
690 else if (*s<' ')
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
691 printf("%c%03o",92,*s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
692 else if (*s==34)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
693 printf("%c%c",92,34);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
694 else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
695 printf("%c",*s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
696 s++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
697 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
698 printf("%c\n",34);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
699 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
700
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
701 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
702 string(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
703 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
704 char *s;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
705 int i,lb;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
706
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
707 if (0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
708 s=(char *)cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
709 lb=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
710 printf("\tjmp _%d\n",lb);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
711 i=backdef();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
712 ascii(s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
713 printf("\t.align 2\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
714 fwddef(lb);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
715 printf("\tlea _%d,%s\n",i,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
716 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
717 s=(char *)cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
718 printf(".section\t.rodata\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
719 lb=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
720 printf("_%d:\n",lb);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
721 ascii(s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
722 if (output_mode==TEXT_EMIT_MODE) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
723 printf(".text\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
724 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
725 text_mode();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
726 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
727 printf("\tlea _%d,%s\n",lb,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
728 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
729 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
730
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
731 #define MAX_COPY_LEN 20
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
732
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
733 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
734 emit_copy(int from,int to,int length,int offset,int value,int det)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
735 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
736 int fix = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
737 /* length <0 means upward direction copy */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
738 switch (length) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
739 case 0: break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
740 case 1: case -1:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
741 printf("\tmovb %d(%s),%s\n",offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
742 register_name(from,0), reg_name_l[rname[dreg]] );
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
743 printf("\tmovb %s,%d(%s)\n",reg_name_l[rname[dreg]] ,offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
744 register_name(to,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
745 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
746 case 2: case -2:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
747 printf("\tmovw %d(%s),%s\n",offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
748 register_name(from,0), reg_name_w[rname[dreg]] );
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
749 printf("\tmovw %s,%d(%s)\n",reg_name_w[rname[dreg]] ,offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
750 register_name(to,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
751 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
752 case 4: case -4:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
753 printf("\tmovl %d(%s),%s\n",offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
754 register_name(from,0), register_name(dreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
755 printf("\tmovl %s,%d(%s)\n",register_name(dreg,0), offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
756 register_name(to,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
757 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
758 default:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
759 if (-MAX_COPY_LEN<length && length <0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
760 for(;length<=4;length+=4,offset-=4)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
761 emit_copy(from,to,4,offset,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
762 for(;length<=2;length+=2,offset-=2)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
763 emit_copy(from,to,2,offset,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
764 if(length>0)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
765 emit_copy(from,to,length,offset,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
766 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
767 } else if (length <=MAX_COPY_LEN) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
768 for(;length>=4;length-=4,offset+=4)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
769 emit_copy(from,to,4,offset,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
770 for(;length>=2;length-=2,offset+=2)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
771 emit_copy(from,to,2,offset,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
772 if(length>0)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
773 emit_copy(from,to,length,offset,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
774 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
775 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
776 if (det) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
777 /*
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
778 call bcopy
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
779 g_expr(list3(FUNCTION,,);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
780 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
781 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
782 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
783 use_register(from,REG_ESI,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
784 use_register(to, REG_EDI,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
785 use_register(dreg,REG_ECX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
786 if (length<0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
787 printf("\tmovl $%d,%%ecx\n",-length/4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
788 printf("\taddl $%d,%%esi\n",-length);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
789 printf("\taddl $%d,%%edi\n",-length);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
790 printf("\tstd\n\trep\n\tmovsl\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
791 if(length%4) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
792 emit_copy(from,to,length,offset+length/4,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
793 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
794 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
795 printf("\tmovl $%d,%%ecx\n",length/4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
796 fix = (length/4)*4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
797 printf("\tcld\n\trep\n\tmovsl\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
798 if(length%4) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
799 emit_copy(from,to,length,offset+length/4,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
800 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
801 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
802 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
803 if (value) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
804 /* creg must point top of the destination data */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
805 /* this code is necessary for the value of assignment or function call */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
806 /* otherwise we don't need this */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
807 if (fix) printf("\tsubl $%d,%s\n",fix,register_name(to,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
808 if(creg!=to) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
809 if (to==dreg)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
810 printf("\tmovl %s,%s\n",register_name(to,0),register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
811 else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
812 free_register(creg); creg=to;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
813 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
814 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
815 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
816 regv[from]=regv[to]=regv[dreg]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
817 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
818 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
819
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
820 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
821 struct_push(int e4,int t)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
822 {
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
823 int length,xreg,save,lreg,count;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
824 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
825 length=size(t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
826 if(length%size_of_int) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
827 length += size_of_int - (length%size_of_int);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
828 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
829 for(count=0;length<MAX_COPY_LEN;count++,length-=size_of_int) {
f94ca1168520 float first try...
kono
parents: 78
diff changeset
830 if (length==0) return count;
f94ca1168520 float first try...
kono
parents: 78
diff changeset
831 else {
f94ca1168520 float first try...
kono
parents: 78
diff changeset
832 printf("\tpushl %d(%s)\n",
f94ca1168520 float first try...
kono
parents: 78
diff changeset
833 length-size_of_int,register_name(creg,0));
f94ca1168520 float first try...
kono
parents: 78
diff changeset
834 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
835 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
836 printf("\tsubl $%d,%%esp\n",length);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
837 if (register_full()) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
838 save = 1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
839 for(lreg=0;lreg==creg||lreg==dreg;lreg++);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
840 printf("\tpushl %s\n",register_name(lreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
841 xreg = lreg; regv[xreg]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
842 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
843 save=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
844 xreg = get_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
845 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
846 if (save)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
847 printf("\tlea %d(%%esp),%s\n",size_of_int,register_name(xreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
848 else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
849 printf("\tmovl %%esp,%s\n",register_name(xreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
850 regv[xreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
851 /* downward direction copy */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
852 emit_copy(creg,xreg,length,0,0,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
853 /* we have value in creg, it may be changed */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
854 if (save) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
855 if(creg==xreg) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
856 creg = get_register(); /* creg is freed in emit_copy */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
857 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
858 printf("\tpopl %s\n",register_name(xreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
859 regv[xreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
860 } else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
861 free_register(xreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
862 return length/size_of_int;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
863 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
864
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
865 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
866 function(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
867 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
868 int e2,e3,e4,e5,nargs,t;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
869 NMTBL *n;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
870 int save,saved;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
871 if (free_register_count()<1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
872 for(save = 0;save==dreg||save==creg;save++);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
873 printf("\tpushl %s\n",register_name(save,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
874 saved = 1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
875 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
876 save = get_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
877 saved = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
878 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
879 regv[save]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
880 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
881 nargs = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
882 for (e3 = caddr(e1); e3; e3 = cadr(e3)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
883 t=caddr(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
884 n=(NMTBL *)(e5=(cadr(e4 = car(e3))));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
885 if(scalar(t)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
886 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
887 printf("\tpushl %s\n",register_name(creg,0));
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
888 } else if (t==DOUBLE) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
889 g_expr(e4);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
890 printf("\tleal\t-8(%%esp),%%esp\n\tfstpl\t(%%esp)\n");
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
891 nargs += size_of_double/size_of_int;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
892 fregv[freg]=0;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
893 continue;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
894 } else if (t==FLOAT) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
895 g_expr(e4);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
896 printf("\tleal\t-4(%%esp),%%esp\n\tfstps\t(%%esp)\n");
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
897 nargs += size_of_float/size_of_int;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
898 fregv[freg]=0;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
899 continue;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
900 } else if (car(t)==STRUCT||car(t)==UNION) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
901 nargs += struct_push(e4,t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
902 continue;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
903 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
904 error(TYERR);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
905 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
906 ++nargs;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
907 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
908 if (car(e2) == FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
909 n=(NMTBL *)cadr(e2);
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
910 regv[creg]=0;
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
911 use_register(creg,REG_EAX,0); /* will be destroyed */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
912 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
913 g_expr(e2);
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
914 regv[creg]=1;
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
915 use_register(creg,REG_EAX,1); /* will be destroyed */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
916 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
917
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
918 /* we don't have to save creg nor dreg */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
919 regs[creg]=0; regs[dreg]=0;
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
920 regv[dreg]= regv[save]= 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
921 use_register(dreg,REG_EDX,0); /* will be destroyed */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
922 use_register(save,REG_ECX,0); /* will be destroyed */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
923 regs[creg]=1; regs[dreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
924
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
925 if (car(e2) == FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
926 printf("\tcall\t%s\n",n->nm);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
927 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
928 printf("\tcall\t*%s\n",register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
929 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
930 if (nargs) printf("\taddl $%d,%%esp\n",size_of_int*nargs);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
931 if (saved) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
932 printf("\tpopl %s\n",register_name(save,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
933 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
934 free_register(save);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
935 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
936 regv[save]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
937 regv[creg]=1;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
938 fregv[freg]=1; /* return type はどこ? fnptr にはあるけど... */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
939 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
940
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
941 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
942 code_frame_pointer(int e3) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
943 printf("\tmovl %s,%%ebp\n",register_name(e3,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
944 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
945
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
946
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
947 void
62
129f4802b027 separation done
kono
parents: 61
diff changeset
948 code_fix_frame_pointer(int disp_offset) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
949 printf("\tlea %d(%%ebp),%%ebp\n",disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
950 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
951
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
952
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
953 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
954 code_jmp(char *s) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
955 printf("\tjmp %s\n",s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
956 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
957
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
958
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
959 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
960 code_indirect_jmp(int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
961 printf("\tjmp *%s\n",register_name(e2,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
962 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
963
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
964 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
965 rindirect(int e1) /* *(p +5 ) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
966 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
967 char *op;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
968 int e2,e3,byte;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
969 e3 = cadr(e2 = cadr(e1));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
970 g_expr(e2);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
971 switch (car(e1)) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
972 case FRINDIRECT: case DRINDIRECT:
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
973 printf("\t%s (%s)\n",fload(car(e1)==DRINDIRECT),register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
974 break;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
975 case CRINDIRECT: case RINDIRECT:
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
976 op = ((byte = (car(e1) == CRINDIRECT)) ? "movsbl" : "movl");
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
977 printf("\t%s (%s),%s\n",op,register_name(creg,0),register_name(creg,0));
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
978 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
979 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
980
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
981 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
982 move(int byte)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
983 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
984 return byte?"movb":"movl";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
985 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
986
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
987 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
988 code_assign_gvar(int e2,int byte) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
989 if (byte) use_data_reg(creg,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
990 printf("\t%s %s,%s\n",move(byte),register_name(creg,byte),(char *)caddr(e2));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
991 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
992
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
993 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
994 code_assign_lvar(int e2,int byte) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
995 if (byte) use_data_reg(creg,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
996 printf("\t%s %s,%d(%%ebp)\n",move(byte),register_name(creg,byte),e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
997 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
998
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
999 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1000 code_assign_register(int e2,int byte) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1001 printf("\tmovl %s,%s\n",register_name(creg,0),register_name(e2,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1002 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1003
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1004 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1005 code_assign(int e2,int byte) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1006 printf("\t%s %s,(%s)\n",move(byte),register_name(creg,byte),register_name(e2,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1007 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1008
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1009
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1010 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1011 code_register_assop(int e2,int op,int byte) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1012 int reg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1013 int xreg = creg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1014 creg = reg = e2;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1015 tosop(op,xreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1016 creg = xreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1017 printf("\tmovl %s,%s\n",register_name(reg,0),register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1018 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1019
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1020
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1021 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1022 code_assop(int op,int byte) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1023 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1024 int xreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1025 int edx = edx_setup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1026 xrn = register_name(xreg = emit_pop(0),0); /* pop e3 value */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1027 regv[xreg]=regs[xreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1028 printf("\tmovl %s,%s # assop \n",register_name(creg,0),register_name(edx,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1029 regv[edx]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1030 ld_indexx(byte,0,edx);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1031 tosop(op,xreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1032 printf("\t%s %s,(%s)\n",byte ? "movb" : "movl",register_name(creg,byte),register_name(edx,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1033 edx_cleanup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1034 emit_pop_free(xreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1035 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1036
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1037
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1038 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1039 tosop(int op,int oreg)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1040 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1041 int dx;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1042 char *orn,*crn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1043
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1044 switch(op) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1045 case LSHIFT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1046 case ULSHIFT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1047 shift("sall",oreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1048 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1049 case RSHIFT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1050 shift("sarl",oreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1051 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1052 case URSHIFT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1053 shift("shrl",oreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1054 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1055 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1056 if(oreg==-1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1057 printf("\tpopl %s\n",register_name(dreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1058 oreg = dreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1059 regv[dreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1060 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1061 regv[oreg]=1; regs[oreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1062 orn = register_name(oreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1063 crn = register_name(creg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1064 switch(op) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1065 case ADD:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1066 printf("\taddl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1067 break;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1068 case SUB: case CMP:
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1069 printf("\tsubl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1070 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1071 case BAND:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1072 printf("\tandl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1073 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1074 case EOR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1075 printf("\txorl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1076 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1077 case BOR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1078 printf("\torl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1079 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1080 case MUL:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1081 case UMUL:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1082 printf("\t%s %s,%s\n","imull",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1083 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1084 case DIV:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1085 case UDIV:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1086 use_register(creg,REG_EAX,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1087 edx_setup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1088 orn = register_name(oreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1089 if (op==DIV)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1090 printf("\tcltd\n\tdivl %s\n",orn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1091 else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1092 printf("\txor %%edx,%%edx\n\tidivl %s\n",orn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1093 edx_cleanup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1094 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1095 case MOD:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1096 case UMOD:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1097 use_register(creg,REG_EAX,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1098 edx_setup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1099 orn = register_name(oreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1100 if (op==DIV)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1101 printf("\tcltd\n\tdivl %s\n",orn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1102 else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1103 printf("\txor %%edx,%%edx\n\tidivl %s\n",orn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1104 dx = virtual(REG_EDX);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1105 if (dx!=creg) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1106 rname[dx]=rname[creg];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1107 rname[creg]=REG_EDX;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1108 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1109 edx_cleanup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1110 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1111 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1112 if (oreg!=dreg&&oreg>=0)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1113 free_register(oreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1114 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1115
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1116 static int edx_stack=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1117
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1118 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1119 edx_setup()
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1120 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1121 int edx_save;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1122 /* make real EDX register empty */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1123 if (free_register_count()<1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1124 for(edx_save = 0;edx_save==dreg||edx_save==creg;edx_save++);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1125 printf("\tpushl %s\n",register_name(edx_save,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1126 edx_stack = list3(edx_save,edx_stack,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1127 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1128 edx_save = get_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1129 edx_stack = list3(edx_save,edx_stack,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1130 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1131 regv[edx_save]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1132 use_register(edx_save,REG_EDX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1133 return edx_save;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1134 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1135
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1136
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1137 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1138 edx_cleanup()
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1139 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1140 if (caddr(edx_stack)==0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1141 printf("\tpopl %s\n",register_name(car(edx_stack),0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1142 } else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1143 free_register(car(edx_stack));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1144 edx_stack = cadr(edx_stack);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1145 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1146
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1147 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1148 shift(char *op, int reg)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1149 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1150 if (reg>=0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1151 use_register(reg,REG_ECX,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1152 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1153 use_register(dreg,REG_ECX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1154 printf("\tpopl %%ecx\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1155 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1156 printf("\t%s %%cl,%s\n",op,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1157 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1158
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1159 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1160 ld_indexx(int byte, int n, int xreg)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1161 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1162 char *op;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1163
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1164 op = byte ? "movsbl" : "movl";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1165 if (n)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1166 printf("\t%s %d(%s),%s\n",op,n,register_name(xreg,0),register_name(creg,byte));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1167 else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1168 printf("\t%s (%s),%s\n",op,register_name(xreg,0),register_name(creg,byte));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1169 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1170
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1171 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1172 cmpdimm(int e, int csreg)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1173 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1174 /* used in dosiwtch() */
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1175 if(chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1176 use_register(creg,csreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1177 printf("\tcmpl $%d,%s\n",e,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1178 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1179
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1180 void
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1181 code_opening(char *filename)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1182 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1183 printf("\t.file \"%s\"\n",filename);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1184 printf("\t.version\t\"01.01\"\n");
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1185 /* printf("gcc2_compiled.:\n"); */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1186 printf(".text\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1187 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1188
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1189 void
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1190 code_closing()
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1191 {
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
1192 global_table();
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1193 printf("\t.ident \"Micro-C compiled\"\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1194 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1195
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1196 void
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1197 rexpr(int e1, int l1, char *s,int t)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1198 {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1199 g_expr(list3(CMP,cadr(e1),caddr(e1)));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1200 printf("\tj%s\t_%d\n",s,l1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1201 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1202
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1203
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1204 void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1205 jcond(int l, char cond)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1206 {
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1207 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1208 printf("\tj%s\t_%d\n",cond?"ne":"e",l);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1209 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1210
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1211 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1212 jmp(int l)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1213 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1214 control=0;
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1215 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1216 printf("\tjmp\t_%d\n",l);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1217 /* align? */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1218 /*
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1219 this is not allowed because of ? operator
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1220 regv[creg]=regv[dreg]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1221 use_register(creg,REG_EAX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1222 use_register(dreg,REG_EBX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1223 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1224 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1225
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1226 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1227 gen_comment(char *s)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1228 {
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1229 if (chk) return;
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1230 printf("## %s",s);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1231 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1232
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1233
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1234 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1235 code_enter(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1236 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1237 printf("\t.align 4\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1238 if (stmode!=STATIC)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1239 printf(".globl %s\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1240 printf("\t.type\t%s,@function\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1241 printf("%s:\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1242 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1243
77
2b8ba655e572 fix arg type
kono
parents: 66
diff changeset
1244
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1245 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1246 code_enter1(int args)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1247 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1248 code_disp_label=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1249 printf("\tlea _%d(%%ebp),%%esp\n",code_disp_label);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1250
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1251 printf("## args %d disp %d code_arg_offset=%d code_disp_offset=%d\n",args,disp,code_arg_offset,code_disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1252 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1253
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1254 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1255 code_leave(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1256 {
63
e13486b2c12e stack alignment
kono
parents: 62
diff changeset
1257 disp&= -size_of_int;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1258 printf("\t.set _%d,%d\n",code_disp_label,disp+code_disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1259 printf("_%d:\n",labelno);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1260 printf("\t.size\t%s,_%d-%s\n",name,labelno,name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1261 local_table();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1262 labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1263 free_all_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1264 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1265
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1266 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1267 enter(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1268 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1269 printf("\t.align 2\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1270 if (stmode!=STATIC)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1271 printf(".globl %s\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1272 printf("%s:\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1273 printf("\t.type\t%s,@function\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1274 printf("\tpushl %%ebp\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1275 printf("\tmovl %%esp,%%ebp\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1276 printf("\tpushl %%ebx\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1277 printf("\tpushl %%esi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1278 printf("\tpushl %%edi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1279 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1280
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1281 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1282 enter1()
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1283 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1284 func_disp_label=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1285 printf("\tlea _%d(%%ebp),%%esp\n",func_disp_label);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1286 /* if(disp) printf("\tsubl $%d,%%esp\n",-disp); */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1287 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1288
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1289 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1290 leave(int control, char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1291 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1292 if (control)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1293 use_register(creg,REG_EAX,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1294 if (retcont) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1295 if (control)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1296 jmp(retlabel);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1297 fwddef(retcont);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1298 use_register(creg,REG_EAX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1299 printf("\tmovl %s,%s\n",reg_name[REG_ESI],register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1300 /* printf("\tleave\n"); */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1301 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1302 fwddef(retlabel);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1303 /* use_register(creg,REG_EAX,0); too late */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1304 /* if(disp) printf("\taddl $%d,%%esp\n",-disp); */
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1305 disp &= -size_of_int;
63
e13486b2c12e stack alignment
kono
parents: 62
diff changeset
1306
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1307 printf("\tlea %d(%%ebp),%%esp\n",disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1308 printf("\tpopl %%edi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1309 printf("\tpopl %%esi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1310 printf("\tpopl %%ebx\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1311 printf("\tleave\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1312 printf("\tret\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1313 printf("\t.set _%d,%d\n",func_disp_label,disp+disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1314 printf("_%d:\n",labelno);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1315 printf("\t.size\t%s,_%d-%s\n",name,labelno,name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1316 local_table();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1317 labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1318 free_all_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1319 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1320
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1321
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1322 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1323 code_set_fixed_creg(int mode) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1324 use_register(creg,REG_EAX,mode);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1325 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1326
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1327 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1328 gen_gdecl(char *n, int gpc)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1329 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1330 /*
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1331 if (stmode!=STATIC)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1332 printf(".globl %s\n",n);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1333 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1334 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1335
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1336 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1337 align(int t)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1338 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1339 if (t!=CHAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1340 if (data_alignment & 1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1341 printf("\t.align 2\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1342 data_alignment = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1343 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1344 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1345
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1346 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1347 emit_data(int e, int t, NMTBL *n)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1348 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1349 int l;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1350 double d;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1351 float f;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1352 char *name;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1353 name = n->nm;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1354 if(mode!=GDECL) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1355 error(-1); return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1356 }
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1357 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1358 if (n->dsp != -1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1359 n->dsp = -1; /* initiallized flag */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1360 printf(".globl\t%s\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1361 data_mode(name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1362 align(t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1363 printf("%s:\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1364 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1365 data_mode(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1366 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1367 if(car(e)==CONST) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1368 if (t==CHAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1369 printf("\t.byte %d\n",cadr(e));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1370 if (data_alignment>0)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1371 data_alignment++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1372 gpc += 1;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1373 } else if (t==SHORT) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1374 printf("\t.word %d\n",cadr(e));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1375 if (data_alignment>0) data_alignment++;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1376 gpc += 2;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1377 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1378 printf("\t.long %d\n",cadr(e));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1379 gpc += size_of_int;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1380 }
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1381 } else if(t==DOUBLE) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1382 d = dcadr(e);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1383 printf("\t.long\t0x%x,0x%x\n",code_d1(d),code_d2(d));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1384 } else if(t==FLOAT) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1385 f = dcadr(e);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1386 printf("\t.long\t0x%x\n",*(int *)&f);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1387 } else if(t!=CHAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1388 gpc += size_of_int;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1389 if(car(e)==ADDRESS&&car(cadr(e))==GVAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1390 printf("\t.long %s\n",(char *)caddr(cadr(e)));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1391 } else if(car(e)==FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1392 printf("\t.long %s\n",((NMTBL *)cadr(e))->nm);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1393 } else if(car(e)==STRING) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1394 if (car(n->ty)!=ARRAY || cadr(n->ty)!=CHAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1395 l = fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1396 printf("\t.long _%d\n",l);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1397 printf(".section\t.rodata\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1398 printf("_%d:\n",l);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1399 output_mode = RODATA_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1400 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1401 ascii((char *)cadr(e));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1402 } else error(TYERR);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1403 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1404 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1405
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1406 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1407 emit_data_closing(NMTBL *n)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1408 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1409 int lb;
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1410 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1411 if (mode==GDECL) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1412 data_mode(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1413 lb=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1414 printf("_%d:\n",lb);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1415 printf("\t.size\t%s,_%d-%s\n",n->nm,lb,n->nm);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1416 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1417 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1418
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1419 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1420 global_table(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1421 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1422 NMTBL *n;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1423 int init;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1424 init=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1425 for(n=ntable;n < &ntable[GSYMS];n++) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1426 if (n->sc == GVAR && n->dsp != -1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1427 /* n->dsp = -1 means initialized global */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1428 if (init==0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1429 data_mode(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1430 init=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1431 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1432 printf(".comm %s,%d\n",n->nm,size(n->ty));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1433 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1434 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1435 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1436
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1437 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1438 local_table(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1439 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1440 NMTBL *n;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1441 int init;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1442 init=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1443 /* static local variables */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1444 for(n=ntable+GSYMS;n < &ntable[GSYMS+LSYMS];n++) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1445 if (n->sc == GVAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1446 if (init==0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1447 data_mode(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1448 init=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1449 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1450 printf(".lcomm %s,%d\n",n->nm,size(n->ty));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1451 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1452 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1453 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1454
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1455 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1456 text_mode(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1457 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1458 if (output_mode!=TEXT_EMIT_MODE) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1459 printf(".text\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1460 printf("\t.align 2\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1461 output_mode = TEXT_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1462 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1463 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1464
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1465 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1466 data_mode(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1467 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1468 if (output_mode!=DATA_EMIT_MODE) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1469 printf(".data\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1470 output_mode = DATA_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1471 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1472 if (name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1473 printf("\t.type\t%s,@object\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1474 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1475
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1476 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1477 lvar(int l)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1478 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1479 if (fnptr->sc==CODE) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1480 return l+code_disp_offset;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1481 } else if (l<0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1482 return l+disp_offset;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1483 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1484 return l+arg_offset;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1485 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1486 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1487
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1488 /* floating point */
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1489
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1490
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1491 char *
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1492 fstore(int d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1493 {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1494 return use?
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1495 (d?"fstl":"fsts"):
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1496 (d?"fstpl":"fstps")
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1497 ;
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1498 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1499
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1500 char *
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1501 fstore_u(int d)
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1502 {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1503 return d?"fstpl":"fstps";
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1504 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1505
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1506 char *
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1507 fload(int d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1508 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1509 return d?"fldl":"flds";
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1510 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1511
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1512
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1513 void code_dassign_gvar(int e2,int d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1514 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1515 printf("\t%s %s\n",fstore(d),(char *)caddr(e2)) ;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1516 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1517
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1518 void code_dassign_lvar(int e2,int d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1519 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1520 printf("\t%s %d(%%ebp)\n",fstore(d),e2);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1521 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1522
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1523 void code_dassign(int e2,int d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1524 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1525 printf("\t%s (%s)\n",fstore(d),register_name(e2,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1526 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1527
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1528 static double d0 = 1.0;
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1529
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1530 int
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1531 code_d1(double d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1532 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1533 int *i = (int *)&d0; int *j = (int *)&d;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1534 return (i[1] == 0x3ff00000)?j[0]:j[1];
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1535 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1536
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1537 int
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1538 code_d2(double d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1539 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1540 int *i = (int *)&d0; int *j = (int *)&d;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1541 return (i[1] == 0x3ff00000)?j[1]:j[0];
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1542 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1543
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1544 void code_dconst(int e2)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1545 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1546 int lb;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1547 double d = dcadr(e2);
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1548
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1549 if (d==0.0) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1550 printf("\tfldz\n"); return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1551 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1552 if (d==1.0) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1553 printf("\tfld1\n"); return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1554 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1555 printf(" \t.section\t.rodata\n\t.align 8\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1556 lb=fwdlabel();
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1557 printf("_%d:\n",lb);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1558 printf("\t.long\t0x%x,0x%x\n",code_d1(d),code_d2(d));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1559 if (output_mode==TEXT_EMIT_MODE) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1560 printf(".text\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1561 } else {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1562 text_mode();
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1563 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1564 printf("\tfldl _%d\n",lb);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1565 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1566
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1567 void code_dneg()
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1568 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1569 printf("\tfchs\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1570 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1571
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1572 void code_d2i()
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1573 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1574 /* fuck you! */
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1575 printf("\tlea -%d(%%esp),%%esp\n",size_of_int*2);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1576 printf("\tfnstcw (%%esp)\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1577 printf("\tmovl (%%esp), %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1578 printf("\tmovb $12, 1(%%esp)\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1579 printf("\tfldcw (%%esp)\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1580 printf("\tmovl %s, (%%ebp)\n",register_name(creg,0));
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1581 printf("\tfistpl %d(%%esp)\n",size_of_int);
3789aef7331d minor fix
kono
parents: 84
diff changeset
1582 printf("\tfldcw (%%esp)\n");
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1583 printf("\tpopl %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1584 printf("\tpopl %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1585 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1586
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1587 void code_i2d()
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1588 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1589 printf("\tpushl %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1590 printf("\tfildl (%%esp)\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1591 printf("\tlea %d(%%esp),%%esp\n",size_of_int);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1592 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1593
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1594 void code_d2u()
3789aef7331d minor fix
kono
parents: 84
diff changeset
1595 {
3789aef7331d minor fix
kono
parents: 84
diff changeset
1596 /* fuck you! */
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1597 printf("\tlea -%d(%%esp),%%esp\n",size_of_int*3);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1598 printf("\tfnstcw (%%esp)\n");
3789aef7331d minor fix
kono
parents: 84
diff changeset
1599 printf("\tmovl (%%esp), %s\n",register_name(creg,0));
3789aef7331d minor fix
kono
parents: 84
diff changeset
1600 printf("\tmovb $12, 1(%%esp)\n");
3789aef7331d minor fix
kono
parents: 84
diff changeset
1601 printf("\tfldcw (%%esp)\n");
3789aef7331d minor fix
kono
parents: 84
diff changeset
1602 printf("\tmovl %s, (%%ebp)\n",register_name(creg,0));
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1603 printf("\tfistpll %d(%%esp)\n",size_of_int);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1604 printf("\tfldcw (%%esp)\n");
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1605 printf("\tmovl %d(%%esp),%s\n",size_of_int,register_name(creg,0));
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1606 printf("\tlea %d(%%esp),%%esp\n",size_of_int*3);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1607 }
3789aef7331d minor fix
kono
parents: 84
diff changeset
1608
3789aef7331d minor fix
kono
parents: 84
diff changeset
1609 void code_u2d()
3789aef7331d minor fix
kono
parents: 84
diff changeset
1610 {
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1611 printf("\tpushl %s\n",register_name(creg,0));
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1612 printf("\tpushl %s\n",register_name(creg,0));
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1613 printf("\tmovl $0, %d(%%esp)\n",size_of_int);
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1614 printf("\tfildll (%%esp)\n");
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1615 printf("\tlea %d(%%esp),%%esp\n",size_of_int*2);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1616 }
3789aef7331d minor fix
kono
parents: 84
diff changeset
1617
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1618 void code_drgvar(int e2,int d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1619 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1620 printf("\t%s %s\n",fload(d),(char *)caddr(e2)) ;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1621 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1622
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1623
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1624 void code_drlvar(int e2,int d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1625 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1626 printf("\t%s %d(%%ebp)\n",fload(d),e2);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1627 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1628
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1629 void code_cmp_drgvar(int e2)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1630 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1631 printf("\tfcomp %s\n",(char *)caddr(e2)) ;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1632 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1633
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1634 void code_cmp_drlvar(int e2)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1635 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1636 printf("\tfcomp %d(%%ebp)\n",e2);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1637 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1638
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1639 void dtosop(int op,int e1)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1640 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1641 switch(op) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1642 case DADD: printf("\tfaddp %%st,%%st(1)\n"); break;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1643 case DSUB: printf("\tfsubp %%st,%%st(1)\n"); break;
3789aef7331d minor fix
kono
parents: 84
diff changeset
1644 case DDIV: printf("\tfdivp %%st,%%st(1)\n"); break;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1645 case DMUL: printf("\tfmulp %%st,%%st(1)\n"); break;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1646 case DCMP:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1647 printf("\tfucompp\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1648 printf("\tfnstsw\t%%ax\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1649 break;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1650 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1651 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1652
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1653 void
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1654 code_dassop(int op,int d) {
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1655 /* we have lvalue in creg, applied floating value is in %st(0) */
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1656 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1657 dtosop(op,0);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1658 printf("\t%s (%s)\n",fstore(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1659 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1660
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1661 void
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1662 code_dpreinc(int e1,int e2,int d) {
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1663 g_expr(e2);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1664 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1665 printf("\tfld1\n");
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
1666 if (caddr(e1)>0)
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1667 printf("\tfaddp %%st,%%st(1)\n");
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1668 else
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1669 printf("\tfsubrp %%st,%%st(1)\n");
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1670 printf("\t%s (%s)\n",fstore(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1671 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1672
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1673 void
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1674 code_dpostinc(int e1,int e2,int d) {
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1675 g_expr(e2);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1676 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1677 if (use)
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1678 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1679 printf("\tfld1\n");
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
1680 if (caddr(e1)>0)
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1681 printf("\tfaddp %%st,%%st(1)\n");
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1682 else
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1683 printf("\tfsubrp %%st,%%st(1)\n");
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
1684 printf("\t%s (%s)\n",(use?fstore_u(d):fstore(d)),register_name(creg,0));
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1685 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1686
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1687 void
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1688 drexpr(int e1, int e2,int l1, int op)
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1689 {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1690 g_expr(list3(DCMP,e1,e2));
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1691 switch(op) {
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1692 case DOP+GE:
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1693 printf("\ttestb\t$5,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1694 printf("\tjne\t_%d\n",l1);
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1695 break;
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1696 case DOP+GT:
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1697 printf("\ttestb\t$69,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1698 printf("\tjne\t_%d\n",l1);
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1699 break;
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1700 case DOP+EQ:
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1701 printf("\tandb\t$69,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1702 printf("\txorb\t$64,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1703 printf("\tjne\t_%d\n",l1);
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1704 break;
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1705 case DOP+NEQ:
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1706 printf("\tandb\t$69,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1707 printf("\txorb\t$64,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1708 printf("\tje\t_%d\n",l1);
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1709 break;
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1710 }
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1711 }
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1712
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1713 int dpop_register()
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1714 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1715 return 1;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1716 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1717
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1718 int emit_dpop(int e1)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1719 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1720 return 1;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1721 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1722
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1723 void emit_dpop_free(int e1)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1724 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1725 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1726
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1727 void emit_dpush()
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1728 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1729 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1730
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1731 /* end */