git @ Cat's Eye Technologies SixtyPical / 2684f65
Git rid of all modes of COPY. Cat's Eye Technologies 11 years ago
4 changed file(s) with 9 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
6868 in
6969 mappedProgram == p
7070 where
71 checkInstr j@(COPYINDEXED _ (NamedLocation g) _) =
71 checkInstr j@(COPY _ (Indexed (NamedLocation g) reg)) =
7272 case lookupDecl p g of
7373 Just (Assign _ ByteTable _) -> j
7474 Just (Reserve _ ByteTable) -> j
5353 emitInstr p r (COPY X A) = "txa"
5454 emitInstr p r (COPY Y A) = "tya"
5555
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"
5858
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"
6161
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"
6363
6464 emitInstr p r (CMP A (NamedLocation label)) = "cmp " ++ label
6565 emitInstr p r (CMP X (NamedLocation label)) = "cpx " ++ label
5858 deriving (Show, Ord, Eq)
5959
6060 data Instruction = COPY StorageLocation StorageLocation
61 | COPYINDEXED StorageLocation StorageLocation StorageLocation
62 | COPYINDIRECTINDEXED StorageLocation StorageLocation StorageLocation
6361 | CMPIMM StorageLocation DataValue
6462 | CMP StorageLocation StorageLocation
6563 | ADDIMM StorageLocation DataValue
316316 (try $ immediate (\v -> COPY (Immediate v) A) <|> absolute_indexed gen)
317317 where
318318 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
320320
321321 ldx :: Parser Instruction
322322 ldx = do
339339 indirect_indexed gen
340340 where
341341 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)
344344
345345 stx :: Parser Instruction
346346 stx = do