mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-10 08:30:38 +00:00
Implement 'with interrupts off'.
This commit is contained in:
parent
fd07f4bae9
commit
645079f03a
@ -232,5 +232,7 @@ def analyze_instr(instr, context, routines):
|
||||
context.set_written(dest)
|
||||
context.set_touched(REG_A, FLAG_Z, FLAG_N)
|
||||
context.set_unmeaningful(REG_A, FLAG_Z, FLAG_N)
|
||||
elif opcode == 'with-sei':
|
||||
analyze_block(instr.block, context, routines)
|
||||
else:
|
||||
raise NotImplementedError(opcode)
|
||||
|
@ -16,6 +16,7 @@ from sixtypical.gen6502 import (
|
||||
CMP, CPX, CPY, AND, ORA, EOR,
|
||||
BCC, BCS, BNE, BEQ,
|
||||
JMP, JSR, RTS,
|
||||
SEI, CLI,
|
||||
)
|
||||
|
||||
|
||||
@ -236,5 +237,9 @@ class Compiler(object):
|
||||
if cls is None:
|
||||
raise UnsupportedOpcodeError(instr)
|
||||
self.emitter.emit(cls(Relative(top_label)))
|
||||
elif opcode == 'with-sei':
|
||||
self.emitter.emit(SEI())
|
||||
self.compile_block(instr.block)
|
||||
self.emitter.emit(CLI())
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
@ -160,5 +160,7 @@ def eval_instr(instr, context, routines):
|
||||
context.set(REG_A, 0)
|
||||
context.set(FLAG_Z, 0)
|
||||
context.set(FLAG_N, 0)
|
||||
elif opcode == 'with-sei':
|
||||
eval_block(instr.block)
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
@ -135,6 +135,12 @@ class CLC(Opcode):
|
||||
}
|
||||
|
||||
|
||||
class CLI(Opcode):
|
||||
opcodes = {
|
||||
Implied: 0x58,
|
||||
}
|
||||
|
||||
|
||||
class CMP(Opcode):
|
||||
opcodes = {
|
||||
Immediate: 0xc9,
|
||||
@ -287,6 +293,12 @@ class SEC(Opcode):
|
||||
}
|
||||
|
||||
|
||||
class SEI(Opcode):
|
||||
opcodes = {
|
||||
Implied: 0x78,
|
||||
}
|
||||
|
||||
|
||||
class STA(Opcode):
|
||||
opcodes = {
|
||||
Absolute: 0x8d,
|
||||
|
@ -257,5 +257,10 @@ class Parser(object):
|
||||
self.scanner.expect(',')
|
||||
dest = self.locexpr()
|
||||
return Instr(opcode=opcode, dest=dest, src=src)
|
||||
elif self.scanner.consume("with"):
|
||||
self.scanner.expect("interrupts")
|
||||
self.scanner.expect("off")
|
||||
block = self.block()
|
||||
return Instr(opcode='with-sei', dest=None, src=None, block=block)
|
||||
else:
|
||||
raise ValueError('bad opcode "%s"' % self.scanner.token)
|
||||
|
@ -205,6 +205,8 @@ Declaring a vector.
|
||||
| ld a, 0
|
||||
| }
|
||||
| routine main {
|
||||
| with interrupts off {
|
||||
| copy foo, cinv
|
||||
| }
|
||||
| }
|
||||
= ok
|
||||
|
Loading…
x
Reference in New Issue
Block a user