delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/15/07:58:43

From: "Chaos" <chengin AT alpha DOT net DOT pl>
Newsgroups: comp.os.msdos.djgpp
Subject: NASM & GCC. Not very good friends?
Lines: 60
Organization: Chaos Engine
X-Newsreader: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.1
X-Original-NNTP-Posting-Host: pc124.warszawa.ppp.tpnet.pl
Message-ID: <391fe374@news.vogel.pl>
X-Original-Trace: 15 May 2000 13:45:56 +0200, pc124.warszawa.ppp.tpnet.pl
Date: Mon, 15 May 2000 11:50:01 GMT
NNTP-Posting-Host: 195.116.104.13
X-Complaints-To: abuse AT tpsa DOT pl
X-Trace: news.tpnet.pl 958391401 195.116.104.13 (Mon, 15 May 2000 13:50:01 MET DST)
NNTP-Posting-Date: Mon, 15 May 2000 13:50:01 MET DST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I've tried to include some code written in assembler to my C code in DJGPP.
So reasonable, for someone who isn't familiar with that AT&T crazy syntax,
was to use NASM. So I did. Compilation asm code with NASM, like with gcc
wasn't a problem. They started when I tried to link those object files. Here
are the sources:
-------------------
// Kaszana.c :

#include<stdio.h>
extern unsigned int AddFour(unsigned int);
int main(void)
{
    unsigned int var;
    var=AddFour(4);
    printf("AddFour(4) = %i\n", var);
    return 0;
}
---------------------
;Syf.asm :

[BITS 32]
[GLOBAL _AddFour__FUi]
[SECTION .text]
; --------------------------------------------------------------------------
-
; Prototype: unsigned int AddFour(unsigned int x);
; Returns: x + 4
; --------------------------------------------------------------------------
-
x_AddFour       equ 8
_AddFour__FUi:
    push ebp
    mov ebp, esp

    mov eax, [ebp + x_AddFour]
    add eax, 4

    mov esp, ebp
    pop ebp
    ret
---------------------
Compilation command for gcc was: gcc -c Kaszana.c
NASM was fed with: nasm -f coff Syf.asm
Linking: gcc Kaszana.o Syf.o -o Kaszana.exe

The last command is always ending with:

D:\C\Kaszana>gcc Kaszana.o Syf.o -o Kaszana.exe
Kaszana.o(.text+0x1d):Kaszana.c: undefined reference to `AddFour'

All these source files were taken from "Interfacing DJGPP with
Assembly-Language Procedures" writtenby Matthew Mastracci. I supose that
code is good part, so what can it be what causes erorrs?

Take care.
-=| Chaos |=-
e-mail:  chengin AT alpha DOT net DOT pl
              chengin AT polbox DOT com


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019