Mercurial > repos > blastem
comparison zruntime.S @ 451:b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 26 Jul 2013 19:55:04 -0700 |
parents | 30c250a41629 |
children | cc6030bd04c6 |
comparison
equal
deleted
inserted
replaced
448:e85a107e6ec0 | 451:b7c3b2d22858 |
---|---|
17 ret | 17 ret |
18 do_limit: | 18 do_limit: |
19 cmp 112(%rsi), %ebp | 19 cmp 112(%rsi), %ebp |
20 jb no_sync | 20 jb no_sync |
21 sync_io: | 21 sync_io: |
22 movw $0, 164(%rsi) | |
22 call z80_save_context_scratch | 23 call z80_save_context_scratch |
23 pop %rax /*return address in read/write func*/ | 24 pop %rax /*return address in read/write func*/ |
24 pop 104(%rsi) /*return address in native code*/ | 25 pop 104(%rsi) /*return address in native code*/ |
25 sub $5, %rax /* adjust return addres to point to the call instruction that got us here */ | 26 sub $5, %rax /* adjust return addres to point to the call instruction that got us here */ |
26 mov %rax, (%rsi) | 27 mov %rax, (%rsi) |
27 | 28 |
28 pop %r15 /* restore callee saved regsiters */ | 29 pop %r15 /* restore callee saved regsiters */ |
29 pop %r14 | 30 pop %r14 |
30 pop %r13 | 31 pop %r13 |
31 pop %r12 | 32 pop %r12 |
32 pop %rbp | 33 pop %rbp |
33 pop %rbx | 34 pop %rbx |
34 ret /* return to caller of z80_run */ | 35 ret /* return to caller of z80_run */ |
35 | 36 |
36 .global z80_handle_cycle_limit_int | 37 .global z80_handle_cycle_limit_int |
37 z80_handle_cycle_limit_int: | 38 z80_handle_cycle_limit_int: |
38 cmp 116(%rsi), %ebp | 39 cmp 116(%rsi), %ebp |
39 jb zskip_int | 40 jb zskip_int |
40 mov 112(%rsi), %ebp /* set cycle limit to sync cycle */ | 41 mov 112(%rsi), %ebp /* set cycle limit to sync cycle */ |
61 call z80_native_addr | 62 call z80_native_addr |
62 jmp *%r13 | 63 jmp *%r13 |
63 zskip_int: | 64 zskip_int: |
64 cmp 112(%rsi), %ebp | 65 cmp 112(%rsi), %ebp |
65 jb zskip_sync | 66 jb zskip_sync |
67 mov %r13w, 164(%rsi) | |
66 .global z80_do_sync | 68 .global z80_do_sync |
67 z80_do_sync: | 69 z80_do_sync: |
68 call z80_save_context | 70 call z80_save_context |
69 pop (%rsi) /*return address in native code*/ | 71 pop (%rsi) /*return address in native code*/ |
70 pop %r15 /* restore callee saved regsiters */ | 72 pop %r15 /* restore callee saved regsiters */ |
242 .global z80_io_write | 244 .global z80_io_write |
243 z80_io_write: | 245 z80_io_write: |
244 call z_inccycles_io | 246 call z_inccycles_io |
245 /* genesis Z80 has no IO port hardware and writes have no effect */ | 247 /* genesis Z80 has no IO port hardware and writes have no effect */ |
246 ret | 248 ret |
247 | 249 |
248 .global z80_retrans_stub | 250 .global z80_retrans_stub |
249 z80_retrans_stub: | 251 z80_retrans_stub: |
250 pop %r14 | 252 pop %r14 |
251 call z80_save_context | 253 call z80_save_context |
252 /* adjust for mov and call instructions */ | 254 /* adjust for mov and call instructions */ |
262 | 264 |
263 .global z80_native_addr | 265 .global z80_native_addr |
264 z80_native_addr: | 266 z80_native_addr: |
265 call z80_save_context | 267 call z80_save_context |
266 push %rsi | 268 push %rsi |
267 mov %rsi, %rdi | 269 mov %rsi, %rdi |
268 movzx %r13w, %esi | 270 movzx %r13w, %esi |
269 call z80_get_native_address_trans | 271 call z80_get_native_address_trans |
270 mov %rax, %r13 | 272 mov %rax, %r13 |
271 pop %rsi | 273 pop %rsi |
272 call z80_load_context | 274 call z80_load_context |
273 ret | 275 ret |
274 | 276 |
275 z80_save_context_scratch: | 277 z80_save_context_scratch: |
276 mov %r13w, 98(%rsi) /* scratch1 */ | 278 mov %r13w, 98(%rsi) /* scratch1 */ |
277 mov %r14w, 100(%rsi) /* scratch2 */ | 279 mov %r14w, 100(%rsi) /* scratch2 */ |
278 | 280 |
279 .global z80_save_context | 281 .global z80_save_context |
280 z80_save_context: | 282 z80_save_context: |
281 mov %r9w, 8(%rsi) /* SP */ | 283 mov %r9w, 8(%rsi) /* SP */ |
282 mov %r15w, 16(%rsi) /* bank register */ | 284 mov %r15w, 16(%rsi) /* bank register */ |
283 mov %bx, 18(%rsi) /* BC */ | 285 mov %bx, 18(%rsi) /* BC */ |
293 | 295 |
294 | 296 |
295 z80_load_context_scratch: | 297 z80_load_context_scratch: |
296 mov 98(%rsi), %r13w /* scratch1 */ | 298 mov 98(%rsi), %r13w /* scratch1 */ |
297 mov 100(%rsi), %r14w /* scratch2 */ | 299 mov 100(%rsi), %r14w /* scratch2 */ |
298 | 300 |
299 .global z80_load_context | 301 .global z80_load_context |
300 z80_load_context: | 302 z80_load_context: |
301 mov 8(%rsi), %r9w /* SP */ | 303 mov 8(%rsi), %r9w /* SP */ |
302 mov 16(%rsi), %r15w /* bank register */ | 304 mov 16(%rsi), %r15w /* bank register */ |
303 mov 18(%rsi), %bx /* BC */ | 305 mov 18(%rsi), %bx /* BC */ |
326 je no_extra | 328 je no_extra |
327 push 104(%rsi) | 329 push 104(%rsi) |
328 movq $0, 104(%rsi) | 330 movq $0, 104(%rsi) |
329 no_extra: | 331 no_extra: |
330 jmp *(%rsi) | 332 jmp *(%rsi) |
331 | 333 |