summaryrefslogtreecommitdiff
path: root/Main.hs
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2018-04-15 10:19:08 +0200
committerTom Smeding <tom.smeding@gmail.com>2018-04-15 10:19:08 +0200
commit2f7aa3f0ae524305b7c3e8ba06a5ed0d2ba70891 (patch)
tree201a681041120914132f1a00f989468e59bf92de /Main.hs
parent446871a1ae5b7adb48e108052e2a2e5afa8dfe30 (diff)
Let generated code work with yasm on linux
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/Main.hs b/Main.hs
index 9c33f83..c7ca464 100644
--- a/Main.hs
+++ b/Main.hs
@@ -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"]