I have simple ocaml file test.ml
1 + 2;;
I compiled it. can i see assembly output of this code? Maybe ocaml packet has any tools for this?
Thank you.
Yes you can: see below. Everything that remains from your code is movl $7, %eax
(7 is OCaml's representation for 3, which is the result of 1+2).
$ cat > t.ml
1 + 2 ;;
$ ocamlopt -S t.ml
$ cat t.s
.data
.globl _camlT__data_begin
_camlT__data_begin:
.text
.globl _camlT__code_begin
_camlT__code_begin:
nop
.data
.long 0
.globl _camlT
_camlT:
.text
.align 4
.globl _camlT__entry
_camlT__entry:
subl $12, %esp
L100:
movl $7, %eax
movl $1, %eax
addl $12, %esp
ret
.data
.text
nop
.globl _camlT__code_end
_camlT__code_end:
.data
.globl _camlT__data_end
_camlT__data_end:
.long 0
.globl _camlT__frametable
_camlT__frametable:
.long 0
.section __IMPORT,__pointers,non_lazy_symbol_pointers
.section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With