mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-06-02 18:41:35 +00:00
Generate code for if
blocks, badly. Number ifs, please...
This commit is contained in:
parent
48c0c032e3
commit
af2c369fb8
|
@ -262,10 +262,12 @@ TODO
|
|||
----
|
||||
|
||||
* Parse HEX values like $40A3
|
||||
* Fuller machine model
|
||||
* Tables
|
||||
* Character tables ("strings" to everybody else)
|
||||
* External routines
|
||||
* Work out the analyses again and document them
|
||||
* parse support immediate loads, compares
|
||||
* Addressing modes; rename instructions to match
|
||||
* Generate code for BEQ
|
||||
|
||||
Tests
|
||||
-----
|
||||
|
@ -393,3 +395,32 @@ No duplicate declarations.
|
|||
= tya
|
||||
= sta screen
|
||||
= rts
|
||||
|
||||
| assign word screen 4000
|
||||
| routine main {
|
||||
| lda screen
|
||||
| cmp screen
|
||||
| if beq {
|
||||
| tax
|
||||
| } else {
|
||||
| tay
|
||||
| }
|
||||
| sta screen
|
||||
| }
|
||||
= .org 0
|
||||
= .word $0801
|
||||
= .org $0801
|
||||
= .byte $10, $08, $c9, $07, $9e, $32, $30, $36, $31, $00, $00, $00
|
||||
= jmp main
|
||||
= .alias screen 4000
|
||||
= main:
|
||||
= lda screen
|
||||
= cmp screen
|
||||
= BEQ _label
|
||||
= tay
|
||||
= jmp _past
|
||||
= _label:
|
||||
= tax
|
||||
= _past:
|
||||
= sta screen
|
||||
= rts
|
||||
|
|
|
@ -54,4 +54,14 @@ emitInstr p r (COPY A X) = "tax"
|
|||
emitInstr p r (COPY A Y) = "tay"
|
||||
emitInstr p r (COPY X A) = "txa"
|
||||
emitInstr p r (COPY Y A) = "tya"
|
||||
emitInstr p r _ = "(instr)"
|
||||
|
||||
emitInstr p r (IF branch b1 b2) =
|
||||
(show branch) ++ " _label\n" ++
|
||||
emitInstrs p r b2 ++
|
||||
" jmp _past\n" ++
|
||||
"_label:\n" ++
|
||||
emitInstrs p r b1 ++
|
||||
"_past:"
|
||||
|
||||
emitInstr p r i = error "Internal error: sixtypical doesn't know how to emit assembler code for '" ++ show i ++ "'"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user