c and asm

Programming, for all ages and all languages.
Post Reply
ChrisSkura
Member
Member
Posts: 33
Joined: Sat Nov 07, 2009 2:47 am

c and asm

Post by ChrisSkura »

I've been writing my OS in asm but since I've been working with c/c++ for 4 years I wanted to try using asm and c together. When I compile my c program it compiles fine and so does my asm program but when I go to link them with the .ld file I get a couple of errors.

c.c

Code: Select all

extern void _kmain();

void _kmain()
{
}
asm.asm

Code: Select all

global loader
extern _kmain

loader:

    mov ah, 00
    mov al, 12h
    int 10h

    call _kmain

end:

    jmp $
    times 510 - ($ - $$) db 0
    
    dw 0xAA55
linker.ld

Code: Select all

ENTRY (loader)
I've tried all of the tutorials on the wiki but none of them worked.
when I try to link them, I get:

ld: warning: cannot find entry symbol loader; defaulting to 00000000
c\asm.o: In function `loader':
c\asm.asm:(.text+0xd): undefined reference to `_kmain'
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: c and asm

Post by Combuster »

"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply