[erlang-questions] compile:file

Andrew Kondratovich <>
Mon Aug 1 15:41:51 CEST 2011


Hi.
Docs says, that compile:file("m.erl", ['S']) produces a listing of the
assembler code in the file m.S.
Also, docs says, that compile:file("m.S", [asm]) compiles the code
from input file, which is expected to be assembler code.

So, these two steps identically to simple compile:file("m.erl").

But, why I can't to compile code from assembler, when it has
operations with floating points. For example:

============================================================
-module(m).
-compile(export_all).

do(A) ->
	A + 0.5.
============================================================

This code produces assembler code:
============================================================
{module, m}.  %% version = 0

{exports, [{do,1},{module_info,0},{module_info,1}]}.

{attributes, []}.

{labels, 7}.


{function, do, 1, 2}.
  {label,1}.
    {func_info,{atom,m},{atom,do},1}.
  {label,2}.
    {test_heap,{alloc,[{words,0},{floats,1}]},1}.
    {fconv,{x,0},{fr,0}}.
    {fmove,{float,0.5},{fr,1}}.
    fclearerror.
    {bif,fadd,{f,0},[{fr,0},{fr,1}],{fr,0}}.
    {fcheckerror,{f,0}}.
    {fmove,{fr,0},{x,0}}.
    return.


{function, module_info, 0, 4}.
  {label,3}.
    {func_info,{atom,m},{atom,module_info},0}.
  {label,4}.
    {move,{atom,m},{x,0}}.
    {call_ext_only,1,{extfunc,erlang,get_module_info,1}}.


{function, module_info, 1, 6}.
  {label,5}.
    {func_info,{atom,m},{atom,module_info},1}.
  {label,6}.
    {move,{x,0},{x,1}}.
    {move,{atom,m},{x,0}}.
    {call_ext_only,2,{extfunc,erlang,get_module_info,2}}.
============================================================

When I try to compile:
============================================================
40> compile:file("m.erl", ['S']).
{ok,m}
41> compile:file("m.S", [asm]).
Function: do/1
error
42>
============================================================

win xp
erl -version
Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 5.8.3

/Andrew



More information about the erlang-questions mailing list