[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Wrapping assembly into C files.

Hi Julian (and everyone else listening).

I compiled your nasm files and disassembled them with 'objdump' under
Linux, and wrapped the resulting Gnu assembly into a C file. It is long
and ugly, but it compiles with regular gcc like a normal .c file. This
will make it easier to include into ATLAS, since we won't have to include
.o files.

The beta=0 and beta=1 cases works fine, but I cannot get the beta=X case
to work. It seems to me that you copy the value of beta to a local
variable with "fstpl 0x40" and "fldl 0x40" (in nasm "fstp qword [0x40]"
and  "fld qword [0x40]").

Where is this "beta" kept in memory? What place does the "0x40" address
refer to?

I have tried to reconstruct the behavoiur with some c code by allocating a
local variable, but I have not had any success. Does anyone have an idea
of how to solve this problem?

I have attached your transformed code. If you define PBETA in the top, it
will try to always use the beta value from the parameter list, and if
PBETA is not defined it uses the same code as yours. In that case it will
compile to exactly the same machine instructions (except for two nop
instructions in the very end), but the headers/tables in the generated
object file will differ, and cause the code to segfault. I have no
experience in looking at .o files, so I don't know how to fix the headers
(and how to do it in C).

The code attached works for beta=0 and beta=1.

I hope someone can help with the small, but very irritating problem.