www.digitalmars.com         C & C++   DMDScript  

D - function call from assembly

reply Manfred Hansen <manfred toppoint.de> writes:
Hello

i try to call a function from an assembly program.













        .section .data
        .section .text
        .globl _start

  _start:

        call prin
        






The D programm

void prin() {
        /* printf("Hallo"); */
        int i = 3;
}

Compile with:
dmd -c print.c
gcc -s -c d_function.s
gcc  -nostdlib  d_function.o print.o  -lgcc -o d_function
c_function.o(.text+0x1): In function `_start':
: undefined reference to `prin'
collect2: ld returned 1 exit status

Maybe someone have an idea, or a better example.

Manfred
                
Mar 05 2004
parent reply "Ben Hinkle" <bhinkle4 juno.com> writes:
My only suggestion is add "extern (C)"

extern (C)
void prin() {
        /* printf("Hallo"); */
        int i = 3;
}
Mar 05 2004
parent Manfred Hansen <manfred toppoint.de> writes:
Ben Hinkle wrote:

 My only suggestion is add "extern (C)"
 
 extern (C)
 void prin() {
         /* printf("Hallo"); */
         int i = 3;
 }
It looks good. There are no error message anymore. In the evening or tommorow i will try this in my real proramm. Thank you. Manfred
Mar 05 2004