mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-12-01 01:51:33 +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
|
TODO
|
||||||
----
|
----
|
||||||
|
|
||||||
* Parse HEX values like $40A3
|
* comments
|
||||||
* Initial values for reserved, incl. tables
|
* Initial values for reserved, incl. tables
|
||||||
|
* give length for tables, must be there for reserved
|
||||||
* Character tables ("strings" to everybody else)
|
* Character tables ("strings" to everybody else)
|
||||||
* Work out the analyses again and document them
|
* 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
|
* Addressing modes; rename instructions to match
|
||||||
|
|
||||||
Tests
|
Tests
|
||||||
@ -441,7 +442,7 @@ We cannot absolute-indexed a word.
|
|||||||
| routine main {
|
| routine main {
|
||||||
| lda #4
|
| lda #4
|
||||||
| ldx #0
|
| ldx #0
|
||||||
| ldy #255
|
| ldy #$FF
|
||||||
| lda screen
|
| lda screen
|
||||||
| lda screen, x
|
| lda screen, x
|
||||||
| lda screen, y
|
| lda screen, y
|
||||||
@ -530,7 +531,7 @@ We cannot absolute-indexed a word.
|
|||||||
= score: .word 0
|
= score: .word 0
|
||||||
= .alias screen 1024
|
= .alias screen 1024
|
||||||
|
|
||||||
| assign word screen 1024
|
| assign word screen $0400
|
||||||
| routine main {
|
| routine main {
|
||||||
| lda screen
|
| lda screen
|
||||||
| cmp screen
|
| cmp screen
|
||||||
|
@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
module SixtyPical.Parser (parseProgram) where
|
module SixtyPical.Parser (parseProgram) where
|
||||||
|
|
||||||
import SixtyPical.Model
|
import Numeric (readHex)
|
||||||
|
|
||||||
import Text.ParserCombinators.Parsec
|
import Text.ParserCombinators.Parsec
|
||||||
|
|
||||||
|
import SixtyPical.Model
|
||||||
|
|
||||||
{-
|
{-
|
||||||
|
|
||||||
Toplevel := {Decl} {Routine}.
|
Toplevel := {Decl} {Routine}.
|
||||||
@ -420,14 +423,34 @@ locationName = do
|
|||||||
spaces
|
spaces
|
||||||
return (c:cs)
|
return (c:cs)
|
||||||
|
|
||||||
address :: Parser Address
|
address = hex_address <|> decimal_address
|
||||||
address = do
|
|
||||||
|
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
|
digits <- many digit
|
||||||
spaces
|
spaces
|
||||||
return (read digits :: Address)
|
return (read digits :: Address)
|
||||||
|
|
||||||
data_value :: Parser DataValue
|
data_value = hex_data_value <|> decimal_data_value
|
||||||
data_value = do
|
|
||||||
|
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
|
digits <- many digit
|
||||||
spaces
|
spaces
|
||||||
return (read digits :: DataValue)
|
return (read digits :: DataValue)
|
||||||
|
Loading…
Reference in New Issue
Block a user