From f4a77ae5c44d10b50120d804fab6226ee9fc31c5 Mon Sep 17 00:00:00 2001 From: Cat's Eye Technologies Date: Thu, 3 Apr 2014 18:59:37 +0100 Subject: [PATCH] Support for all instructions! --- src/SixtyPical/Emitter.hs | 10 ++++++++++ src/SixtyPical/Model.hs | 1 + src/SixtyPical/Parser.hs | 18 ++++++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/SixtyPical/Emitter.hs b/src/SixtyPical/Emitter.hs index f4c937e..0eefe31 100644 --- a/src/SixtyPical/Emitter.hs +++ b/src/SixtyPical/Emitter.hs @@ -134,6 +134,16 @@ emitInstr p r (SEI blk) = emitInstrs p r blk ++ " cli" +emitInstr p r (PUSH A blk) = + "pha\n" ++ + emitInstrs p r blk ++ + " pla" + +emitInstr p r (PUSH FlagC blk) = + "php\n" ++ + emitInstrs p r blk ++ + " plp" + emitInstr p r (COPYVECTOR (NamedLocation (Just Vector) src) (NamedLocation (Just Vector) dst)) = "lda " ++ src ++ "\n" ++ " sta " ++ dst ++ "\n" ++ diff --git a/src/SixtyPical/Model.hs b/src/SixtyPical/Model.hs index b87fae1..6035273 100644 --- a/src/SixtyPical/Model.hs +++ b/src/SixtyPical/Model.hs @@ -77,6 +77,7 @@ data Instruction = COPY StorageLocation StorageLocation | REPEAT InternalID Branch [Instruction] | DELTA StorageLocation DataValue | SEI [Instruction] + | PUSH StorageLocation [Instruction] | COPYVECTOR StorageLocation StorageLocation | COPYROUTINE RoutineName StorageLocation | NOP diff --git a/src/SixtyPical/Parser.hs b/src/SixtyPical/Parser.hs index bb5ec07..dcc879b 100644 --- a/src/SixtyPical/Parser.hs +++ b/src/SixtyPical/Parser.hs @@ -27,7 +27,7 @@ Command := "if" Branch Block "else" Block | "cpy" (LocationName | Immediate) | "inx" | "iny" | "dex" | "dey" | "inc" Location | "dec" Location | "clc" | "cld" | "clv" | "sec" | "sed" - | "sei" Block + | "sei" Block | "pha" Block | "php" Block | "jmp" LocationName | "jsr" RoutineName | "nop". @@ -196,7 +196,7 @@ command = (try lda) <|> (try sbc) <|> (try ora) <|> (try asl) <|> (try bit) <|> (try eor) <|> (try lsr) <|> (try rol) <|> (try ror) <|> - (try sei) <|> + (try sei) <|> (try pha) <|> (try php) <|> (try jmp) <|> (try jsr) <|> (try copy_vector_statement) <|> (try copy_routine_statement) <|> @@ -486,6 +486,20 @@ sei = do blk <- block return (SEI blk) +pha :: Parser Instruction +pha = do + string "pha" + spaces + blk <- block + return (PUSH A blk) + +php :: Parser Instruction +php = do + string "php" + spaces + blk <- block + return (PUSH FlagC blk) + jmp :: Parser Instruction jmp = do string "jmp"