Article View: borland.public.cppbuilder.language.basm
Article #35Re: integrating assembly and C++ Builder 6
From: Ed Mulroy [TeamB]
Date: Thu, 13 Sep 2007 19:10
Date: Thu, 13 Sep 2007 19:10
100 lines
4185 bytes
4185 bytes
In what you show you have PUBLIC _externproc The PUBLIC line is a
declaration that a symbol is to be placed into the public symbol table. It
is not a declaration of the symbol. I think _externproc should be a
procedure (a proc) in the code.
As an example, here is some assembly that does that. Unlike your code it
actually declares segments instead of using the "simplified" directives that
you seem to prefer. The comments about the symbols are not related to the
difference in segment declaration. They refer to the symbol WinMain.
----------------------------
.386p
model flat
HWND_DESKTOP equ 0
MB_OK equ 0
_TEXT segment dword public use32 'CODE'
_TEXT ends
_DATA segment dword public use32 'DATA'
_DATA ends
_BSS segment dword public use32 'BSS'
_BSS ends
; This program does not use _BSS, the unitialized global data segment,
; but is generally needed in programs so I've added it here
DGROUP group _BSS,_DATA
; declaration of Windows' ascii MessageBox function
; the linker will find a reference to it in the Windows import
library
extrn MessageBoxA :near
_DATA segment dword public use32 'DATA'
align 1
msg db " Hello World! ",0
mtitle db "Hello Message Box", 0
zero dw 0
align 4
_DATA ends
_TEXT segment dword public use32 'CODE'
WinMain proc near
push ebp ; save EBP register and load stack ptr into it
mov ebp,esp
; MessageBox(HWND_DESKTOP, msg, mtitle, MB_OK);
push MB_OK
push offset mtitle
push offset msg
push HWND_DESKTOP
call MessageBoxA
xor eax,eax ; return value is zero
pop ebp ; restore EBP register value
ret 16 ; free up 16 bytes of stack when returning
WinMain endp
_TEXT ends
public WinMain
end WinMain
----------------------------
. Ed
> Daniel wrote in message
> news:46e95c9e@newsgroups.borland.com...
>
> No, I don't use that in the assembly module. The assembly module
> is extremly
> simple:
> .386
> .model flat
> PUBLIC _externproc
> DATASEG
> ;one or two things here just to define something.
> ENDS DATA
> CODE
> mov eax, 05Ah; just to have something happen
> ENDS CODE
> END
>
> patterned after a previous post on this group. I created this file by
> choosing File->New->Assembly then adding it to the project. Although I can
> assemble it with the command-line assembler and add the object file to the
> Builder project, it doesn't make any difference whether the asm file or
> obj
> file is part of the project.
>
> Borland's documentation advises to use the same .model in the assembly
> module as the C++ program, but nowhere in Builder does it give any
> indication of what the model is. Nor can I find anything that says
> anything
> about what the COW32.obj file might be or do.
>
> Any help is much appreciated since I'm going nuts.
Technical Details
Message-ID:
<46e98b16@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!217.73.144.44.MISMATCH!ecngs!feeder.ecngs.de!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>Show Full Headers
Complete Article Headers
X-Google-Thread: 107b11,2b231382bcbeb5c2 X-Google-Attributes: gid107b11,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> Newsgroups: borland.public.cppbuilder.language.basm References: <46e947b4$1@newsgroups.borland.com> <ahiie31op322c33qt9t70a4jfu67mto5ih@4ax.com> <46e95c9e@newsgroups.borland.com> Subject: Re: integrating assembly and C++ Builder 6 Date: Thu, 13 Sep 2007 15:10:13 -0400 Lines: 102 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 69.142.254.168 Message-ID: <46e98b16@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1189710614 69.142.254.168 (13 Sep 2007 12:10:14 -0700) X-Authenticated-User: edmulroy Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!217.73.144.44.MISMATCH!ecngs!feeder.ecngs.de!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail