[nhc-users] G-Code generated by nhc

Malcolm Wallace Malcolm.Wallace@cs.york.ac.uk
Fri, 1 Aug 2003 11:18:04 +0100


Arun Kumar S Jadhav <arunk@it.iitb.ac.in> writes:

> 	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