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