X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: Hans-Bernhard Broeker 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: References: 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 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.