Mercurial > repos > blastem
comparison runtime.S @ 545:67cf0ce57d8d
Generate handle_cycle_limit at runtime so it can use the generated save/load_context functions. Since the hand written versions of save/load are no longer used they have been removed.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 16 Feb 2014 19:54:27 -0800 |
parents | 8a26567852b7 |
children | 3090d016c9e9 |
comparison
equal
deleted
inserted
replaced
544:8a26567852b7 | 545:67cf0ce57d8d |
---|---|
1 | 1 |
2 .global handle_cycle_limit | |
3 .global do_sync | |
4 handle_cycle_limit: | |
5 cmp 84(%rsi), %eax | |
6 jb skip_sync | |
7 do_sync: | |
8 push %rcx | |
9 push %rdi | |
10 call m68k_save_context | |
11 mov %rsi, %rdi | |
12 xor %esi, %esi | |
13 test $8, %esp | |
14 jnz adjust_rsp | |
15 call sync_components | |
16 jmp done_adjust | |
17 adjust_rsp: | |
18 sub $8, %rsp | |
19 call sync_components | |
20 add $8, %rsp | |
21 done_adjust: | |
22 mov %rax, %rsi | |
23 call m68k_load_context | |
24 pop %rdi | |
25 pop %rcx | |
26 skip_sync: | |
27 ret | |
28 | 2 |
29 invalid_msg: | 3 invalid_msg: |
30 .asciz "Invalid instruction at %X\n" | 4 .asciz "Invalid instruction at %X\n" |
31 | 5 |
32 .global m68k_invalid | 6 .global m68k_invalid |
147 shr $1, %cl | 121 shr $1, %cl |
148 and $1, %cl | 122 and $1, %cl |
149 mov %cl, (%rsi) | 123 mov %cl, (%rsi) |
150 ret | 124 ret |
151 | 125 |
152 .global m68k_save_context | |
153 m68k_save_context: | |
154 mov %bl, 1(%rsi) /* N Flag */ | |
155 mov %dl, 2(%rsi) /* Z flag */ | |
156 mov %bh, 3(%rsi) /* V flag */ | |
157 mov %dh, 4(%rsi) /* C flag */ | |
158 mov %r10d, 8(%rsi) /* d0 */ | |
159 mov %r11d, 12(%rsi) /* d1 */ | |
160 mov %r12d, 16(%rsi) /* d2 */ | |
161 mov %r8d, 20(%rsi) /* d3 */ | |
162 mov %r13d, 40(%rsi) /* a0 */ | |
163 mov %r14d, 44(%rsi) /* a1 */ | |
164 mov %r9d, 48(%rsi) /* a2 */ | |
165 mov %r15d, 68(%rsi) /* a7 */ | |
166 mov %eax, 80(%rsi) /* current cycle count */ | |
167 ret | |
168 | |
169 .global m68k_load_context | |
170 m68k_load_context: | |
171 mov 1(%rsi), %bl /* N Flag */ | |
172 mov 2(%rsi), %dl /* Z flag */ | |
173 mov 3(%rsi), %bh /* V flag */ | |
174 mov 4(%rsi), %dh /* C flag */ | |
175 mov 8(%rsi), %r10d /* d0 */ | |
176 mov 12(%rsi), %r11d /* d1 */ | |
177 mov 16(%rsi), %r12d /* d2 */ | |
178 mov 20(%rsi), %r8d /* d3 */ | |
179 mov 40(%rsi), %r13d /* a0 */ | |
180 mov 44(%rsi), %r14d /* a1 */ | |
181 mov 48(%rsi), %r9d /* a2 */ | |
182 mov 68(%rsi), %r15d /* a7 */ | |
183 mov 76(%rsi), %ebp /* target cycle count */ | |
184 mov 80(%rsi), %eax /* current cycle count */ | |
185 ret | |
186 |