mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-16 15:30:26 +00:00
Low, high bytes of word.
This commit is contained in:
parent
249d29b695
commit
c9c2d9345f
@ -463,22 +463,22 @@ We cannot absolute-indexed a word.
|
||||
| }
|
||||
? indexed access of non-table
|
||||
|
||||
> We cannot absolute acess a word.
|
||||
>
|
||||
> | assign word screen 1024
|
||||
> | routine main {
|
||||
> | lda screen
|
||||
> | }
|
||||
> ? absolute access of non-byte-based address
|
||||
>
|
||||
> Instead, we have to do this.
|
||||
>
|
||||
> | assign word screen 1024
|
||||
> | routine main {
|
||||
> | lda <screen
|
||||
> | lda >screen
|
||||
> | }
|
||||
> = True
|
||||
We cannot absolute access a word.
|
||||
|
||||
| assign word screen 1024
|
||||
| routine main {
|
||||
| lda screen
|
||||
| }
|
||||
? absolute access of non-byte-based address
|
||||
|
||||
Instead, we have to do this.
|
||||
|
||||
| assign word screen 1024
|
||||
| routine main {
|
||||
| lda <screen
|
||||
| lda >screen
|
||||
| }
|
||||
= True
|
||||
|
||||
-> Tests for functionality "Emit ASM for SixtyPical program"
|
||||
|
||||
@ -495,6 +495,8 @@ We cannot absolute-indexed a word.
|
||||
| lda screen, x
|
||||
| lda screen, y
|
||||
| lda (screen), y
|
||||
| lda <score
|
||||
| lda >score
|
||||
| inc screen
|
||||
| tax
|
||||
| inx
|
||||
@ -541,6 +543,8 @@ We cannot absolute-indexed a word.
|
||||
= lda screen, x
|
||||
= lda screen, y
|
||||
= lda (screen), y
|
||||
= lda score
|
||||
= lda score+1
|
||||
= inc screen
|
||||
= tax
|
||||
= inx
|
||||
|
@ -49,6 +49,9 @@ emitInstr p r (COPY (NamedLocation st label) A) = "lda " ++ label
|
||||
emitInstr p r (COPY (NamedLocation st label) X) = "ldx " ++ label
|
||||
emitInstr p r (COPY (NamedLocation st label) Y) = "ldy " ++ label
|
||||
|
||||
emitInstr p r (COPY (LowByteOf (NamedLocation st label)) A) = "lda " ++ label
|
||||
emitInstr p r (COPY (HighByteOf (NamedLocation st label)) A) = "lda " ++ label ++ "+1"
|
||||
|
||||
emitInstr p r (COPY A X) = "tax"
|
||||
emitInstr p r (COPY A Y) = "tay"
|
||||
emitInstr p r (COPY X A) = "txa"
|
||||
|
@ -39,6 +39,8 @@ data StorageLocation = A
|
||||
| Indexed StorageLocation StorageLocation
|
||||
| IndirectIndexed StorageLocation StorageLocation
|
||||
| NamedLocation (Maybe StorageType) LocationName
|
||||
| LowByteOf StorageLocation
|
||||
| HighByteOf StorageLocation
|
||||
deriving (Show, Ord, Eq)
|
||||
|
||||
-- this is bunk, man. if a location does not appear in an analysis
|
||||
|
@ -122,10 +122,24 @@ index = do
|
||||
"y" -> Y
|
||||
|
||||
data AddressingModality = Directly LocationName
|
||||
| HighBytely LocationName
|
||||
| LowBytely LocationName
|
||||
| Indirectly LocationName
|
||||
| Immediately DataValue
|
||||
deriving (Ord, Show, Eq)
|
||||
|
||||
low_byte_of_absolute :: Parser AddressingModality
|
||||
low_byte_of_absolute = do
|
||||
string "<"
|
||||
l <- locationName
|
||||
return $ LowBytely l
|
||||
|
||||
high_byte_of_absolute :: Parser AddressingModality
|
||||
high_byte_of_absolute = do
|
||||
string ">"
|
||||
l <- locationName
|
||||
return $ HighBytely l
|
||||
|
||||
indirect_location :: Parser AddressingModality
|
||||
indirect_location = do
|
||||
string "("
|
||||
@ -148,7 +162,9 @@ immediate = do
|
||||
|
||||
addressing_mode :: (AddressingModality -> [StorageLocation] -> Instruction) -> Parser Instruction
|
||||
addressing_mode f = do
|
||||
d <- ((try immediate) <|> (try indirect_location) <|> direct_location)
|
||||
d <- ((try immediate) <|> (try high_byte_of_absolute) <|>
|
||||
(try low_byte_of_absolute) <|> (try indirect_location) <|>
|
||||
direct_location)
|
||||
indexes <- many index
|
||||
return $ f d indexes
|
||||
|
||||
@ -319,6 +335,8 @@ lda = do
|
||||
addressing_mode gen
|
||||
where
|
||||
gen (Immediately v) [] = COPY (Immediate v) A
|
||||
gen (LowBytely l) [] = COPY (LowByteOf (NamedLocation Nothing l)) A
|
||||
gen (HighBytely l) [] = COPY (HighByteOf (NamedLocation Nothing l)) A
|
||||
gen (Directly l) [] = COPY (NamedLocation Nothing l) A
|
||||
gen (Directly l) [reg] = COPY (Indexed (NamedLocation Nothing l) reg) A
|
||||
gen (Indirectly l) [reg] = COPY (IndirectIndexed (NamedLocation Nothing l) reg) A
|
||||
|
Loading…
x
Reference in New Issue
Block a user