Mercurial > repos > blastem
annotate zruntime.S @ 426:add9e2f5c0e3
Make VDP render in native pixel format of the renderer for a modest performance gain and to make it easier to use OpenGL for rendering
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 30 Jun 2013 11:45:58 -0700 |
parents | 30c250a41629 |
children | b7c3b2d22858 |
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 */ |
375
134ffb72d7a1
Clear IFF1 and IFF2 when an interrupt is taken on the Z80
Mike Pavone <pavone@retrodev.com>
parents:
357
diff
changeset
|
41 /* not sure this is really necessary now that IFF1 and IFF2 are geting cleared */ |
335 | 42 movl $0xFFFFFFFF, 116(%rsi) /* make sure the interrupt doesn't fire more than once */ |
375
134ffb72d7a1
Clear IFF1 and IFF2 when an interrupt is taken on the Z80
Mike Pavone <pavone@retrodev.com>
parents:
357
diff
changeset
|
43 /* disable interrupts */ |
134ffb72d7a1
Clear IFF1 and IFF2 when an interrupt is taken on the Z80
Mike Pavone <pavone@retrodev.com>
parents:
357
diff
changeset
|
44 movb $0, 96(%rsi) |
134ffb72d7a1
Clear IFF1 and IFF2 when an interrupt is taken on the Z80
Mike Pavone <pavone@retrodev.com>
parents:
357
diff
changeset
|
45 movb $0, 97(%rsi) |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 add $7, %ebp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 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
|
48 mov %r9w, %r14w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 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
|
50 push %r13 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 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
|
52 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
|
53 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
|
54 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
|
55 shr $8, %r13w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 call z80_write_byte_noinc |
276
eec7072189a1
Fix crash bug in Z80 interrupt support
Mike Pavone <pavone@retrodev.com>
parents:
261
diff
changeset
|
58 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
|
59 /* 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
|
60 mov $0x38, %r13w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 call z80_native_addr |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 jmp *%r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 zskip_int: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 cmp 112(%rsi), %ebp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 jb zskip_sync |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 .global z80_do_sync |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 z80_do_sync: |
281
44f0bbf57b4f
Save context in z80_do_sync
Mike Pavone <pavone@retrodev.com>
parents:
280
diff
changeset
|
68 call z80_save_context |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 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
|
70 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
|
71 pop %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 pop %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 pop %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 pop %rbp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 pop %rbx |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 zskip_sync: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 |
285
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
79 .global z80_halt |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
80 z80_halt: |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
81 mov %edi, %r14d |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
82 sub %ebp, %r14d |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
83 and $0xFFFFFFFC, %r14d |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
84 add %r14d, %ebp |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
85 cmp %edi, %ebp |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
86 jnb z80_handle_cycle_limit_int |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
87 add $4, %ebp |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
88 jmp z80_handle_cycle_limit_int |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
89 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 .global z80_read_byte |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 z80_read_byte: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 z80_read_byte_noinc: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 cmp $0x4000, %r13w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 jb z80_read_ram |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 cmp $0x8000, %r13w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 jae z80_read_bank |
290
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
98 cmp $0x6000, %r13w |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
99 jb z80_read_ym2612 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 /* TODO: Bank reg, YM-2612, PSG/VDP */ |
280 | 101 mov $0xFF, %r13b |
249
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_ram: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
104 and $0x1FFF, %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 mov (%r11, %r13), %r13b |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 z80_read_bank: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 and $0x7FFF, %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 cmp $0, %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 je slow_bank_read |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 /* 68K memory is byte swapped */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 xor $1, %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 mov (%r12, %r13), %r13b |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 slow_bank_read: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 /* 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
|
117 ret |
290
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
118 z80_read_ym2612: |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
119 call z80_save_context |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
120 mov %r13w, %di |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
121 push %rsi |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
122 call z80_read_ym |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
123 pop %rsi |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
124 mov %al, %r13b |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
125 call z80_load_context |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
126 ret |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
128 .global z80_write_byte |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 z80_write_byte: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
130 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 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
|
132 cmp $0x4000, %r14w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 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
|
134 cmp $0x8000, %r14w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
135 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
|
136 cmp $0x6000, %r14w |
290
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
137 jb z80_write_ym2612 |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
138 cmp $0x6100, %r14w |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
139 jb z80_write_bank_reg |
357
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
140 cmp $0x7F00, %r14w |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
141 jae z80_write_vdp |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
142 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
143 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
|
144 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
|
145 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
|
146 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
|
147 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
|
148 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
|
149 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
|
150 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
|
151 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
|
152 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
|
153 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
|
154 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
|
155 not_code: |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 z80_write_bank: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 slow_bank_write: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 /* 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
|
160 ret |
290
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
161 z80_write_ym2612: |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
162 and $0x3, %r14w |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
163 call z80_save_context |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
164 mov %r14w, %di |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
165 mov %r13b, %dl |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
166 call z80_write_ym |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
167 mov %rax, %rsi |
357
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
168 jmp z80_load_context |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 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
|
170 and $1, %r13w |
280 | 171 shr %r15w |
172 shl $8, %r13w | |
173 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
|
174 or %r13w, %r15w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
175 and $0x1FF, %r15w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 cmp $0x80, %r15w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
177 jb update_bank_ptr |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
178 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
179 update_bank_ptr: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
180 mov %r15w, %r12w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
181 shl $15, %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
182 add 80(%rsi), %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
183 ret |
357
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
184 z80_write_vdp: |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
185 and $0xFF, %r14w |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
186 call z80_save_context |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
187 mov %r14w, %di |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
188 mov %r13b, %dl |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
189 call z80_vdp_port_write |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
190 mov %rax, %rsi |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
191 jmp z80_load_context |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
192 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
193 .global z80_read_word |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
194 z80_read_word: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
195 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
196 push %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
197 call z80_read_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
198 mov %r13b, %r14b |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
199 pop %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
200 inc %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
201 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
202 call z80_read_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
203 shl $8, %r13w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
204 mov %r14b, %r13b |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
205 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
206 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
207 .global z80_write_word_highfirst |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
208 z80_write_word_highfirst: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
209 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
210 push %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
211 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
|
212 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
|
213 shr $8, %r13w |
249
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 pop %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
216 pop %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
217 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
218 call z80_write_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
219 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
220 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
221 .global z80_write_word_lowfirst |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
222 z80_write_word_lowfirst: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
223 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
224 push %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
225 push %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
226 call z80_write_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
227 pop %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
228 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
|
229 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
|
230 shr $8, %r13w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
231 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
232 call z80_write_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
233 ret |
284
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
234 |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
235 .global z80_io_read |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
236 z80_io_read: |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
237 call z_inccycles_io |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
238 /* 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
|
239 mov $0xFF, %r13 |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
240 ret |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
241 |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
242 .global z80_io_write |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
243 z80_io_write: |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
244 call z_inccycles_io |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
245 /* 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
|
246 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
|
247 |
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 .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
|
249 z80_retrans_stub: |
390
561fe3ea3fc8
Use a call instruction to figure out the original native address when retranslating so that it does not get lost when the byte transforms from a instruction word to extension word
Mike Pavone <pavone@retrodev.com>
parents:
375
diff
changeset
|
250 pop %r14 |
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
|
251 call z80_save_context |
390
561fe3ea3fc8
Use a call instruction to figure out the original native address when retranslating so that it does not get lost when the byte transforms from a instruction word to extension word
Mike Pavone <pavone@retrodev.com>
parents:
375
diff
changeset
|
252 /* adjust for mov and call instructions */ |
393
30c250a41629
Fix address adjustement in z80_retrans_stub
Mike Pavone <pavone@retrodev.com>
parents:
390
diff
changeset
|
253 sub $11, %r14 |
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
|
254 mov %r13d, %edi |
390
561fe3ea3fc8
Use a call instruction to figure out the original native address when retranslating so that it does not get lost when the byte transforms from a instruction word to extension word
Mike Pavone <pavone@retrodev.com>
parents:
375
diff
changeset
|
255 mov %r14, %rdx |
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
|
256 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
|
257 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
|
258 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
|
259 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
|
260 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
|
261 jmp *%r13 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
262 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
263 .global z80_native_addr |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
264 z80_native_addr: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
265 call z80_save_context |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
266 push %rsi |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
267 mov %rsi, %rdi |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
268 movzx %r13w, %esi |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
269 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
|
270 mov %rax, %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
271 pop %rsi |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
272 call z80_load_context |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
273 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
274 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
275 z80_save_context_scratch: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
276 mov %r13w, 98(%rsi) /* scratch1 */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
277 mov %r14w, 100(%rsi) /* scratch2 */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
278 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
279 .global z80_save_context |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
280 z80_save_context: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
281 mov %r9w, 8(%rsi) /* SP */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
282 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
|
283 mov %bx, 18(%rsi) /* BC */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
284 mov %cx, 20(%rsi) /* DE */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
285 mov %ax, 22(%rsi) /* HL */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
286 mov %dx, 24(%rsi) /* IX */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
287 mov %r8w, 26(%rsi) /* IY */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
288 mov %r10b, 30(%rsi) /* A */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
289 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
|
290 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
|
291 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
|
292 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
293 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
294 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
295 z80_load_context_scratch: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
296 mov 98(%rsi), %r13w /* scratch1 */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
297 mov 100(%rsi), %r14w /* scratch2 */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
298 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
299 .global z80_load_context |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
300 z80_load_context: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
301 mov 8(%rsi), %r9w /* SP */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
302 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
|
303 mov 18(%rsi), %bx /* BC */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
304 mov 20(%rsi), %cx /* DE */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
305 mov 22(%rsi), %ax /* HL */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
306 mov 24(%rsi), %dx /* IX */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
307 mov 26(%rsi), %r8w /* IY */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
308 mov 30(%rsi), %r10b /* A */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
309 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
|
310 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
|
311 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
|
312 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
|
313 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
314 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
315 .global z80_run |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
316 z80_run: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
317 push %rbx |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
318 push %rbp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
319 push %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
320 push %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
321 push %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
322 push %r15 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
323 mov %rdi, %rsi |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
324 call z80_load_context_scratch |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
325 cmpq $0, 104(%rsi) |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
326 je no_extra |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
327 push 104(%rsi) |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
328 movq $0, 104(%rsi) |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
329 no_extra: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
330 jmp *(%rsi) |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
331 |