diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2018-04-15 10:19:08 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2018-04-15 10:19:08 +0200 |
commit | 2f7aa3f0ae524305b7c3e8ba06a5ed0d2ba70891 (patch) | |
tree | 201a681041120914132f1a00f989468e59bf92de /Main.hs | |
parent | 446871a1ae5b7adb48e108052e2a2e5afa8dfe30 (diff) |
Let generated code work with yasm on linux
Diffstat (limited to 'Main.hs')
-rw-r--r-- | Main.hs | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -4,6 +4,7 @@ import Control.Monad import Data.Char import System.Environment import System.Exit +import qualified System.Info as System (os) import System.Process import AST @@ -40,5 +41,11 @@ main = do interpret opt (map (fromIntegral . ord) input) >>= (putStr . map (chr . fromIntegral)) EMCompile -> do writeFile (fname ++ ".asm") $ compile opt - callProcess "yasm" ["-f", "macho64", fname ++ ".asm", "-o", fname ++ ".o"] + + let format = case System.os of + "darwin" -> "macho64" + "linux" -> "elf64" + _ -> undefined + + callProcess "yasm" ["-f", format, fname ++ ".asm", "-o", fname ++ ".o"] callProcess "gcc" [fname ++ ".o", "-o", fname ++ ".exe"] |