Anyone have suggestions regarding the form for assembley code files used
with Borland's version C compiler? The code below, assembled by masm6, doesn't
satisfy the linker (Borland's).
The segment names are a guess for the most part - taken from masm6's
accrued examples on other projects. "cs:DGROUP" appears off but, if the error
is due to segment names, maybe someone here knows suitable names?
The code & bat file & error messages are included below.
Hul
*********************************************************
; wedtst.asm
name SUPP32 ; ???
.386p
public _wedtst
; Segments & groups
DGROUP group _TEXT
_TEXT segment
assume cs:DGROUP,ds:DGROUP
_wedtst proc ; awk (WORD gdtsize, DWORD flataddr) void public
push bp ;save bp
mov bp,sp ; -> stack frame
mov eax, 66
pop bp ;restore bp
ret
_wedtst endp
_TEXT ends
end
******** bat file
SET BC55PATH=C:\BOR5
%BC55PATH%\bin\bcc32 -c -tW -a4 -g20 -I.. -I%BC55PATH%\include windil.c >
compout.txt
rem %BC55PATH%\bin\brc32 -i%BC55PATH%\include windil.rc >> compout.txt
%BC55PATH%\bin\ilink32 -L%BC55PATH%\lib -c -aa -Tpe c0w32+windil+wedtst,windil,
NULL,import32.lib+cw32.lib,, >> compout.txt
type compout.txt | more
******* compout.txt
C:\bor5\wed>SET BC55PATH=C:\BOR5
C:\bor5\wed>C:\BOR5\bin\bcc32 -c -tW -a4 -g20 -I.. -IC:\BOR5\include windil.c
1>compout.txt
C:\bor5\wed>C:\BOR5\bin\ilink32 -LC:\BOR5\lib -c -aa -Tpe c0w32+windil+wedtst,
windil,NULL,import32.lib+cw32.lib,, 1>>compout.txt
C:\bor5\wed>type compout.txt | more
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
WINDIL.C:
Warning W8057 WINDIL.C 48: Parameter 'hPrevinstance' is never used in function
WinMain
Warning W8057 WINDIL.C 48: Parameter 'szCmdLine' is never used in function
WinMain
Warning W8065 WINDIL.C 200: Call to function 'pooi' with no prototype in
function WndProc
Warning W8065 WINDIL.C 262: Call to function 'iitoaa' with no prototype in
function pooi
Warning W8070 WINDIL.C 265: Function should return a value in function pooi
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '_wedtst' referenced from C:\BOR5\WED\WINDIL.OBJ
>comp.arch.embedded
>Assembly code with Borland's C compiler
>
> Anyone have suggestions regarding the form for assembley code files used
>with Borland's version C compiler? The code below, assembled by masm6, doesn't
>satisfy the linker (Borland's).
> The segment names are a guess for the most part - taken from masm6's
>accrued examples on other projects. "cs:DGROUP" appears off but, if the error
>is due to segment names, maybe someone here knows suitable names?
> The code & bat file & error messages are included below.
It's been ages since I fiddled with X86 assembly but this might help.
For "Borland C++ 5.5.1" (the version with BCB5), and running
"bcc32 -S hello.c" on
---
#include <stdio.h>
main()
{
puts("Hello, world!");
return 0;
}
---
we get "hello.asm" as
---
.386p
ifdef ??version
if ??version GT 500H
.mmx
endif
endif
model flat
ifndef ??version
?debug macro
endm
endif
?debug S "hello.c"
?debug T "hello.c"
_TEXT segment dword public use32 'CODE'
_TEXT ends
_DATA segment dword public use32 'DATA'
_DATA ends
_BSS segment dword public use32 'BSS'
_BSS ends
DGROUP group _BSS,_DATA
_TEXT segment dword public use32 'CODE'
_main proc near
?live1@0:
;
; main()
;
push ebp
mov ebp,esp
;
; {
; puts("Hello, world!");
;
@1:
push offset s@
call _puts
pop ecx
;
; return 0;
;
xor eax,eax
;
; }
;
@3:
@2:
pop ebp
ret
_main endp
_TEXT ends
_DATA segment dword public use32 'DATA'
s@ label byte
; s@+0:
db "Hello, world!",0
align 4
_DATA ends
_TEXT segment dword public use32 'CODE'
_TEXT ends
public _main
extrn _puts:near
?debug D "C:\Program Files\Borland\CBuilder5\Include\_nfile.h"
10303 10240
?debug D "C:\Program Files\Borland\CBuilder5\Include\_null.h"
10303 10240
?debug D "C:\Program Files\Borland\CBuilder5\Include\_defs.h"
10303 10240
?debug D "C:\Program Files\Borland\CBuilder5\Include\_stddef.h"
10303 10240
?debug D "C:\Program Files\Borland\CBuilder5\Include\stdio.h"
10303 10240
?debug D "hello.c" 14050 28522
end
---
--
Rich Webb Norfolk, VA
>comp.arch.embedded
>Assembly code with Borland's C compiler
>
> Anyone have suggestions regarding the form for assembley code files used
>with Borland's version C compiler? The code below, assembled by masm6, doesn't
>satisfy the linker (Borland's).
> The segment names are a guess for the most part - taken from masm6's
>accrued examples on other projects. "cs:DGROUP" appears off but, if the error
>is due to segment names, maybe someone here knows suitable names?
> The code & bat file & error messages are included below.
>
>Hul
I don't have time right now to dig into this. But could you post the
error messages? The exact details of those you are getting?
I gather from the above you are using a Microsoft assembler's output
and linking it together with the output from a Borland c compiler
using the Borland linker. Another thing to keep in mind is that the
records placed in the OBJ file (aside from naming issues you above
suggest) might be somewhat different -- in short, the Borland linker
may not recognize every record in the output of the Microsoft
assembler. Though it may. I just don't know. The error messages may
help to disambiguate here.
Jon
>comp.arch.embedded
Unless I have missed something, this will generate a 16-bit object,
and it looks like the c code (from below) is 32-bit. That generally
don't work.
Try something more like:
.386
.model flat
.code
_wedtst proc ; awk (WORD gdtsize, DWORD flataddr) void public
push bp ;save bp
mov bp,sp ; -> stack frame
mov eax, 66
pop bp ;restore bp
ret
_wedtst endp
end
--
ArarghMail912 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html
To reply by email, remove the extra stuff from the reply address.
> comp.arch.embedded
> Assembly code with Borland's C compiler
>
> Anyone have suggestions regarding the form for assembley code files
> used
> with Borland's version C compiler? The code below, assembled by masm6,
> doesn't satisfy the linker (Borland's).
> The segment names are a guess for the most part - taken from masm6's
> accrued examples on other projects. "cs:DGROUP" appears off but, if the
> error is due to segment names, maybe someone here knows suitable names?
> The code & bat file & error messages are included below.
>
-- snip --
If I'm working with a tool chain that supports compiling to assembly I
cheat. I write a framework file in C and compile to assembly, then find
the insides of the functions and start writing code.
It may not be manly, but it works just fine.
><snip>
>I don't have time right now to dig into this. But could you post the
>error messages? The exact details of those you are getting?
Hehe. Cripes. In my rush to dash off a reply I didn't read the
"mess" I saw below the OP's post. My fault. I'll look, later.
Jon
Anyone have suggestions regarding the form for assembley code files used
with Borland's version C compiler? The code below, assembled by masm6, doesn't
satisfy the linker (Borland's).
The segment names are a guess for the most part - taken from masm6's
accrued examples on other projects. "cs:DGROUP" appears off but, if the error
is due to segment names, maybe someone here knows suitable names?
The code & bat file & error messages are included below.
Hul
*********************************************************
; wedtst.asm
name SUPP32 ; ???
.386p
public _wedtst
; Segments & groups
DGROUP group _TEXT
_TEXT segment
assume cs:DGROUP,ds:DGROUP
_wedtst proc ; awk (WORD gdtsize, DWORD flataddr) void public
push bp ;save bp
mov bp,sp ; -> stack frame
mov eax, 66
pop bp ;restore bp
ret
_wedtst endp
_TEXT ends
end
******** bat file
Hul
Hul
Hul
Hul
>I'll give it a try & see what happens.
And DON'T use '/coff' on the command line. You should get 32-bit OMF
files, which is what I think the Borland linker expects. Never used
Borland products, so don't really know.
<snip>
I always recommended that method. Particularly when people wanted in
line assembly or a small amount of assembly in a C program.
write an empty c function call, with all the parameters, compile to
assembler and out the body in by hand.
This sorts out all the parameter passing and you can call it with a
standard C include file. Much more efficient.
Of course at one time all compilers went to assembly code Then you
assembled and linked. Actually even the compilers tended to be 3 pass
affairs. Now it is a single pass to object code ...
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Chris H wrote:
> In message <xaudnWLLO9McMqrW...@web-ster.com>, Tim Wescott
> <t...@seemywebsite.com> writes
>
>>If I'm working with a tool chain that supports compiling to assembly I
>>cheat. I write a framework file in C and compile to assembly, then find
>>the insides of the functions and start writing code.
>>
>>It may not be manly, but it works just fine.
>
>
> I always recommended that method. Particularly when people wanted in
> line assembly or a small amount of assembly in a C program.
>
> write an empty c function call, with all the parameters, compile to
> assembler and out the body in by hand.
The simple and stupid way for passing parameters between C and assembler
is by global variables. It is trivial, it is portable, and independent
from possible changes in the calling agreements of the future versions
of the same toolset. The aesthetes can implement some sort of locking or
roll their own stack to ensure atomic access to globals.
Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
http://www.abvolt.com
What embedded target is this for?
X86 AFAIK Borland only did compilers for X86
I don't recall having a single problem with calling agreements breaking
down with toolset version. That doesn't seem to be something that
changes often -- and I've always been in an environment where we bind a
software version to a toolset version, and treat a toolset upgrade as
major.
It's certainly a dire thing when the agreement does change, though.
I thought that until recently - but apparently they did others too. We
had a request the other day for some other CPU. Although I forget which
it was exactly I think it was an old Motorola thing, maybe 68K?
Maybe this has already been written here as I have not read the whole
thread, but Borland C 5.5 I think is now (legitimately) free. Paradigm
have their own version that is still updated and supported. OpenWatcom
have some nice alternative solutions too (not Borland based).
--
Regards,
Richard.
+ http://www.FreeRTOS.org
Designed for Microcontrollers. More than 7000 downloads per month.
+ http://www.SafeRTOS.com
Certified by T�V as meeting the requirements for safety related systems.
You might want to dig around on our download page..
http://www.jkmicro.com/downloads/downloads.html
I know that FC.ZIP
http://www.jkmicro.com/downloads/zip/fc.zip
implements an interrupt-driven frequency counter
in asm along with a Borland host environment.
That would be Pascal. Borland did do some Pascal stuff in the beginning
(this is from memory but it was decades ago) hence their Delphi was
based on Pascal.
>Maybe this has already been written here as I have not read the whole
>thread, but Borland C 5.5 I think is now (legitimately) free.
I believe the Borland x86 C and C++ compilers are available on free
download.
Hul
Hul
More working with Borland's compiler: trying to link 2 .obj files generated
by Borland's compiler without any errors indicated, untill the .exe is
executed. Then windows pops a window saying, roughly, this application has
generated an error and we are closing the application - an error log is being
created.
Anyone know where Microsoft hides their error logs?
Hul
It depends. On some architectures, fetching a few values from parameter
registers is a lot easier than constructing a global variable address in
an address register and dereferencing that.
The best way is, of course, to use GNU-style asm operand constraints.
Stefan
CPU type is fairly obvious. Not what I meant.
Is the OP targeting some kind of DOS like target, bare-metal (Phar
Lap like target) or some kind of Win32 based target?
To me it sounds like he may be trying to target something Win32
based and needs to contact the specific vendor. Most people don't mix
Microsoft and Borland for DOS or bare metal targets.
Is this an embedded target?
What OS ?
This is an embedded news group.
There are literally hundreds of thousands
of embedded DOS computers out there. I know,
I built a few tens of thousands of them...
Apart from that the 386 was quite widely used in embedded work. There
was a specific embedded version AFAIr. Whilst not as common as some MCU
the x86 family was used in embedded work with and without a DOS & BIOS
Where x86 was used for embedded work the Borland compiler tended to be
the compiler of choice. I have a rom kit for the Borland compilers if
anyone is interested.
The 80186(&8)EA/B/C series were used in embedded applications with the
Borland compiler, requiring a very small BSP to furnish BIOS compatibility.
Nigel Roles (of York University) did much of the groundwork.