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