git @ Cat's Eye Technologies SixtyPical / 645079f
Implement 'with interrupts off'. Chris Pressey 6 years ago
6 changed file(s) with 31 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
231231 context.set_written(dest)
232232 context.set_touched(REG_A, FLAG_Z, FLAG_N)
233233 context.set_unmeaningful(REG_A, FLAG_Z, FLAG_N)
234 elif opcode == 'with-sei':
235 analyze_block(instr.block, context, routines)
234236 else:
235237 raise NotImplementedError(opcode)
1515 CMP, CPX, CPY, AND, ORA, EOR,
1616 BCC, BCS, BNE, BEQ,
1717 JMP, JSR, RTS,
18 SEI, CLI,
1819 )
1920
2021
235236 if cls is None:
236237 raise UnsupportedOpcodeError(instr)
237238 self.emitter.emit(cls(Relative(top_label)))
239 elif opcode == 'with-sei':
240 self.emitter.emit(SEI())
241 self.compile_block(instr.block)
242 self.emitter.emit(CLI())
238243 else:
239244 raise NotImplementedError
159159 context.set(REG_A, 0)
160160 context.set(FLAG_Z, 0)
161161 context.set(FLAG_N, 0)
162 elif opcode == 'with-sei':
163 eval_block(instr.block)
162164 else:
163165 raise NotImplementedError
134134 }
135135
136136
137 class CLI(Opcode):
138 opcodes = {
139 Implied: 0x58,
140 }
141
142
137143 class CMP(Opcode):
138144 opcodes = {
139145 Immediate: 0xc9,
286292 }
287293
288294
295 class SEI(Opcode):
296 opcodes = {
297 Implied: 0x78,
298 }
299
300
289301 class STA(Opcode):
290302 opcodes = {
291303 Absolute: 0x8d,
256256 self.scanner.expect(',')
257257 dest = self.locexpr()
258258 return Instr(opcode=opcode, dest=dest, src=src)
259 elif self.scanner.consume("with"):
260 self.scanner.expect("interrupts")
261 self.scanner.expect("off")
262 block = self.block()
263 return Instr(opcode='with-sei', dest=None, src=None, block=block)
259264 else:
260265 raise ValueError('bad opcode "%s"' % self.scanner.token)
204204 | ld a, 0
205205 | }
206206 | routine main {
207 | copy foo, cinv
208 | }
209 = ok
207 | with interrupts off {
208 | copy foo, cinv
209 | }
210 | }
211 = ok