git @ Cat's Eye Technologies SixtyPical / fa1b0cf
Support branching and looping on the `n` flag. Chris Pressey 3 years ago
5 changed file(s) with 22 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
88 * Added `nop` opcode, which compiles to `NOP` (mainly for timing.)
99 * Accessing zero-page with `ld` and `st` generates zero-page opcodes.
1010 * A `byte` or `word` table can be initialized with a list of constants.
11 * Branching and repeating on the `n` flag is now supported.
1112 * Specifying multiple SixtyPical source files will produce a single
1213 compiled result from their combination.
1314 * Rudimentary support for Atari 2600 prelude in a 4K cartridge image,
14 and start of an example program in `eg/atari2600` directory.
15 and an example program in `eg/atari2600` directory.
1516
1617 0.14
1718 ----
8080 repeat {
8181 st a, WSYNC
8282 dec x
83 } until z // FIXME orig loop used "bpl _wsync_loop"
83 } until n
8484 st a, WSYNC
8585
8686 //;
1414 CLC, SEC, ADC, SBC, ROL, ROR,
1515 INC, INX, INY, DEC, DEX, DEY,
1616 CMP, CPX, CPY, AND, ORA, EOR,
17 BCC, BCS, BNE, BEQ,
17 BCC, BCS, BNE, BEQ, BPL, BMI,
1818 JMP, JSR, RTS,
1919 SEI, CLI,
2020 NOP,
517517 False: {
518518 'c': BCC,
519519 'z': BNE,
520 'n': BPL,
520521 },
521522 True: {
522523 'c': BCS,
523524 'z': BEQ,
525 'n': BMI,
524526 },
525527 }[instr.inverted].get(instr.src.name)
526528 if cls is None:
547549 False: {
548550 'c': BCC,
549551 'z': BNE,
552 'n': BPL,
550553 },
551554 True: {
552555 'c': BCS,
553556 'z': BEQ,
557 'n': BMI,
554558 },
555559 }[instr.inverted].get(instr.src.name)
556560 if cls is None:
156156 class BNE(Instruction):
157157 opcodes = {
158158 Relative: 0xd0,
159 }
160
161
162 class BPL(Instruction):
163 opcodes = {
164 Relative: 0x10,
165 }
166
167
168 class BMI(Instruction):
169 opcodes = {
170 Relative: 0x30,
159171 }
160172
161173
416416 | routine main
417417 | trashes a, y, z, n, c
418418 | {
419 | ld y, 65
419 | ld y, 199
420420 | repeat {
421421 | ld a, y
422422 | inc y
423423 | } until not n
424424 | }
425 = $080D LDY #$41
425 = $080D LDY #$C7
426426 = $080F TYA
427427 = $0810 INY
428428 = $0811 BMI $080F