Git rid of all modes of COPY.
Cat's Eye Technologies
11 years ago
68 | 68 |
in
|
69 | 69 |
mappedProgram == p
|
70 | 70 |
where
|
71 | |
checkInstr j@(COPYINDEXED _ (NamedLocation g) _) =
|
|
71 |
checkInstr j@(COPY _ (Indexed (NamedLocation g) reg)) =
|
72 | 72 |
case lookupDecl p g of
|
73 | 73 |
Just (Assign _ ByteTable _) -> j
|
74 | 74 |
Just (Reserve _ ByteTable) -> j
|
53 | 53 |
emitInstr p r (COPY X A) = "txa"
|
54 | 54 |
emitInstr p r (COPY Y A) = "tya"
|
55 | 55 |
|
56 | |
emitInstr p r (COPYINDEXED A (NamedLocation label) X) = "sta " ++ label ++ ", x"
|
57 | |
emitInstr p r (COPYINDEXED A (NamedLocation label) Y) = "sta " ++ label ++ ", y"
|
|
56 |
emitInstr p r (COPY A (Indexed (NamedLocation label) X)) = "sta " ++ label ++ ", x"
|
|
57 |
emitInstr p r (COPY A (Indexed (NamedLocation label) Y)) = "sta " ++ label ++ ", y"
|
58 | 58 |
|
59 | |
emitInstr p r (COPYINDEXED (NamedLocation label) A X) = "lda " ++ label ++ ", x"
|
60 | |
emitInstr p r (COPYINDEXED (NamedLocation label) A Y) = "lda " ++ label ++ ", y"
|
|
59 |
emitInstr p r (COPY (Indexed (NamedLocation label) X) A) = "lda " ++ label ++ ", x"
|
|
60 |
emitInstr p r (COPY (Indexed (NamedLocation label) Y) A) = "lda " ++ label ++ ", y"
|
61 | 61 |
|
62 | |
emitInstr p r (COPYINDIRECTINDEXED A (NamedLocation label) Y) = "sta (" ++ label ++ "), y"
|
|
62 |
emitInstr p r (COPY A (IndirectIndexed (NamedLocation label) Y)) = "sta (" ++ label ++ "), y"
|
63 | 63 |
|
64 | 64 |
emitInstr p r (CMP A (NamedLocation label)) = "cmp " ++ label
|
65 | 65 |
emitInstr p r (CMP X (NamedLocation label)) = "cpx " ++ label
|
58 | 58 |
deriving (Show, Ord, Eq)
|
59 | 59 |
|
60 | 60 |
data Instruction = COPY StorageLocation StorageLocation
|
61 | |
| COPYINDEXED StorageLocation StorageLocation StorageLocation
|
62 | |
| COPYINDIRECTINDEXED StorageLocation StorageLocation StorageLocation
|
63 | 61 |
| CMPIMM StorageLocation DataValue
|
64 | 62 |
| CMP StorageLocation StorageLocation
|
65 | 63 |
| ADDIMM StorageLocation DataValue
|
316 | 316 |
(try $ immediate (\v -> COPY (Immediate v) A) <|> absolute_indexed gen)
|
317 | 317 |
where
|
318 | 318 |
gen l [] = COPY (NamedLocation l) A
|
319 | |
gen l [reg] = COPYINDEXED (NamedLocation l) A reg
|
|
319 |
gen l [reg] = COPY (Indexed (NamedLocation l) reg) A
|
320 | 320 |
|
321 | 321 |
ldx :: Parser Instruction
|
322 | 322 |
ldx = do
|
|
339 | 339 |
indirect_indexed gen
|
340 | 340 |
where
|
341 | 341 |
gen (Directly l) [] = COPY A (NamedLocation l)
|
342 | |
gen (Directly l) [reg] = COPYINDEXED A (NamedLocation l) reg
|
343 | |
gen (Indirectly l) [reg] = COPYINDIRECTINDEXED A (NamedLocation l) reg
|
|
342 |
gen (Directly l) [reg] = COPY A (Indexed (NamedLocation l) reg)
|
|
343 |
gen (Indirectly l) [reg] = COPY A (IndirectIndexed (NamedLocation l) reg)
|
344 | 344 |
|
345 | 345 |
stx :: Parser Instruction
|
346 | 346 |
stx = do
|