Mercurial > repos > blastem
comparison z80_to_x86.c @ 277:765e132edd71
Using push/pop inside translated code is not compatible with the current way the Z80 core returns to the caller
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 03 May 2013 19:27:32 -0700 |
parents | 1a7d0a964ad2 |
children | 6be6056735a9 |
comparison
equal
deleted
inserted
replaced
276:eec7072189a1 | 277:765e132edd71 |
---|---|
190 case Z80_REG_INDIRECT: | 190 case Z80_REG_INDIRECT: |
191 dst = mov_rr(dst, opts->regs[inst->ea_reg], areg, SZ_W); | 191 dst = mov_rr(dst, opts->regs[inst->ea_reg], areg, SZ_W); |
192 size = z80_size(inst); | 192 size = z80_size(inst); |
193 if (read) { | 193 if (read) { |
194 if (modify) { | 194 if (modify) { |
195 dst = push_r(dst, SCRATCH1); | 195 //dst = push_r(dst, SCRATCH1); |
196 dst = mov_rrdisp8(dst, SCRATCH1, CONTEXT, offsetof(z80_context, scratch1), SZ_W); | |
196 } | 197 } |
197 if (size == SZ_B) { | 198 if (size == SZ_B) { |
198 dst = call(dst, (uint8_t *)z80_read_byte); | 199 dst = call(dst, (uint8_t *)z80_read_byte); |
199 } else { | 200 } else { |
200 dst = call(dst, (uint8_t *)z80_read_word); | 201 dst = call(dst, (uint8_t *)z80_read_word); |
201 } | 202 } |
202 if (modify) { | 203 if (modify) { |
203 dst = pop_r(dst, SCRATCH2); | 204 //dst = pop_r(dst, SCRATCH2); |
205 dst = mov_rdisp8r(dst, CONTEXT, offsetof(z80_context, scratch1), SCRATCH2, SZ_W); | |
204 } | 206 } |
205 } | 207 } |
206 ea->base = SCRATCH1; | 208 ea->base = SCRATCH1; |
207 break; | 209 break; |
208 case Z80_IMMED: | 210 case Z80_IMMED: |
211 break; | 213 break; |
212 case Z80_IMMED_INDIRECT: | 214 case Z80_IMMED_INDIRECT: |
213 dst = mov_ir(dst, inst->immed, areg, SZ_W); | 215 dst = mov_ir(dst, inst->immed, areg, SZ_W); |
214 size = z80_size(inst); | 216 size = z80_size(inst); |
215 if (read) { | 217 if (read) { |
216 if (modify) { | 218 /*if (modify) { |
217 dst = push_r(dst, SCRATCH1); | 219 dst = push_r(dst, SCRATCH1); |
218 } | 220 }*/ |
219 if (size == SZ_B) { | 221 if (size == SZ_B) { |
220 dst = call(dst, (uint8_t *)z80_read_byte); | 222 dst = call(dst, (uint8_t *)z80_read_byte); |
221 } else { | 223 } else { |
222 dst = call(dst, (uint8_t *)z80_read_word); | 224 dst = call(dst, (uint8_t *)z80_read_word); |
223 } | 225 } |
224 if (modify) { | 226 if (modify) { |
225 dst = pop_r(dst, SCRATCH2); | 227 //dst = pop_r(dst, SCRATCH2); |
228 dst = mov_ir(dst, inst->immed, SCRATCH2, SZ_W); | |
226 } | 229 } |
227 } | 230 } |
228 ea->base = SCRATCH1; | 231 ea->base = SCRATCH1; |
229 break; | 232 break; |
230 case Z80_IX_DISPLACE: | 233 case Z80_IX_DISPLACE: |
233 dst = mov_rr(dst, reg, areg, SZ_W); | 236 dst = mov_rr(dst, reg, areg, SZ_W); |
234 dst = add_ir(dst, inst->immed, areg, SZ_W); | 237 dst = add_ir(dst, inst->immed, areg, SZ_W); |
235 size = z80_size(inst); | 238 size = z80_size(inst); |
236 if (read) { | 239 if (read) { |
237 if (modify) { | 240 if (modify) { |
238 dst = push_r(dst, SCRATCH1); | 241 //dst = push_r(dst, SCRATCH1); |
242 dst = mov_rrdisp8(dst, SCRATCH1, CONTEXT, offsetof(z80_context, scratch1), SZ_W); | |
239 } | 243 } |
240 if (size == SZ_B) { | 244 if (size == SZ_B) { |
241 dst = call(dst, (uint8_t *)z80_read_byte); | 245 dst = call(dst, (uint8_t *)z80_read_byte); |
242 } else { | 246 } else { |
243 dst = call(dst, (uint8_t *)z80_read_word); | 247 dst = call(dst, (uint8_t *)z80_read_word); |
244 } | 248 } |
245 if (modify) { | 249 if (modify) { |
246 dst = pop_r(dst, SCRATCH2); | 250 //dst = pop_r(dst, SCRATCH2); |
251 dst = mov_rdisp8r(dst, CONTEXT, offsetof(z80_context, scratch1), SCRATCH2, SZ_W); | |
247 } | 252 } |
248 } | 253 } |
249 ea->base = SCRATCH1; | 254 ea->base = SCRATCH1; |
250 break; | 255 break; |
251 case Z80_UNUSED: | 256 case Z80_UNUSED: |