56 | 56 |
string "reserve"
|
57 | 57 |
spaces
|
58 | 58 |
sz <- storage_type
|
59 | |
name <- locationName
|
|
59 |
name <- location_name
|
60 | 60 |
return $ Reserve name sz
|
61 | 61 |
|
62 | 62 |
assign :: Parser Decl
|
|
64 | 64 |
string "assign"
|
65 | 65 |
spaces
|
66 | 66 |
sz <- storage_type
|
67 | |
name <- locationName
|
|
67 |
name <- location_name
|
68 | 68 |
addr <- address
|
69 | 69 |
return $ Assign name sz addr
|
70 | 70 |
|
|
103 | 103 |
spaces
|
104 | 104 |
string "("
|
105 | 105 |
spaces
|
106 | |
locations <- many locationName
|
|
106 |
locations <- many location
|
107 | 107 |
string ")"
|
108 | 108 |
spaces
|
109 | |
return (map (\x -> NamedLocation Nothing x) locations)
|
|
109 |
return locations
|
|
110 |
|
|
111 |
location = (try explicit_register <|> named_location)
|
110 | 112 |
|
111 | 113 |
block :: Parser [Instruction]
|
112 | 114 |
block = do
|
|
149 | 151 |
low_byte_of_absolute :: Parser AddressingModality
|
150 | 152 |
low_byte_of_absolute = do
|
151 | 153 |
string "<"
|
152 | |
l <- locationName
|
|
154 |
l <- location_name
|
153 | 155 |
return $ LowBytely l
|
154 | 156 |
|
155 | 157 |
high_byte_of_absolute :: Parser AddressingModality
|
156 | 158 |
high_byte_of_absolute = do
|
157 | 159 |
string ">"
|
158 | |
l <- locationName
|
|
160 |
l <- location_name
|
159 | 161 |
return $ HighBytely l
|
160 | 162 |
|
161 | 163 |
indirect_location :: Parser AddressingModality
|
162 | 164 |
indirect_location = do
|
163 | 165 |
string "("
|
164 | 166 |
spaces
|
165 | |
l <- locationName
|
|
167 |
l <- location_name
|
166 | 168 |
string ")"
|
167 | 169 |
spaces
|
168 | 170 |
return $ Indirectly l
|
169 | 171 |
|
170 | 172 |
direct_location :: Parser AddressingModality
|
171 | 173 |
direct_location = do
|
172 | |
l <- locationName
|
|
174 |
l <- location_name
|
173 | 175 |
return $ Directly l
|
|
176 |
|
|
177 |
explicit_location :: String -> StorageLocation -> Parser StorageLocation
|
|
178 |
explicit_location s l = do
|
|
179 |
string s
|
|
180 |
spaces
|
|
181 |
return $ l
|
|
182 |
|
|
183 |
explicit_register :: Parser StorageLocation
|
|
184 |
explicit_register = ((try $ explicit_location ".a" A) <|>
|
|
185 |
(try $ explicit_location ".x" X) <|>
|
|
186 |
(explicit_location ".y" Y))
|
174 | 187 |
|
175 | 188 |
register_location :: Parser AddressingModality
|
176 | 189 |
register_location = do
|
177 | |
string "@" --- ARGH
|
178 | |
spaces
|
179 | |
return $ Implicitly A
|
|
190 |
z <- explicit_register
|
|
191 |
spaces
|
|
192 |
return $ Implicitly z
|
180 | 193 |
|
181 | 194 |
immediate :: Parser AddressingModality
|
182 | 195 |
immediate = do
|
|
311 | 324 |
inc = do
|
312 | 325 |
string "inc"
|
313 | 326 |
spaces
|
314 | |
l <- locationName
|
315 | |
return (DELTA (NamedLocation Nothing l) 1)
|
|
327 |
l <- named_location
|
|
328 |
return (DELTA l 1)
|
316 | 329 |
|
317 | 330 |
dec :: Parser Instruction
|
318 | 331 |
dec = do
|
319 | 332 |
string "dec"
|
320 | 333 |
spaces
|
321 | |
l <- locationName
|
322 | |
return (DELTA (NamedLocation Nothing l) (-1))
|
|
334 |
l <- named_location
|
|
335 |
return (DELTA l (-1))
|
323 | 336 |
|
324 | 337 |
cmp :: Parser Instruction
|
325 | 338 |
cmp = do
|
|
428 | 441 |
stx = do
|
429 | 442 |
string "stx"
|
430 | 443 |
spaces
|
431 | |
l <- locationName
|
432 | |
return (COPY X (NamedLocation Nothing l))
|
|
444 |
l <- named_location
|
|
445 |
return (COPY X l)
|
433 | 446 |
|
434 | 447 |
sty :: Parser Instruction
|
435 | 448 |
sty = do
|
436 | 449 |
string "sty"
|
437 | 450 |
spaces
|
438 | |
l <- locationName
|
439 | |
return (COPY Y (NamedLocation Nothing l))
|
|
451 |
l <- named_location
|
|
452 |
return (COPY Y l)
|
440 | 453 |
|
441 | 454 |
txa :: Parser Instruction
|
442 | 455 |
txa = do
|
|
489 | 502 |
spaces
|
490 | 503 |
string "("
|
491 | 504 |
spaces
|
492 | |
l <- locationName
|
|
505 |
l <- named_location
|
493 | 506 |
string ")"
|
494 | 507 |
spaces
|
495 | |
return $ JMPVECTOR (NamedLocation Nothing l)
|
|
508 |
return $ JMPVECTOR l
|
496 | 509 |
|
497 | 510 |
jsr :: Parser Instruction
|
498 | 511 |
jsr = do
|
|
541 | 554 |
src <- routineName
|
542 | 555 |
string "to"
|
543 | 556 |
spaces
|
544 | |
dst <- locationName
|
|
557 |
dst <- location_name
|
545 | 558 |
return (COPYROUTINE src (NamedLocation Nothing dst))
|
546 | 559 |
|
547 | 560 |
branch :: Parser Branch
|
|
562 | 575 |
spaces
|
563 | 576 |
return (c:cs)
|
564 | 577 |
|
565 | |
locationName :: Parser String
|
566 | |
locationName = do
|
|
578 |
location_name :: Parser String
|
|
579 |
location_name = do
|
567 | 580 |
c <- letter
|
568 | 581 |
cs <- many (alphaNum <|> char '_')
|
569 | 582 |
spaces
|
570 | 583 |
return (c:cs)
|
|
584 |
|
|
585 |
named_location :: Parser StorageLocation
|
|
586 |
named_location = do
|
|
587 |
name <- location_name
|
|
588 |
return (NamedLocation Nothing name)
|
571 | 589 |
|
572 | 590 |
address = hex_address <|> decimal_address
|
573 | 591 |
|