mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-11-24 15:32:27 +00:00
Parse hex values.
This commit is contained in:
parent
765073f94e
commit
159d3835be
@ -262,11 +262,12 @@ In these, `absolute` must be a `reserve`d or `locate`d address.
|
||||
TODO
|
||||
----
|
||||
|
||||
* Parse HEX values like $40A3
|
||||
* comments
|
||||
* Initial values for reserved, incl. tables
|
||||
* give length for tables, must be there for reserved
|
||||
* Character tables ("strings" to everybody else)
|
||||
* Work out the analyses again and document them
|
||||
* `repeat jmp`
|
||||
* lda wordaddress --> is not legal. use lda <wordaddr or lda >wordaddr
|
||||
* Addressing modes; rename instructions to match
|
||||
|
||||
Tests
|
||||
@ -441,7 +442,7 @@ We cannot absolute-indexed a word.
|
||||
| routine main {
|
||||
| lda #4
|
||||
| ldx #0
|
||||
| ldy #255
|
||||
| ldy #$FF
|
||||
| lda screen
|
||||
| lda screen, x
|
||||
| lda screen, y
|
||||
@ -530,7 +531,7 @@ We cannot absolute-indexed a word.
|
||||
= score: .word 0
|
||||
= .alias screen 1024
|
||||
|
||||
| assign word screen 1024
|
||||
| assign word screen $0400
|
||||
| routine main {
|
||||
| lda screen
|
||||
| cmp screen
|
||||
|
@ -2,9 +2,12 @@
|
||||
|
||||
module SixtyPical.Parser (parseProgram) where
|
||||
|
||||
import SixtyPical.Model
|
||||
import Numeric (readHex)
|
||||
|
||||
import Text.ParserCombinators.Parsec
|
||||
|
||||
import SixtyPical.Model
|
||||
|
||||
{-
|
||||
|
||||
Toplevel := {Decl} {Routine}.
|
||||
@ -420,14 +423,34 @@ locationName = do
|
||||
spaces
|
||||
return (c:cs)
|
||||
|
||||
address :: Parser Address
|
||||
address = do
|
||||
address = hex_address <|> decimal_address
|
||||
|
||||
hex_address :: Parser Address
|
||||
hex_address = do
|
||||
char '$'
|
||||
digits <- many hexDigit
|
||||
spaces
|
||||
let ((d, _):_) = readHex digits
|
||||
return (d :: Address)
|
||||
|
||||
decimal_address :: Parser Address
|
||||
decimal_address = do
|
||||
digits <- many digit
|
||||
spaces
|
||||
return (read digits :: Address)
|
||||
|
||||
data_value :: Parser DataValue
|
||||
data_value = do
|
||||
data_value = hex_data_value <|> decimal_data_value
|
||||
|
||||
hex_data_value :: Parser DataValue
|
||||
hex_data_value = do
|
||||
char '$'
|
||||
digits <- many hexDigit
|
||||
spaces
|
||||
let ((d, _):_) = readHex digits
|
||||
return (d :: DataValue)
|
||||
|
||||
decimal_data_value :: Parser DataValue
|
||||
decimal_data_value = do
|
||||
digits <- many digit
|
||||
spaces
|
||||
return (read digits :: DataValue)
|
||||
|
Loading…
Reference in New Issue
Block a user