Skip to content
Advertisement

Calling assembly routines from C source code

I have this simple C source code :

JavaScript

and i have this s.asm which defines the function _Sum :

JavaScript

now , i compiled the .asm using :

JavaScript

and compiled and linked the .c file using :

JavaScript

this is the outcome :

JavaScript

So what is the problem ?

I’m using Ubuntu-Linux

Any help would be greatly appreciated , Thanks

[SOLVED] : i checked with nm the test.o file and it expected to find the symbol ‘Sum’ not ‘_Sum’ so changing that solved the problem.

Advertisement

Answer

As far as I can see from your question, you overwrite your object file that came from the assembler s.o by the C program. So you don’t have the assembler routine any more.

You should probably write

Generate the s.o object file

JavaScript

Generate the test.o (your command created another s.o)

JavaScript

Link the app

JavaScript

(I chose testapp as output binary because test is often a very bad name for a program, it collides with the Unix command test)

Advertisement