1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2025-01-11 10:29:42 +00:00

lda screen, x

This commit is contained in:
Cat's Eye Technologies 2014-04-01 23:47:10 +01:00
parent c80591f7f5
commit 128fbcf531
3 changed files with 22 additions and 10 deletions

View File

@ -202,6 +202,7 @@ In these, `absolute` must be a `reserve`d or `locate`d address.
lda #immediate
lda absolute
lda absolute, x
ldx #immediate
ldx absolute
@ -237,6 +238,7 @@ In these, `absolute` must be a `reserve`d or `locate`d address.
X sei { block }
sta absolute
sta absolute, x
stx absolute
@ -258,7 +260,7 @@ TODO
----
* Parse HEX values like $40A3
* Tables
* Initial values for reserved, incl. tables
* Character tables ("strings" to everybody else)
* External routines
* Work out the analyses again and document them
@ -416,6 +418,7 @@ We cannot absolute-indexed a word.
| ldx #0
| ldy #255
| lda screen
| lda screen, x
| inc screen
| tax
| inx
@ -456,6 +459,7 @@ We cannot absolute-indexed a word.
= ldx #0
= ldy #255
= lda screen
= lda screen, x
= inc screen
= tax
= inx

View File

@ -61,6 +61,9 @@ emitInstr p r (COPY Y A) = "tya"
emitInstr p r (COPYINDEXED A (NamedLocation label) X) = "sta " ++ label ++ ", x"
emitInstr p r (COPYINDEXED A (NamedLocation label) Y) = "sta " ++ label ++ ", x"
emitInstr p r (COPYINDEXED (NamedLocation label) A X) = "lda " ++ label ++ ", x"
emitInstr p r (COPYINDEXED (NamedLocation label) A Y) = "lda " ++ label ++ ", x"
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

View File

@ -213,12 +213,20 @@ index = do
spaces
return X
absolute_indexed :: (LocationName -> [StorageLocation] -> Instruction) -> Parser Instruction
absolute_indexed f = do
l <- locationName
indexes <- many index
return $ f l indexes
lda :: Parser Instruction
lda = do
string "lda"
spaces
(try $ immediate (\v -> PUT A v) <|>
absolute (\l -> COPY (NamedLocation l) A))
(try $ immediate (\v -> PUT A v) <|> absolute_indexed gen)
where
gen l [] = COPY (NamedLocation l) A
gen l [X] = COPYINDEXED (NamedLocation l) A X
ldx :: Parser Instruction
ldx = do
@ -238,13 +246,10 @@ sta :: Parser Instruction
sta = do
string "sta"
spaces
l <- locationName
indexes <- many index
return $ case indexes of
[] ->
COPY A (NamedLocation l)
[X] ->
COPYINDEXED A (NamedLocation l) X
absolute_indexed gen
where
gen l [] = COPY A (NamedLocation l)
gen l [X] = COPYINDEXED A (NamedLocation l) X
stx :: Parser Instruction
stx = do