sixty-five-oh-two/app/Main.hs

57 lines
1.2 KiB
Haskell
Raw Normal View History

2018-05-23 10:51:24 +00:00
module Main where
2018-05-26 09:00:40 +00:00
import DSL.SixtyFiveOhTwo
2018-05-24 09:09:54 +00:00
import Control.Monad.State
2018-05-25 08:40:25 +00:00
import qualified Data.ByteString as B
2018-05-26 08:54:52 +00:00
import Data.Int
2018-05-24 09:09:54 +00:00
2018-05-26 08:54:52 +00:00
test1 :: Instruction
test1 = do
lda (Immediate 0xFF)
sta (ZeroPage 0x00)
lda (Immediate 0x00)
adc (Immediate 0x01)
cmp (ZeroPage 0x00)
bne (Relative (-0x03 :: Int8))
test2f :: Instruction
test2f = do
2018-05-24 09:09:54 +00:00
lda (Immediate 0x10)
sta (Absolute 0x0200)
rts (Implied)
2018-05-26 08:54:52 +00:00
test2 :: Instruction
test2 = do
define "accumulatorLoadNStore" test2f
2018-05-24 09:09:54 +00:00
call "accumulatorLoadNStore"
2018-05-23 10:51:24 +00:00
2018-05-26 08:54:52 +00:00
test3f2 :: Instruction
test3f2 = replicateM_ 10 (inc (Accumulator))
test3f1 :: Instruction
test3f1 = do
lda (Immediate 0x02)
define "addIt" test3f2
test3 :: Instruction
test3 = do
define "loadIt" test3f1
call "loadIt"
call "addIt"
2018-05-23 10:51:24 +00:00
main :: IO ()
2018-05-26 08:54:52 +00:00
main = do
putStrLn "test one: simple program"
putStrLn "========================"
print $ execState test1 emptyState
putStrLn ""
putStrLn "test two: simple function"
putStrLn "========================="
print $ execState test2 emptyState
putStrLn ""
putStrLn "test two: nested function"
putStrLn "========================="
print $ execState test3 emptyState
putStrLn ""