mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-01-10 02:29:23 +00:00
Incrementing and decrementing.
This commit is contained in:
parent
af2c369fb8
commit
d1521afd3a
@ -177,20 +177,20 @@ In these, `absolute` must be a `reserve`d or `locate`d address.
|
||||
cpy absolute
|
||||
X cpy #immediate
|
||||
|
||||
X dec absolute
|
||||
dec absolute
|
||||
|
||||
X dex
|
||||
dex
|
||||
|
||||
X dey
|
||||
dey
|
||||
|
||||
X eor #immediate
|
||||
X eor absolute
|
||||
|
||||
X inc absolute
|
||||
inc absolute
|
||||
|
||||
X inx
|
||||
inx
|
||||
|
||||
X iny
|
||||
iny
|
||||
|
||||
! jmp
|
||||
|
||||
@ -267,6 +267,8 @@ TODO
|
||||
* External routines
|
||||
* Work out the analyses again and document them
|
||||
* parse support immediate loads, compares
|
||||
* number ifs and repeats
|
||||
* hello, world sort of program
|
||||
* Addressing modes; rename instructions to match
|
||||
|
||||
Tests
|
||||
@ -360,9 +362,14 @@ No duplicate declarations.
|
||||
| assign word screen 4000
|
||||
| routine main {
|
||||
| lda screen
|
||||
| inc screen
|
||||
| tax
|
||||
| inx
|
||||
| dex
|
||||
| stx score
|
||||
| tay
|
||||
| iny
|
||||
| dey
|
||||
| sty score
|
||||
| cmp score
|
||||
| ldx score
|
||||
@ -372,6 +379,7 @@ No duplicate declarations.
|
||||
| cpy screen
|
||||
| tya
|
||||
| sta screen
|
||||
| dec screen
|
||||
| }
|
||||
= .org 0
|
||||
= .word $0801
|
||||
@ -382,9 +390,14 @@ No duplicate declarations.
|
||||
= .alias screen 4000
|
||||
= main:
|
||||
= lda screen
|
||||
= inc screen
|
||||
= tax
|
||||
= inx
|
||||
= dex
|
||||
= stx score
|
||||
= tay
|
||||
= iny
|
||||
= dey
|
||||
= sty score
|
||||
= cmp score
|
||||
= ldx score
|
||||
@ -394,6 +407,7 @@ No duplicate declarations.
|
||||
= cpy screen
|
||||
= tya
|
||||
= sta screen
|
||||
= dec screen
|
||||
= rts
|
||||
|
||||
| assign word screen 4000
|
||||
|
@ -50,6 +50,13 @@ 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 (DELTA X 1) = "inx"
|
||||
emitInstr p r (DELTA X (-1)) = "dex"
|
||||
emitInstr p r (DELTA Y 1) = "iny"
|
||||
emitInstr p r (DELTA Y (-1)) = "dey"
|
||||
emitInstr p r (DELTA (NamedLocation label) 1) = "inc " ++ label
|
||||
emitInstr p r (DELTA (NamedLocation label) (-1)) = "dec " ++ label
|
||||
|
||||
emitInstr p r (COPY A X) = "tax"
|
||||
emitInstr p r (COPY A Y) = "tay"
|
||||
emitInstr p r (COPY X A) = "txa"
|
||||
|
@ -54,6 +54,7 @@ data Instruction = LOADIMM StorageLocation DataValue
|
||||
| CMP StorageLocation StorageLocation
|
||||
| JSR RoutineName
|
||||
| IF Branch [Instruction] [Instruction]
|
||||
| DELTA StorageLocation DataValue
|
||||
| NOP
|
||||
deriving (Show, Ord, Eq)
|
||||
|
||||
|
@ -21,6 +21,7 @@ Command := "if" Branch Block "else" Block
|
||||
| "cmp" (LocationName | Immediate)
|
||||
| "cpx" (LocationName | Immediate)
|
||||
| "cpy" (LocationName | Immediate)
|
||||
| "inx" | "iny" | "dex" | "dey"
|
||||
| "nop".
|
||||
Branch := "bcc" | "bcs" | "beq" | "bmi" | "bne" | "bpl" | "bvc" | "bvs".
|
||||
|
||||
@ -80,6 +81,8 @@ 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) <|>
|
||||
(try inx) <|> (try iny) <|> (try dex) <|> (try dey) <|>
|
||||
(try inc) <|> (try dec) <|>
|
||||
if_statement <|> nop
|
||||
|
||||
nop :: Parser Instruction
|
||||
@ -88,6 +91,44 @@ nop = do
|
||||
spaces
|
||||
return NOP
|
||||
|
||||
inx :: Parser Instruction
|
||||
inx = do
|
||||
string "inx"
|
||||
spaces
|
||||
return $ DELTA X 1
|
||||
|
||||
iny :: Parser Instruction
|
||||
iny = do
|
||||
string "iny"
|
||||
spaces
|
||||
return $ DELTA Y 1
|
||||
|
||||
dex :: Parser Instruction
|
||||
dex = do
|
||||
string "dex"
|
||||
spaces
|
||||
return $ DELTA X (-1)
|
||||
|
||||
dey :: Parser Instruction
|
||||
dey = do
|
||||
string "dey"
|
||||
spaces
|
||||
return $ DELTA Y (-1)
|
||||
|
||||
inc :: Parser Instruction
|
||||
inc = do
|
||||
string "inc"
|
||||
spaces
|
||||
l <- locationName
|
||||
return (DELTA (NamedLocation l) 1)
|
||||
|
||||
dec :: Parser Instruction
|
||||
dec = do
|
||||
string "dec"
|
||||
spaces
|
||||
l <- locationName
|
||||
return (DELTA (NamedLocation l) (-1))
|
||||
|
||||
cmp :: Parser Instruction
|
||||
cmp = do
|
||||
string "cmp"
|
||||
|
Loading…
x
Reference in New Issue
Block a user