mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-11-22 01:32:13 +00:00
lda,y sta,y adc and
This commit is contained in:
parent
128fbcf531
commit
1aea850043
@ -137,11 +137,12 @@ Funny syntax indicates use of a special form.
|
||||
|
||||
In these, `absolute` must be a `reserve`d or `locate`d address.
|
||||
|
||||
X adc #immediate
|
||||
X adc absolute
|
||||
.
|
||||
adc #immediate
|
||||
adc absolute
|
||||
|
||||
X and #immediate
|
||||
X and absolute
|
||||
and #immediate
|
||||
and absolute
|
||||
|
||||
X asl
|
||||
X asl absolute
|
||||
@ -203,6 +204,7 @@ In these, `absolute` must be a `reserve`d or `locate`d address.
|
||||
lda #immediate
|
||||
lda absolute
|
||||
lda absolute, x
|
||||
lda absolute, y
|
||||
|
||||
ldx #immediate
|
||||
ldx absolute
|
||||
@ -235,10 +237,11 @@ In these, `absolute` must be a `reserve`d or `locate`d address.
|
||||
|
||||
sed
|
||||
|
||||
X sei { block }
|
||||
sei { block }
|
||||
|
||||
sta absolute
|
||||
sta absolute, x
|
||||
sta absolute, y
|
||||
|
||||
stx absolute
|
||||
|
||||
@ -266,6 +269,8 @@ TODO
|
||||
* Work out the analyses again and document them
|
||||
* `repeat jmp`
|
||||
* Addressing modes; rename instructions to match
|
||||
* Not responsible for BASIC header (cat externally)
|
||||
* Put data at end, no need for jmp main
|
||||
|
||||
Tests
|
||||
-----
|
||||
@ -419,6 +424,7 @@ We cannot absolute-indexed a word.
|
||||
| ldy #255
|
||||
| lda screen
|
||||
| lda screen, x
|
||||
| lda screen, y
|
||||
| inc screen
|
||||
| tax
|
||||
| inx
|
||||
@ -440,12 +446,17 @@ We cannot absolute-indexed a word.
|
||||
| tya
|
||||
| sta screen
|
||||
| sta screen, x
|
||||
| sta screen, y
|
||||
| dec screen
|
||||
| clc
|
||||
| cld
|
||||
| clv
|
||||
| sec
|
||||
| sed
|
||||
| adc #8
|
||||
| adc screen
|
||||
| and #8
|
||||
| and screen
|
||||
| }
|
||||
= .org 0
|
||||
= .word $0801
|
||||
@ -460,6 +471,7 @@ We cannot absolute-indexed a word.
|
||||
= ldy #255
|
||||
= lda screen
|
||||
= lda screen, x
|
||||
= lda screen, y
|
||||
= inc screen
|
||||
= tax
|
||||
= inx
|
||||
@ -481,12 +493,17 @@ We cannot absolute-indexed a word.
|
||||
= tya
|
||||
= sta screen
|
||||
= sta screen, x
|
||||
= sta screen, y
|
||||
= dec screen
|
||||
= clc
|
||||
= cld
|
||||
= clv
|
||||
= sec
|
||||
= sed
|
||||
= adc #8
|
||||
= adc screen
|
||||
= and #8
|
||||
= and screen
|
||||
= rts
|
||||
|
||||
| assign word screen 1024
|
||||
|
@ -59,10 +59,10 @@ emitInstr p r (COPY X A) = "txa"
|
||||
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 A (NamedLocation label) Y) = "sta " ++ label ++ ", y"
|
||||
|
||||
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 (COPYINDEXED (NamedLocation label) A Y) = "lda " ++ label ++ ", y"
|
||||
|
||||
emitInstr p r (CMP A (NamedLocation label)) = "cmp " ++ label
|
||||
emitInstr p r (CMP X (NamedLocation label)) = "cpx " ++ label
|
||||
@ -72,6 +72,12 @@ emitInstr p r (CMPIMM A val) = "cmp #" ++ (show val)
|
||||
emitInstr p r (CMPIMM X val) = "cpx #" ++ (show val)
|
||||
emitInstr p r (CMPIMM Y val) = "cpy #" ++ (show val)
|
||||
|
||||
emitInstr p r (ADD A (NamedLocation label)) = "adc " ++ label
|
||||
emitInstr p r (ADDIMM A val) = "adc #" ++ (show val)
|
||||
|
||||
emitInstr p r (AND A (NamedLocation label)) = "and " ++ label
|
||||
emitInstr p r (ANDIMM A val) = "and #" ++ (show val)
|
||||
|
||||
emitInstr p r (DELTA X 1) = "inx"
|
||||
emitInstr p r (DELTA X (-1)) = "dex"
|
||||
emitInstr p r (DELTA Y 1) = "iny"
|
||||
|
@ -58,6 +58,10 @@ data Instruction = PUT StorageLocation DataValue
|
||||
| COPYINDEXED StorageLocation StorageLocation StorageLocation
|
||||
| CMPIMM StorageLocation DataValue
|
||||
| CMP StorageLocation StorageLocation
|
||||
| ADDIMM StorageLocation DataValue
|
||||
| ADD StorageLocation StorageLocation
|
||||
| ANDIMM StorageLocation DataValue
|
||||
| AND StorageLocation StorageLocation
|
||||
| JSR RoutineName
|
||||
-- | JSRVECTOR StorageLocation
|
||||
| JMPVECTOR StorageLocation
|
||||
|
@ -93,6 +93,7 @@ command = (try lda) <|>
|
||||
(try inx) <|> (try iny) <|> (try dex) <|> (try dey) <|>
|
||||
(try inc) <|> (try dec) <|>
|
||||
(try clc) <|> (try cld) <|> (try clv) <|> (try sec) <|> (try sed) <|>
|
||||
(try adc) <|> (try SixtyPical.Parser.and) <|>
|
||||
(try sei) <|>
|
||||
(try jmp) <|>
|
||||
(try copy_vector_statement) <|>
|
||||
@ -194,6 +195,20 @@ cpy = do
|
||||
(try $ immediate (\v -> CMPIMM Y v) <|>
|
||||
absolute (\l -> CMP Y (NamedLocation l)))
|
||||
|
||||
adc :: Parser Instruction
|
||||
adc = do
|
||||
string "adc"
|
||||
spaces
|
||||
(try $ immediate (\v -> ADDIMM A v) <|>
|
||||
absolute (\l -> ADD A (NamedLocation l)))
|
||||
|
||||
and :: Parser Instruction
|
||||
and = do
|
||||
string "and"
|
||||
spaces
|
||||
(try $ immediate (\v -> ANDIMM A v) <|>
|
||||
absolute (\l -> AND A (NamedLocation l)))
|
||||
|
||||
immediate :: (DataValue -> Instruction) -> Parser Instruction
|
||||
immediate f = do
|
||||
string "#"
|
||||
@ -209,9 +224,11 @@ index :: Parser StorageLocation
|
||||
index = do
|
||||
string ","
|
||||
spaces
|
||||
string "x"
|
||||
c <- (string "x" <|> string "y")
|
||||
spaces
|
||||
return X
|
||||
return $ case c of
|
||||
"x" -> X
|
||||
"y" -> Y
|
||||
|
||||
absolute_indexed :: (LocationName -> [StorageLocation] -> Instruction) -> Parser Instruction
|
||||
absolute_indexed f = do
|
||||
@ -226,7 +243,7 @@ lda = do
|
||||
(try $ immediate (\v -> PUT A v) <|> absolute_indexed gen)
|
||||
where
|
||||
gen l [] = COPY (NamedLocation l) A
|
||||
gen l [X] = COPYINDEXED (NamedLocation l) A X
|
||||
gen l [reg] = COPYINDEXED (NamedLocation l) A reg
|
||||
|
||||
ldx :: Parser Instruction
|
||||
ldx = do
|
||||
@ -249,7 +266,7 @@ sta = do
|
||||
absolute_indexed gen
|
||||
where
|
||||
gen l [] = COPY A (NamedLocation l)
|
||||
gen l [X] = COPYINDEXED A (NamedLocation l) X
|
||||
gen l [reg] = COPYINDEXED A (NamedLocation l) reg
|
||||
|
||||
stx :: Parser Instruction
|
||||
stx = do
|
||||
|
Loading…
Reference in New Issue
Block a user