1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-11-25 23:49:17 +00:00

Character tables. Emit tables properly.

This commit is contained in:
Cat's Eye Technologies 2014-04-12 13:55:08 +01:00
parent 7a3b3b1b25
commit ad1e159317
5 changed files with 29 additions and 3 deletions

View File

@ -211,7 +211,6 @@ it probably won't.)
TODO
----
* Character tables ("strings" to everybody else)
* Addressing modes — indexed mode on more instructions
* Rename and lift temporaries in nested blocks
* Tail-recursion optimization

View File

@ -211,6 +211,22 @@ Reserving and assigning byte tables.
= .space frequencies 16
= .alias screen 1024
Reserving things with initial values.
| reserve byte lives : 3
| reserve word screen : $0400
| reserve byte[8] frequencies : (0 1 2 4 5 8 9 10)
| reserve byte[13] message : "Hello, world!"
| routine main {
| }
= main:
= rts
=
= lives: .byte 3
= screen: .word 1024
= frequencies: .byte 0, 1, 2, 4, 5, 8, 9, 10
= message: .byte 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33
Temporary storage, in the form of block-local declarations. Note that these
temporaries are not unioned yet, but they could be.

View File

@ -1,3 +1,5 @@
.charmap 'A, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26
.charmap 'a, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26
.org 0
.word $0801
.data

View File

@ -37,7 +37,8 @@ emitDecl p (Reserve name (ByteTable size) vals) =
name ++ ": .byte " ++ (showList vals)
where
showList [] = ""
showList (val:vals) = (show val) ++ " " ++ (showList vals)
showList [val] = show val
showList (val:vals) = (show val) ++ ", " ++ (showList vals)
emitDecl p (Reserve name typ [])
| typ == Byte = ".space " ++ name ++ " 1"

View File

@ -3,6 +3,7 @@
module SixtyPical.Parser (parseProgram) where
import Numeric (readHex)
import Data.Char (ord)
import Text.ParserCombinators.Parsec
@ -115,7 +116,7 @@ storage_type = (try $ byte_table) <|> (storage "byte" Byte) <|>
initial_value :: Parser [DataValue]
initial_value =
data_value_list <|> single_literal_data_value
data_value_list <|> string_literal <|> single_literal_data_value
where
single_literal_data_value = do
a <- literal_data_value
@ -648,6 +649,13 @@ decimal_literal = do
nspaces
return $ read digits
string_literal :: Parser [DataValue]
string_literal = do
char '"'
s <- manyTill anyChar (char '"')
nspaces
return $ map (\c -> ord c) s
-- -- -- driver -- -- --
parseProgram = parse toplevel ""