diff --git a/eg/call-routine.uampirnexol b/eg/call-routine.uampirnexol new file mode 100644 index 0000000..bfd8425 --- /dev/null +++ b/eg/call-routine.uampirnexol @@ -0,0 +1,4 @@ +let + bumpupx = routine (INX; INX; INX) +in + LDA# 40 ; TAX ; (call bumpupx) ; (call bumpupx) ; INX diff --git a/src/Main.hs b/src/Main.hs index e19f9a0..f6f245e 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -20,16 +20,20 @@ data Flags = Flags { typeCheck :: String, + debugExtraction :: Maybe String, outputPrg :: Maybe String } deriving (Show, Ord, Eq) defaultFlags = Flags{ typeCheck = "yes", + debugExtraction = Nothing, outputPrg = Nothing } parseFlags flags ("--type-check":s:rest) = parseFlags flags{ typeCheck = s } rest +parseFlags flags ("--debug-extraction":s:rest) = + parseFlags flags{ debugExtraction = Just s } rest parseFlags flags ("--output-prg":s:rest) = parseFlags flags{ outputPrg = Just s } rest parseFlags flags other = (flags, other) @@ -82,11 +86,17 @@ return $ extract program initialEEnv other -> abortWith $ "illegal option: --type-check: " ++ other - case outputPrg flags of + case debugExtraction flags of + Just "dump" -> + putStrLn $ show extracted + Just other -> + abortWith $ "illegal option: --debug-extraction: " ++ other Nothing -> - putStrLn $ hexDump $ serialize extracted "main" 0x0200 - Just filename -> - writeBinaryFile filename $ serialize extracted "main" 0x0200 + case outputPrg flags of + Nothing -> + putStrLn $ hexDump $ serialize extracted "main" 0x0200 + Just filename -> + writeBinaryFile filename $ serialize extracted "main" 0x0200 _ -> do abortWith $ "Usage: uampirnexol {flags} parse <filename>\n" ++ @@ -95,6 +105,7 @@ " uampirnexol {flags} extract <filename>\n" ++ " where {flags} can be:\n" ++ " --type-check yes|no (default yes)\n" ++ + " --debug-extraction dump\n" ++ " --output-prg <filename>"