mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-19 20:30:45 +00:00
Support branching and looping on the n
flag.
This commit is contained in:
parent
b9fb26320c
commit
fa1b0cfae1
@ -9,10 +9,11 @@ History of SixtyPical
|
||||
* Added `nop` opcode, which compiles to `NOP` (mainly for timing.)
|
||||
* Accessing zero-page with `ld` and `st` generates zero-page opcodes.
|
||||
* A `byte` or `word` table can be initialized with a list of constants.
|
||||
* Branching and repeating on the `n` flag is now supported.
|
||||
* Specifying multiple SixtyPical source files will produce a single
|
||||
compiled result from their combination.
|
||||
* Rudimentary support for Atari 2600 prelude in a 4K cartridge image,
|
||||
and start of an example program in `eg/atari2600` directory.
|
||||
and an example program in `eg/atari2600` directory.
|
||||
|
||||
0.14
|
||||
----
|
||||
|
@ -81,7 +81,7 @@ define display_frame routine
|
||||
repeat {
|
||||
st a, WSYNC
|
||||
dec x
|
||||
} until z // FIXME orig loop used "bpl _wsync_loop"
|
||||
} until n
|
||||
st a, WSYNC
|
||||
|
||||
//;
|
||||
|
@ -15,7 +15,7 @@ from sixtypical.gen6502 import (
|
||||
CLC, SEC, ADC, SBC, ROL, ROR,
|
||||
INC, INX, INY, DEC, DEX, DEY,
|
||||
CMP, CPX, CPY, AND, ORA, EOR,
|
||||
BCC, BCS, BNE, BEQ,
|
||||
BCC, BCS, BNE, BEQ, BPL, BMI,
|
||||
JMP, JSR, RTS,
|
||||
SEI, CLI,
|
||||
NOP,
|
||||
@ -518,10 +518,12 @@ class Compiler(object):
|
||||
False: {
|
||||
'c': BCC,
|
||||
'z': BNE,
|
||||
'n': BPL,
|
||||
},
|
||||
True: {
|
||||
'c': BCS,
|
||||
'z': BEQ,
|
||||
'n': BMI,
|
||||
},
|
||||
}[instr.inverted].get(instr.src.name)
|
||||
if cls is None:
|
||||
@ -548,10 +550,12 @@ class Compiler(object):
|
||||
False: {
|
||||
'c': BCC,
|
||||
'z': BNE,
|
||||
'n': BPL,
|
||||
},
|
||||
True: {
|
||||
'c': BCS,
|
||||
'z': BEQ,
|
||||
'n': BMI,
|
||||
},
|
||||
}[instr.inverted].get(instr.src.name)
|
||||
if cls is None:
|
||||
|
@ -160,6 +160,18 @@ class BNE(Instruction):
|
||||
}
|
||||
|
||||
|
||||
class BPL(Instruction):
|
||||
opcodes = {
|
||||
Relative: 0x10,
|
||||
}
|
||||
|
||||
|
||||
class BMI(Instruction):
|
||||
opcodes = {
|
||||
Relative: 0x30,
|
||||
}
|
||||
|
||||
|
||||
class CLC(Instruction):
|
||||
opcodes = {
|
||||
Implied: 0x18
|
||||
|
@ -417,13 +417,13 @@ Compiling `repeat ... until not n`.
|
||||
| routine main
|
||||
| trashes a, y, z, n, c
|
||||
| {
|
||||
| ld y, 65
|
||||
| ld y, 199
|
||||
| repeat {
|
||||
| ld a, y
|
||||
| inc y
|
||||
| } until not n
|
||||
| }
|
||||
= $080D LDY #$41
|
||||
= $080D LDY #$C7
|
||||
= $080F TYA
|
||||
= $0810 INY
|
||||
= $0811 BMI $080F
|
||||
|
Loading…
x
Reference in New Issue
Block a user