Article View: borland.public.cppbuilder.language.basm
Article #37Re: integrating assembly and C++ Builder 6
From: Daniel deLesdernier
Date: Fri, 14 Sep 2007 14:17
Date: Fri, 14 Sep 2007 14:17
76 lines
3871 bytes
3871 bytes
You are already clearing up a few questions, for which I thank you.
The asm code currently reads thusly:
.386p
PUBLIC _externproc
DATASEG
_asmNum DD 0505Ah;just to see if this works
ENDS _DATA
CODESEG
start:
_externproc PROC
mov as, 05h
ret
-externproc ENDP
ENDS _TEXT
END start
This is an asm file in a Builder Project that has a single, default form,
with an edit box and one event handler:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int num1=78;
int num2=0;
char *myChar[1];
Form1->Edit1->Text="6";
asm mov eax,num1
asm mov eax, 0Ah
asm mov num2,eax
asm mov eax,0FFh
asm mov myChar, eax
asm mov eax,myChar
asm mov num2,eax
externproc();
Form1->Edit1->Text=num2;
}
Also before the C++ code I declare externproc with
extern "C" void externproc();
Again, the program isn't meant to do much yet; I'm trying to figure out how
to structure things first.
This version actually compiles, links, and runs!!! But why?
Now, before I had a start: directive just before _externproc Proc and an
ENDS start at the very end and I was getting the error ("publicInfoTable
defined in both module externproc.obj and C0W32.obj). Is this possibly
because the start: directive was inserting a bunch of startup stuff into the
obj file that Builder automatically inserts in an application from the
C0W32.obj file when it links and builds the application?
Also, PUBLIC _externproc is necessary, I think, to get the linker to find
the function implementation since it is not in the cpp file. What is it you
said about the PUBLIC directive putting something in a symbol table? What's
a symbol table?
You mentioned in an earlier post about declaring segments with the
simplified directives which I might prefer. I don't really care; I'm
struggling to get something working without adequate documentation. It is
frustrating to have Borland's web site suggest books that are out of date or
out of print. Even Mastering Turbo Assembler is only of limited help because
none of the example code compiles and runs (it seems to all be 16-bit? and
all Builder 6 gives you is tasm32). So before you can learn anything from
the examples you have to learn a lot of other stuff just to get the examples
to run (which I haven't been able to do yet). But I digress. Are there
advantages to not using the simplified directives? Perhaps it allows you to
put code and data in muliple places in your source file (in a way that makes
sense to you) and then have the linker put everything together in computer
memory whereas using the simplified directives forces you to type in all
your data and code in either the CODESEG or DATASEG? Can you use CODESEG and
DATASEG multiple times in a source file?
Thanks,
Daniel deLesdernier
Technical Details
Message-ID:
<46ea9813$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!62.111.101.3.MISMATCH!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<46e947b4$1@newsgroups.borland.com> <ahiie31op322c33qt9t70a4jfu67mto5ih@4ax.com> <46e95c9e@newsgroups.borland.com> <qtpje3p3bnck4pe0dl2u97llhglenkm52a@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 107b11,2b231382bcbeb5c2 X-Google-Attributes: gid107b11,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Daniel deLesdernier" <ddel@bete.com> From: "Daniel deLesdernier" <ddel@bete.com> Newsgroups: borland.public.cppbuilder.language.basm References: <46e947b4$1@newsgroups.borland.com> <ahiie31op322c33qt9t70a4jfu67mto5ih@4ax.com> <46e95c9e@newsgroups.borland.com> <qtpje3p3bnck4pe0dl2u97llhglenkm52a@4ax.com> Subject: Re: integrating assembly and C++ Builder 6 Date: Fri, 14 Sep 2007 10:17:56 -0400 Lines: 78 Organization: Bete X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 64.179.88.204 Message-ID: <46ea9813$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1189779475 64.179.88.204 (14 Sep 2007 07:17:55 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!62.111.101.3.MISMATCH!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail