1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2025-08-15 09:27:34 +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 #immediate
lda absolute lda absolute
lda absolute, x
ldx #immediate ldx #immediate
ldx absolute ldx absolute
@@ -237,6 +238,7 @@ In these, `absolute` must be a `reserve`d or `locate`d address.
X sei { block } X sei { block }
sta absolute sta absolute
sta absolute, x
stx absolute stx absolute
@@ -258,7 +260,7 @@ TODO
---- ----
* Parse HEX values like $40A3 * Parse HEX values like $40A3
* Tables * Initial values for reserved, incl. tables
* Character tables ("strings" to everybody else) * Character tables ("strings" to everybody else)
* External routines * External routines
* Work out the analyses again and document them * Work out the analyses again and document them
@@ -416,6 +418,7 @@ We cannot absolute-indexed a word.
| ldx #0 | ldx #0
| ldy #255 | ldy #255
| lda screen | lda screen
| lda screen, x
| inc screen | inc screen
| tax | tax
| inx | inx
@@ -456,6 +459,7 @@ We cannot absolute-indexed a word.
= ldx #0 = ldx #0
= ldy #255 = ldy #255
= lda screen = lda screen
= lda screen, x
= inc screen = inc screen
= tax = tax
= inx = 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) X) = "sta " ++ label ++ ", x"
emitInstr p r (COPYINDEXED A (NamedLocation label) Y) = "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 A (NamedLocation label)) = "cmp " ++ label
emitInstr p r (CMP X (NamedLocation label)) = "cpx " ++ label emitInstr p r (CMP X (NamedLocation label)) = "cpx " ++ label
emitInstr p r (CMP Y (NamedLocation label)) = "cpy " ++ label emitInstr p r (CMP Y (NamedLocation label)) = "cpy " ++ label

View File

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