delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/01/28/11:01:06

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Inline assembly.
Date: 28 Jan 2002 15:48:36 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 34
Message-ID: <a33rsk$57l$1@nets3.rz.RWTH-Aachen.DE>
References: <fa9bfb1b9e164c8e7b3ecc848e67eadc DOT 62691 AT mygate DOT mailgate DOT org>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1012232916 5365 137.226.32.75 (28 Jan 2002 15:48:36 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 28 Jan 2002 15:48:36 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Joel Saunders <jbs30000 AT aol DOT com> wrote:

>         __asm__("
>                  movw My_Name, %si
>                  movw Screen_PTR, %di
>                  movw $7, %ecx
>                  movsb
> -[_]--------------------------- Message Window --------------------
>  Creating: nptest.exe
>  Error: nptest.o: In function `main':
>  nptest.cpp(6) Error: undefined reference to `My_Name'
>  Error: nptest.cpp(.text+0xd): undefined reference to `Screen_PTR'

> What did I do wrong?

1) You put your inline asm into a C++ program. Bad idea because
2) external names seen by the assembler are not exactly the same as
   C object names, and for C++ that's quite a lot worse again.
   Inspect gcc -S output to see what the C++ compiler actually used
   as the names of those objects.
3) You didn't use extended inline assembly. Would have saved you quite
   some grief here, if only because it knows about name mangling.
4) You didn't read enough of the documentation to know that a Screen_PTR,
   as defined by you, doesn't exist in protected mode programs.  You
   have to use a different selector in the ss register. 
5) You almost definitely want to use %esi and %edi, not %si and %di.

   



-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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