www.digitalmars.com         C & C++   DMDScript  

c++.dos.32-bits - Linking with external asm

reply "Gisle Vanem" <giva bgnett.no> writes:
I'm having problems linking with external assembly modules. It looks as if
external assembly routines are never called despite being called from C.
I'm using the latest compiler 8.29.5 and Borland's tasm v.3.2.

Here is a minimal 32-bit program that illustrates the problem.

C-code:-(test.c)---------------------------------------------------------------------------------------

#include <stdio.h>
int main (void)
{
  extern int val;
  extern void foo (int);

  val = 10;
  printf ("val = %d\n", val);

  foo (11);
  printf ("val = %d\n", val);
  return (0);
}

asm-code---(test1.asm)--------------------------------------------------------------------------
.386
.MODEL FLAT,C
.DATA
      public val
      val dd 0

.CODE
public foo
foo:
      mov eax, [esp+4]
      mov val, eax
      ret
end

bat-file ---(test.bat)-----------------------------------------------------------------------------------
tasm /mx test1.asm
dmc -g -mx test.c test1.obj x32.lib

-------------------------

the printout is:
  val = 10
  val = 10

But I would expect
  val = 10
  val = 11

What is the problem?  

Gisle V.
Jul 09 2002
parent reply "Gisle Vanem" <giva bgnett.no> writes:
"Gisle Vanem" <giva bgnett.no> wrote in message news:...
 I'm having problems linking with external assembly modules. It looks as if
 external assembly routines are never called despite being called from C.
 I'm using the latest compiler 8.29.5 and Borland's tasm v.3.2.
 ..
 .MODEL FLAT,C
Bummer, I changed this to ".MODEL SMALL,C" and everything works now. Gisle V.
Jul 09 2002
parent "Walter" <walter digitalmars.com> writes:
"Gisle Vanem" <giva bgnett.no> wrote in message
news:ageqv1$2so8$1 digitaldaemon.com...
 "Gisle Vanem" <giva bgnett.no> wrote in message news:...
 I'm having problems linking with external assembly modules. It looks as
if
 external assembly routines are never called despite being called from C.
 I'm using the latest compiler 8.29.5 and Borland's tasm v.3.2.
 ..
 .MODEL FLAT,C
Bummer, I changed this to ".MODEL SMALL,C" and everything works now.
The DOSX memory model has 3 separate segments, and so is not flat.
Jul 09 2002