Mercurial > repos > blastem
annotate zruntime.S @ 363:c708dea45f8b
Fix push AF
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 29 May 2013 00:13:48 -0700 |
parents | fa7ea48be9a9 |
children | 134ffb72d7a1 |
rev | line source |
---|---|
284
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
1 z_inccycles_io: |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
2 cmp %edi, %ebp |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
3 jnb do_limit |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
4 no_sync_io: |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
5 add $4, %ebp |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
6 ret |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
7 do_limit_io: |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
8 cmp 112(%rsi), %ebp |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
9 jb no_sync_io |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
10 jmp sync_io |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
11 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 z_inccycles: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 cmp %edi, %ebp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 jnb do_limit |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 no_sync: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 add $3, %ebp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 do_limit: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 cmp 112(%rsi), %ebp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 jb no_sync |
284
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
21 sync_io: |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 call z80_save_context_scratch |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 pop %rax /*return address in read/write func*/ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 pop 104(%rsi) /*return address in native code*/ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 sub $5, %rax /* adjust return addres to point to the call instruction that got us here */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 mov %rax, (%rsi) |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 pop %r15 /* restore callee saved regsiters */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 pop %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 pop %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 pop %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 pop %rbp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 pop %rbx |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 ret /* return to caller of z80_run */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 .global z80_handle_cycle_limit_int |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 z80_handle_cycle_limit_int: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 cmp 116(%rsi), %ebp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 jb zskip_int |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 mov 112(%rsi), %ebp /* set cycle limit to sync cycle */ |
335 | 41 movl $0xFFFFFFFF, 116(%rsi) /* make sure the interrupt doesn't fire more than once */ |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 add $7, %ebp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 sub $2, %r9w |
259
d9417261366f
Fix a remaining z80_write reg swap bug. Properly initialize the native map slots. Reset appropriate regs when z80_reset is called.
Mike Pavone <pavone@retrodev.com>
parents:
253
diff
changeset
|
44 mov %r9w, %r14w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 call z_inccycles |
259
d9417261366f
Fix a remaining z80_write reg swap bug. Properly initialize the native map slots. Reset appropriate regs when z80_reset is called.
Mike Pavone <pavone@retrodev.com>
parents:
253
diff
changeset
|
46 push %r13 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 call z80_write_byte_noinc |
259
d9417261366f
Fix a remaining z80_write reg swap bug. Properly initialize the native map slots. Reset appropriate regs when z80_reset is called.
Mike Pavone <pavone@retrodev.com>
parents:
253
diff
changeset
|
48 pop %r13 |
d9417261366f
Fix a remaining z80_write reg swap bug. Properly initialize the native map slots. Reset appropriate regs when z80_reset is called.
Mike Pavone <pavone@retrodev.com>
parents:
253
diff
changeset
|
49 mov %r9w, %r14w |
d9417261366f
Fix a remaining z80_write reg swap bug. Properly initialize the native map slots. Reset appropriate regs when z80_reset is called.
Mike Pavone <pavone@retrodev.com>
parents:
253
diff
changeset
|
50 add $1, %r14w |
d9417261366f
Fix a remaining z80_write reg swap bug. Properly initialize the native map slots. Reset appropriate regs when z80_reset is called.
Mike Pavone <pavone@retrodev.com>
parents:
253
diff
changeset
|
51 shr $8, %r13w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 call z80_write_byte_noinc |
276
eec7072189a1
Fix crash bug in Z80 interrupt support
Mike Pavone <pavone@retrodev.com>
parents:
261
diff
changeset
|
54 pop %r14 /*dispose of return address */ |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 /* TODO: Support interrupt mode 0 and 2 */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 mov $0x38, %r13w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 call z80_native_addr |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 jmp *%r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 zskip_int: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 cmp 112(%rsi), %ebp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 jb zskip_sync |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 .global z80_do_sync |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 z80_do_sync: |
281
44f0bbf57b4f
Save context in z80_do_sync
Mike Pavone <pavone@retrodev.com>
parents:
280
diff
changeset
|
64 call z80_save_context |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 pop (%rsi) /*return address in native code*/ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 pop %r15 /* restore callee saved regsiters */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 pop %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 pop %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 pop %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 pop %rbp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 pop %rbx |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 zskip_sync: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 |
285
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
75 .global z80_halt |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
76 z80_halt: |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
77 mov %edi, %r14d |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
78 sub %ebp, %r14d |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
79 and $0xFFFFFFFC, %r14d |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
80 add %r14d, %ebp |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
81 cmp %edi, %ebp |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
82 jnb z80_handle_cycle_limit_int |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
83 add $4, %ebp |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
84 jmp z80_handle_cycle_limit_int |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
85 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 .global z80_read_byte |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 z80_read_byte: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 z80_read_byte_noinc: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 cmp $0x4000, %r13w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 jb z80_read_ram |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 cmp $0x8000, %r13w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 jae z80_read_bank |
290
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
94 cmp $0x6000, %r13w |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
95 jb z80_read_ym2612 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 /* TODO: Bank reg, YM-2612, PSG/VDP */ |
280 | 97 mov $0xFF, %r13b |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 z80_read_ram: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 and $0x1FFF, %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 mov (%r11, %r13), %r13b |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
102 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
103 z80_read_bank: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
104 and $0x7FFF, %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 cmp $0, %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 je slow_bank_read |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 /* 68K memory is byte swapped */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 xor $1, %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 mov (%r12, %r13), %r13b |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 slow_bank_read: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 /* TODO: Call into C to implement this */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 ret |
290
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
114 z80_read_ym2612: |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
115 call z80_save_context |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
116 mov %r13w, %di |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
117 push %rsi |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
118 call z80_read_ym |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
119 pop %rsi |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
120 mov %al, %r13b |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
121 call z80_load_context |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
122 ret |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 .global z80_write_byte |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
125 z80_write_byte: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
126 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 z80_write_byte_noinc: |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
128 cmp $0x4000, %r14w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 jb z80_write_ram |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
130 cmp $0x8000, %r14w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 jae z80_write_bank |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
132 cmp $0x6000, %r14w |
290
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
133 jb z80_write_ym2612 |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
134 cmp $0x6100, %r14w |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
135 jb z80_write_bank_reg |
357
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
136 cmp $0x7F00, %r14w |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
137 jae z80_write_vdp |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
138 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
139 z80_write_ram: |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
140 and $0x1FFF, %r14 |
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
141 mov %r13b, (%r11, %r14) |
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
142 mov %r14d, %r13d |
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
143 shr $7, %r13d |
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
144 bt %r13d, 152(%rsi) |
252
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
145 jnc not_code |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
146 call z80_save_context |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
147 mov %r14d, %edi |
252
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
148 call z80_handle_code_write |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
149 mov %rax, %rsi |
261
f0c53a4bbfa3
Implement LDIR and fix a bug in which context was not restored after a call to z80_handle_code_write
Mike Pavone <pavone@retrodev.com>
parents:
259
diff
changeset
|
150 call z80_load_context |
252
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
151 not_code: |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
152 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
153 z80_write_bank: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 slow_bank_write: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 /* TODO: Call into C to implement this */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 ret |
290
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
157 z80_write_ym2612: |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
158 and $0x3, %r14w |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
159 call z80_save_context |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
160 mov %r14w, %di |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
161 mov %r13b, %dl |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
162 call z80_write_ym |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
163 mov %rax, %rsi |
357
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
164 jmp z80_load_context |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
165 z80_write_bank_reg: |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
166 and $1, %r13w |
280 | 167 shr %r15w |
168 shl $8, %r13w | |
169 xor %r12, %r12 | |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
170 or %r13w, %r15w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
171 and $0x1FF, %r15w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
172 cmp $0x80, %r15w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
173 jb update_bank_ptr |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
174 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
175 update_bank_ptr: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 mov %r15w, %r12w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
177 shl $15, %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
178 add 80(%rsi), %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
179 ret |
357
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
180 z80_write_vdp: |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
181 and $0xFF, %r14w |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
182 call z80_save_context |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
183 mov %r14w, %di |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
184 mov %r13b, %dl |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
185 call z80_vdp_port_write |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
186 mov %rax, %rsi |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
187 jmp z80_load_context |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
188 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
189 .global z80_read_word |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
190 z80_read_word: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
191 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
192 push %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
193 call z80_read_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
194 mov %r13b, %r14b |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
195 pop %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
196 inc %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
197 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
198 call z80_read_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
199 shl $8, %r13w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
200 mov %r14b, %r13b |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
201 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
202 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
203 .global z80_write_word_highfirst |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
204 z80_write_word_highfirst: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
205 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
206 push %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
207 push %r13 |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
208 add $1, %r14w |
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
209 shr $8, %r13w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
210 call z80_write_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
211 pop %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
212 pop %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
213 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
214 call z80_write_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
215 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
216 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
217 .global z80_write_word_lowfirst |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
218 z80_write_word_lowfirst: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
219 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
220 push %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
221 push %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
222 call z80_write_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
223 pop %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
224 pop %r14 |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
225 add $1, %r14w |
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
226 shr $8, %r13w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
227 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
228 call z80_write_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
229 ret |
284
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
230 |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
231 .global z80_io_read |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
232 z80_io_read: |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
233 call z_inccycles_io |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
234 /* genesis Z80 has no IO port hardware and always returns FF */ |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
235 mov $0xFF, %r13 |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
236 ret |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
237 |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
238 .global z80_io_write |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
239 z80_io_write: |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
240 call z_inccycles_io |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
241 /* genesis Z80 has no IO port hardware and writes have no effect */ |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
242 ret |
252
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
243 |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
244 .global z80_retrans_stub |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
245 z80_retrans_stub: |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
246 call z80_save_context |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
247 mov %r13d, %edi |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
248 push %rsi |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
249 call z80_retranslate_inst |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
250 pop %rsi |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
251 mov %rax, %r13 |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
252 call z80_load_context |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
253 jmp *%r13 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
254 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
255 .global z80_native_addr |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
256 z80_native_addr: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
257 call z80_save_context |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
258 push %rsi |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
259 mov %rsi, %rdi |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
260 movzx %r13w, %esi |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
261 call z80_get_native_address_trans |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
262 mov %rax, %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
263 pop %rsi |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
264 call z80_load_context |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
265 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
266 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
267 z80_save_context_scratch: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
268 mov %r13w, 98(%rsi) /* scratch1 */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
269 mov %r14w, 100(%rsi) /* scratch2 */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
270 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
271 .global z80_save_context |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
272 z80_save_context: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
273 mov %r9w, 8(%rsi) /* SP */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
274 mov %r15w, 16(%rsi) /* bank register */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
275 mov %bx, 18(%rsi) /* BC */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
276 mov %cx, 20(%rsi) /* DE */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
277 mov %ax, 22(%rsi) /* HL */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
278 mov %dx, 24(%rsi) /* IX */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
279 mov %r8w, 26(%rsi) /* IY */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
280 mov %r10b, 30(%rsi) /* A */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
281 mov %edi, 48(%rsi) /* target_cycle */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
282 mov %ebp, 52(%rsi) /* current_cycle */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
283 mov %r12, 72(%rsi) /* cartridge bank pointer */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
284 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
285 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
286 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
287 z80_load_context_scratch: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
288 mov 98(%rsi), %r13w /* scratch1 */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
289 mov 100(%rsi), %r14w /* scratch2 */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
290 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
291 .global z80_load_context |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
292 z80_load_context: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
293 mov 8(%rsi), %r9w /* SP */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
294 mov 16(%rsi), %r15w /* bank register */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
295 mov 18(%rsi), %bx /* BC */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
296 mov 20(%rsi), %cx /* DE */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
297 mov 22(%rsi), %ax /* HL */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
298 mov 24(%rsi), %dx /* IX */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
299 mov 26(%rsi), %r8w /* IY */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
300 mov 30(%rsi), %r10b /* A */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
301 mov 48(%rsi), %edi /* target_cycle */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
302 mov 52(%rsi), %ebp /* current_cycle */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
303 mov 64(%rsi), %r11 /* z80 RAM */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
304 mov 72(%rsi), %r12 /* cartridge bank pointer */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
305 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
306 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
307 .global z80_run |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
308 z80_run: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
309 push %rbx |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
310 push %rbp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
311 push %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
312 push %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
313 push %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
314 push %r15 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
315 mov %rdi, %rsi |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
316 call z80_load_context_scratch |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
317 cmpq $0, 104(%rsi) |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
318 je no_extra |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
319 push 104(%rsi) |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
320 movq $0, 104(%rsi) |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
321 no_extra: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
322 jmp *(%rsi) |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
323 |