annotate mc-code-ia32.c @ 114:e6cb1e293b35

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