mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-01-10 02:29:23 +00:00
Explicit with
syntax.
This commit is contained in:
parent
c8ddbd8edf
commit
9a0896c90f
@ -131,4 +131,3 @@ TODO
|
||||
* `outputs` on externals
|
||||
* Routine is a kind of StorageLocation? (Location)?
|
||||
* remove DELTA -> ADD/SUB (requires carry be notated on ADD and SUB though)
|
||||
* explicit `with` syntax
|
||||
|
@ -105,7 +105,7 @@ Installing an interrupt handler (at the Kernal level, i.e. with CINV)
|
||||
| reserve vector save_cinv
|
||||
|
|
||||
| routine main {
|
||||
| sei {
|
||||
| with sei {
|
||||
| copy cinv save_cinv
|
||||
| copy routine our_cinv to cinv
|
||||
| }
|
||||
|
@ -297,9 +297,9 @@ Big test for parsing and emitting instructions.
|
||||
= .alias table 1024
|
||||
|
||||
| routine main {
|
||||
| pha {
|
||||
| sei {
|
||||
| php {
|
||||
| with pha {
|
||||
| with sei {
|
||||
| with php {
|
||||
| lda #0
|
||||
| }
|
||||
| lda #1
|
||||
|
@ -3,7 +3,7 @@ assign vector cinv 788
|
||||
reserve vector save_cinv
|
||||
|
||||
routine main {
|
||||
sei {
|
||||
with sei {
|
||||
copy cinv save_cinv
|
||||
copy routine our_cinv to cinv
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ routine main {
|
||||
sta vic_bg
|
||||
jsr reset_position
|
||||
jsr clear_screen
|
||||
sei {
|
||||
with sei {
|
||||
copy cinv save_cinv
|
||||
copy routine our_cinv to cinv
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ routine main {
|
||||
sta vic_bg
|
||||
jsr reset_position
|
||||
jsr clear_screen
|
||||
sei {
|
||||
with sei {
|
||||
copy cinv save_cinv
|
||||
copy routine our_cinv to cinv
|
||||
}
|
||||
|
@ -73,9 +73,7 @@ analyzeProgram program@(Program decls routines) =
|
||||
routCtx
|
||||
|
||||
-- TODO -- THESE ARE WEAK --
|
||||
checkInstr nm (SEI blk) progCtx routCtx =
|
||||
checkBlock nm blk progCtx routCtx
|
||||
checkInstr nm (PUSH _ blk) progCtx routCtx =
|
||||
checkInstr nm (WITH _ blk) progCtx routCtx =
|
||||
checkBlock nm blk progCtx routCtx
|
||||
|
||||
checkInstr nm (BIT dst) progCtx routCtx =
|
||||
|
@ -134,10 +134,10 @@ fillOutNamedLocationTypes p@(Program decls routines) =
|
||||
REPEAT iid branch (mapBlock xform blk)
|
||||
xform (DELTA dest val) =
|
||||
DELTA (resolve dest) val
|
||||
xform (SEI blk) =
|
||||
SEI (mapBlock xform blk)
|
||||
xform (PUSH val blk) =
|
||||
PUSH (resolve val) (mapBlock xform blk)
|
||||
xform (WITH SEI blk) =
|
||||
WITH SEI (mapBlock xform blk)
|
||||
xform (WITH (PUSH val) blk) =
|
||||
WITH (PUSH (resolve val)) (mapBlock xform blk)
|
||||
xform (COPYROUTINE name dest) =
|
||||
COPYROUTINE name (resolve dest)
|
||||
xform other =
|
||||
|
@ -169,17 +169,17 @@ emitInstr p r (REPEAT iid branch blk) =
|
||||
emitInstrs p r blk ++
|
||||
" " ++ (show branch) ++ " _repeat_" ++ (show iid)
|
||||
|
||||
emitInstr p r (SEI blk) =
|
||||
emitInstr p r (WITH SEI blk) =
|
||||
"sei\n" ++
|
||||
emitInstrs p r blk ++
|
||||
" cli"
|
||||
|
||||
emitInstr p r (PUSH A blk) =
|
||||
emitInstr p r (WITH (PUSH A) blk) =
|
||||
"pha\n" ++
|
||||
emitInstrs p r blk ++
|
||||
" pla"
|
||||
|
||||
emitInstr p r (PUSH AllFlags blk) =
|
||||
emitInstr p r (WITH (PUSH AllFlags) blk) =
|
||||
"php\n" ++
|
||||
emitInstrs p r blk ++
|
||||
" plp"
|
||||
|
@ -56,6 +56,10 @@ type RoutineName = String
|
||||
data Branch = BCC | BCS | BEQ | BMI | BNE | BPL | BVC | BVS
|
||||
deriving (Show, Ord, Eq)
|
||||
|
||||
data WithInstruction = SEI
|
||||
| PUSH StorageLocation
|
||||
deriving (Show, Ord, Eq)
|
||||
|
||||
data Instruction = COPY StorageLocation StorageLocation
|
||||
| CMP StorageLocation StorageLocation
|
||||
| ADD StorageLocation StorageLocation
|
||||
@ -72,8 +76,7 @@ data Instruction = COPY StorageLocation StorageLocation
|
||||
| IF InternalID Branch [Instruction] [Instruction]
|
||||
| REPEAT InternalID Branch [Instruction]
|
||||
| DELTA StorageLocation DataValue
|
||||
| SEI [Instruction]
|
||||
| PUSH StorageLocation [Instruction]
|
||||
| WITH WithInstruction [Instruction]
|
||||
| COPYROUTINE RoutineName StorageLocation
|
||||
| NOP
|
||||
deriving (Show, Ord, Eq)
|
||||
|
@ -27,7 +27,7 @@ Command := "if" Branch Block "else" Block
|
||||
| "cpy" (LocationName | Immediate)
|
||||
| "inx" | "iny" | "dex" | "dey" | "inc" Location | "dec" Location
|
||||
| "clc" | "cld" | "clv" | "sec" | "sed"
|
||||
| "sei" Block | "pha" Block | "php" Block
|
||||
| "with ("sei" | "pha" | "php") Block
|
||||
| "jmp" LocationName
|
||||
| "jsr" RoutineName
|
||||
| "nop".
|
||||
@ -226,8 +226,8 @@ command = (try lda) <|>
|
||||
(try sbc) <|> (try ora) <|>
|
||||
(try asl) <|> (try bit) <|> (try eor) <|> (try lsr) <|>
|
||||
(try rol) <|> (try ror) <|>
|
||||
(try sei) <|> (try pha) <|> (try php) <|>
|
||||
(try jmp) <|> (try jsr) <|>
|
||||
(try with_block) <|>
|
||||
(try copy_routine_statement) <|>
|
||||
(try copy_general_statement) <|>
|
||||
if_statement <|> repeat_statement <|> nop
|
||||
@ -477,26 +477,32 @@ tay = do
|
||||
nspaces
|
||||
return (COPY A Y)
|
||||
|
||||
sei :: Parser Instruction
|
||||
with_block :: Parser Instruction
|
||||
with_block = do
|
||||
string "with"
|
||||
nspaces
|
||||
instr <- (try sei) <|> (try pha) <|> php
|
||||
blk <- block
|
||||
return (WITH instr blk)
|
||||
|
||||
|
||||
sei :: Parser WithInstruction
|
||||
sei = do
|
||||
string "sei"
|
||||
nspaces
|
||||
blk <- block
|
||||
return (SEI blk)
|
||||
return SEI
|
||||
|
||||
pha :: Parser Instruction
|
||||
pha :: Parser WithInstruction
|
||||
pha = do
|
||||
string "pha"
|
||||
nspaces
|
||||
blk <- block
|
||||
return (PUSH A blk)
|
||||
return (PUSH A)
|
||||
|
||||
php :: Parser Instruction
|
||||
php :: Parser WithInstruction
|
||||
php = do
|
||||
string "php"
|
||||
nspaces
|
||||
blk <- block
|
||||
return (PUSH AllFlags blk)
|
||||
return (PUSH AllFlags)
|
||||
|
||||
jmp :: Parser Instruction
|
||||
jmp = do
|
||||
|
Loading…
x
Reference in New Issue
Block a user