1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-01 12:41:30 +00:00

Support cpx and cpy.

This commit is contained in:
Cat's Eye Technologies 2014-04-01 17:04:14 +01:00
parent 6132b05b27
commit 48c0c032e3
3 changed files with 26 additions and 4 deletions

View File

@ -171,10 +171,10 @@ In these, `absolute` must be a `reserve`d or `locate`d address.
cmp absolute
X cmp #immediate
X cpx absolute
cpx absolute
X cpx #immediate
X cpy absolute
cpy absolute
X cpy #immediate
X dec absolute
@ -364,8 +364,10 @@ No duplicate declarations.
| sty score
| cmp score
| ldx score
| cpx screen
| txa
| ldy score
| cpy screen
| tya
| sta screen
| }
@ -384,8 +386,10 @@ No duplicate declarations.
= sty score
= cmp score
= ldx score
= cpx screen
= txa
= ldy score
= cpy screen
= tya
= sta screen
= rts

View File

@ -46,8 +46,9 @@ emitInstr p r (COPY (NamedLocation label) A) = "lda " ++ label
emitInstr p r (COPY (NamedLocation label) X) = "ldx " ++ label
emitInstr p r (COPY (NamedLocation label) Y) = "ldy " ++ label
emitInstr p r (CMP A (NamedLocation label)) = "cmp " ++ label
emitInstr p r (CMP X (NamedLocation label)) = "cpx " ++ label
emitInstr p r (CMP Y (NamedLocation label)) = "cpy " ++ label
emitInstr p r (COPY A X) = "tax"
emitInstr p r (COPY A Y) = "tay"

View File

@ -19,6 +19,8 @@ Command := "if" Branch Block "else" Block
| "ldy" (LocationName | Immediate)
| "txa" | "tax" | "tya" | "tay"
| "cmp" (LocationName | Immediate)
| "cpx" (LocationName | Immediate)
| "cpy" (LocationName | Immediate)
| "nop".
Branch := "bcc" | "bcs" | "beq" | "bmi" | "bne" | "bpl" | "bvc" | "bvs".
@ -74,9 +76,10 @@ block = do
return cs
command :: Parser Instruction
command = cmp <|> (try lda) <|> (try ldx) <|> (try ldy) <|>
command = (try lda) <|> (try ldx) <|> (try ldy) <|>
(try sta) <|> (try stx) <|> (try sty) <|>
(try txa) <|> (try tax) <|> (try tya) <|> (try tay) <|>
(try cmp) <|> (try cpx) <|> (try cpy) <|>
if_statement <|> nop
nop :: Parser Instruction
@ -92,6 +95,20 @@ cmp = do
l <- locationName
return (CMP A (NamedLocation l))
cpx :: Parser Instruction
cpx = do
string "cpx"
spaces
l <- locationName
return (CMP X (NamedLocation l))
cpy :: Parser Instruction
cpy = do
string "cpy"
spaces
l <- locationName
return (CMP Y (NamedLocation l))
lda :: Parser Instruction
lda = do
string "lda"