mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-10 08:30:38 +00:00
clc, cld, clv, sec, sed. no sev. but a veritable "demo"...!
This commit is contained in:
parent
421bf03f8a
commit
e268c550b5
@ -136,13 +136,13 @@ In these, `absolute` must be a `reserve`d or `locate`d address.
|
||||
|
||||
if bvs { block } else { block }
|
||||
|
||||
X clc
|
||||
clc
|
||||
|
||||
X cld
|
||||
cld
|
||||
|
||||
! cli
|
||||
|
||||
X clv
|
||||
clv
|
||||
|
||||
cmp absolute
|
||||
X cmp #immediate
|
||||
@ -210,9 +210,9 @@ In these, `absolute` must be a `reserve`d or `locate`d address.
|
||||
X sbc #immediate
|
||||
X sbc absolute
|
||||
|
||||
X sec
|
||||
sec
|
||||
|
||||
X sed
|
||||
sed
|
||||
|
||||
X sei { block }
|
||||
|
||||
@ -244,7 +244,7 @@ TODO
|
||||
* Work out the analyses again and document them
|
||||
* parse support immediate loads, compares
|
||||
* number ifs and repeats
|
||||
* hello, world sort of program
|
||||
* `repeat jmp`
|
||||
* Addressing modes; rename instructions to match
|
||||
|
||||
Tests
|
||||
@ -356,6 +356,11 @@ No duplicate declarations.
|
||||
| tya
|
||||
| sta screen
|
||||
| dec screen
|
||||
| clc
|
||||
| cld
|
||||
| clv
|
||||
| sec
|
||||
| sed
|
||||
| }
|
||||
= .org 0
|
||||
= .word $0801
|
||||
@ -384,6 +389,11 @@ No duplicate declarations.
|
||||
= tya
|
||||
= sta screen
|
||||
= dec screen
|
||||
= clc
|
||||
= cld
|
||||
= clv
|
||||
= sec
|
||||
= sed
|
||||
= rts
|
||||
|
||||
| assign word screen 4000
|
||||
|
@ -39,6 +39,12 @@ emitInstr p r (LOADIMM A val) = "lda #" ++ (show val)
|
||||
emitInstr p r (LOADIMM X val) = "ldx #" ++ (show val)
|
||||
emitInstr p r (LOADIMM Y val) = "ldy #" ++ (show val)
|
||||
|
||||
emitInstr p r (LOADIMM FlagC 0) = "clc"
|
||||
emitInstr p r (LOADIMM FlagD 0) = "cld"
|
||||
emitInstr p r (LOADIMM FlagV 0) = "clv"
|
||||
emitInstr p r (LOADIMM FlagC 1) = "sec"
|
||||
emitInstr p r (LOADIMM FlagD 1) = "sed"
|
||||
|
||||
emitInstr p r (COPY A (NamedLocation label)) = "sta " ++ label
|
||||
emitInstr p r (COPY X (NamedLocation label)) = "stx " ++ label
|
||||
emitInstr p r (COPY Y (NamedLocation label)) = "sty " ++ label
|
||||
|
@ -21,7 +21,8 @@ Command := "if" Branch Block "else" Block
|
||||
| "cmp" (LocationName | Immediate)
|
||||
| "cpx" (LocationName | Immediate)
|
||||
| "cpy" (LocationName | Immediate)
|
||||
| "inx" | "iny" | "dex" | "dey"
|
||||
| "inx" | "iny" | "dex" | "dey" | "inc" Location | "dec" Location
|
||||
| "clc" | "cld" | "clv" | "sec" | "sed"
|
||||
| "nop".
|
||||
Branch := "bcc" | "bcs" | "beq" | "bmi" | "bne" | "bpl" | "bvc" | "bvs".
|
||||
|
||||
@ -83,6 +84,7 @@ command = (try lda) <|> (try ldx) <|> (try ldy) <|>
|
||||
(try cmp) <|> (try cpx) <|> (try cpy) <|>
|
||||
(try inx) <|> (try iny) <|> (try dex) <|> (try dey) <|>
|
||||
(try inc) <|> (try dec) <|>
|
||||
(try clc) <|> (try cld) <|> (try clv) <|> (try sec) <|> (try sed) <|>
|
||||
if_statement <|> repeat_statement <|> nop
|
||||
|
||||
nop :: Parser Instruction
|
||||
@ -91,6 +93,36 @@ nop = do
|
||||
spaces
|
||||
return NOP
|
||||
|
||||
clc :: Parser Instruction
|
||||
clc = do
|
||||
string "clc"
|
||||
spaces
|
||||
return $ LOADIMM FlagC 0
|
||||
|
||||
cld :: Parser Instruction
|
||||
cld = do
|
||||
string "cld"
|
||||
spaces
|
||||
return $ LOADIMM FlagD 0
|
||||
|
||||
clv :: Parser Instruction
|
||||
clv = do
|
||||
string "clv"
|
||||
spaces
|
||||
return $ LOADIMM FlagV 0
|
||||
|
||||
sec :: Parser Instruction
|
||||
sec = do
|
||||
string "sec"
|
||||
spaces
|
||||
return $ LOADIMM FlagC 1
|
||||
|
||||
sed :: Parser Instruction
|
||||
sed = do
|
||||
string "sed"
|
||||
spaces
|
||||
return $ LOADIMM FlagD 1
|
||||
|
||||
inx :: Parser Instruction
|
||||
inx = do
|
||||
string "inx"
|
||||
|
Loading…
x
Reference in New Issue
Block a user