git @ Cat's Eye Technologies SixtyPical / 70247e0
Generate zero-page code for and, or, and xor, when possible. Chris Pressey 3 years ago
5 changed file(s) with 19 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
00 History of SixtyPical
11 =====================
2
3 0.16
4 ----
5
6 * `or a, z`, `and a, z`, and `eor a, z` compile to zero-page operations
7 if the address of z < 256.
28
39 0.15
410 ----
8888 * Automatic tail-call optimization (could be tricky, w/constraints?)
8989 * Possibly `ld x, [ptr] + y`, possibly `st x, [ptr] + y`.
9090 * Maybe even `copy [ptra] + y, [ptrb] + y`, which can be compiled to indirect LDA then indirect STA!
91 * Optimize `or|and|eor a, z` to zero-page operations if address of z < 256.
9291
9392 [VICE]: http://vice-emu.sourceforge.net/
331331 if isinstance(src, ConstantRef):
332332 self.emitter.emit(cls(Immediate(Byte(src.value))))
333333 else:
334 self.emitter.emit(cls(Absolute(self.get_label(src.name))))
334 self.emitter.emit(cls(self.absolute_or_zero_page(self.get_label(src.name))))
335335 else:
336336 raise UnsupportedOpcodeError(instr)
337337 elif opcode in ('shl', 'shr'):
132132 Absolute: 0x2d,
133133 AbsoluteX: 0x3d,
134134 AbsoluteY: 0x39,
135 ZeroPage: 0x25,
135136 }
136137
137138
230231 Absolute: 0x4d,
231232 AbsoluteX: 0x5d,
232233 AbsoluteY: 0x59,
234 ZeroPage: 0x45,
233235 }
234236
235237
298300 Absolute: 0x0d,
299301 AbsoluteX: 0x1d,
300302 AbsoluteY: 0x19,
303 ZeroPage: 0x05,
301304 }
302305
303306
111111 = $080F STA $0400
112112 = $0812 RTS
113113
114 Accesses to memory locations in zero-page with `ld` and `st` use zero-page addressing.
114 Accesses to memory locations in zero-page with `ld` and `st`
115 and `and`, `or`, and `xor` use zero-page addressing.
115116
116117 | byte zp @ $00
117118 | byte screen @ 100
125126 | st a, screen
126127 | ld a, zp
127128 | st a, zp
129 | and a, zp
130 | or a, zp
131 | xor a, zp
128132 | }
129133 = $080D LDA $64
130134 = $080F STA $64
131135 = $0811 LDA $00
132136 = $0813 STA $00
133 = $0815 RTS
137 = $0815 AND $00
138 = $0817 ORA $00
139 = $0819 EOR $00
140 = $081B RTS
134141
135142 Memory location with initial value.
136143