
Hi all, I am working towards retargetable G-machine. As the first step towards this, I need to understand what G-code is generated by nhc for a specific haskell program. When I went through the options of compiler I didn't see any g-code output, instead what i saw was that I could get target machine code file which i don't want. Please let me know if someone has already done some sort of hacking so that g-code can be got or does nhc itself provides this support? Regards, -- Arun Kumar S Jadhav Masters Student, SIC-309, KReSIT, IIT-Bombay, India Ph: +91-22-25764967 http://www.it.iitb.ac.in/~arunk ***************************** Never negotiate out of fear Never fear to negotiate *****************************

Arun Kumar S Jadhav
I am working towards retargetable G-machine. As the first step towards this, I need to understand what G-code is generated by nhc for a specific haskell program. When I went through the options of compiler I didn't see any g-code output, instead what i saw was that I could get target machine code file which i don't want.
Use the -gcode option enclosed with +CTS -CTS brackets. e.g. $ cat hello.hs main = putStrLn "hello world" $ nhc98 -c hello.hs +CTS -gcode -CTS ====== G Code: STARTFUN 143(Main.main) NEEDSTACK 1 HEAP_VAP 146 (LAMBDA146) PUSH_HEAP HEAP_VAP 26 (Prelude.putStrLn) HEAP_OFF -2 RETURN_EVAL ====== G Code: STARTFUN 146(LAMBDA146) NEEDSTACK 1 PUSH_STRING "hello world" STRING RETURN_EVAL You can compare this with the final bytecode output produced in a .hc file by "nhc98 -C". Regards, Malcolm

Use the -gcode option enclosed with +CTS -CTS brackets. e.g.
$ cat hello.hs main = putStrLn "hello world" $ nhc98 -c hello.hs +CTS -gcode -CTS ====== G Code: STARTFUN 143(Main.main) NEEDSTACK 1 HEAP_VAP 146 (LAMBDA146) PUSH_HEAP HEAP_VAP 26 (Prelude.putStrLn) HEAP_OFF -2 RETURN_EVAL
====== G Code: STARTFUN 146(LAMBDA146) NEEDSTACK 1 PUSH_STRING "hello world" STRING RETURN_EVAL
You can compare this with the final bytecode output produced in a .hc file by "nhc98 -C".
Thanks a ton !! Btw it would really be great if I can get hold of semantics of "all" the g-instructions that are possibly produced by nhc. Regards, Arun

Arun Kumar S Jadhav
Thanks a ton !! Btw it would really be great if I can get hold of semantics of "all" the g-instructions that are possibly produced by nhc.
The G-code instructions used by the compiler are defined in src/compiler98/Gcode.hs Their semantics should be fairly obvious, especially if you have either of the Peyton Jones textbooks on implementing functional languages. Regards, Malcolm
participants (2)
-
Arun Kumar S Jadhav
-
Malcolm Wallace