EmbeddedRelated.com
Forums

Assembly code with Borland's C compiler

Started by Hul Tytus December 27, 2009
On Sun, 27 Dec 2009 23:57:30 +0000 (UTC), dbr@kbrx.com wrote:

>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> -- 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.
In message <xaudnWLLO9McMqrWnZ2dnUVZ_tJi4p2d@web-ster.com>, Tim Wescott
<tim@seemywebsite.com> writes
>On Sun, 27 Dec 2009 17:23:59 +0000, Hul Tytus wrote: > >> 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.
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 <xaudnWLLO9McMqrWnZ2dnUVZ_tJi4p2d@web-ster.com>, Tim Wescott > <tim@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
On Dec 27, 10:23=A0am, Hul Tytus <h...@panix.com> wrote:
> comp.arch.embedded > Assembly code with Borland's C compiler > > =A0 =A0Anyone have suggestions regarding the form for assembley code file=
s used
> with Borland's version C compiler?
What embedded target is this for?
In message <d6b5e078-9226-4f28-9f2d-db945618abe7@o28g2000yqh.googlegroup
s.com>, Marco <prenom_nomus@yahoo.com> writes
>On Dec 27, 10:23&#4294967295;am, Hul Tytus <h...@panix.com> wrote: >> comp.arch.embedded >> Assembly code with Borland's C compiler >> >> &#4294967295; &#4294967295;Anyone have suggestions regarding the form for assembley code files used >> with Borland's version C compiler? > > What embedded target is this for?
X86 AFAIK Borland only did compilers for X86 -- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
On Mon, 28 Dec 2009 09:02:58 -0600, Vladimir Vassilevsky wrote:

> Chris H wrote: > >> In message <xaudnWLLO9McMqrWnZ2dnUVZ_tJi4p2d@web-ster.com>, Tim Wescott >> <tim@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.
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. -- www.wescottdesign.com
Chris H wrote:
> In message <d6b5e078-9226-4f28-9f2d-db945618abe7@o28g2000yqh.googlegroup > s.com>, Marco <prenom_nomus@yahoo.com> writes >> On Dec 27, 10:23 am, Hul Tytus <h...@panix.com> wrote: >>> 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? >> What embedded target is this for? > > X86 AFAIK Borland only did compilers for X86
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&#4294967295;V as meeting the requirements for safety related systems.
In message <hhar7v$jbt$1@news.eternal-september.org>, FreeRTOS info
<noemail@given.com> writes
>Chris H wrote: >> In message <d6b5e078-9226-4f28-9f2d-db945618abe7@o28g2000yqh.googlegroup >> s.com>, Marco <prenom_nomus@yahoo.com> writes >>> On Dec 27, 10:23 am, Hul Tytus <h...@panix.com> wrote: >>>> 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? >>> What embedded target is this for? >> >> X86 AFAIK Borland only did compilers for X86 > >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?
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. -- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Thanks Chris. I'll follow your suggestion.

Hul

Chris H <chris@phaedsys.org> wrote:
> In message <xaudnWLLO9McMqrWnZ2dnUVZ_tJi4p2d@web-ster.com>, Tim Wescott > <tim@seemywebsite.com> writes > >On Sun, 27 Dec 2009 17:23:59 +0000, Hul Tytus wrote: > > > >> 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.
> 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 /\/\/\/\/ > \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Vladimir Vassilevsky wrote:
> Chris H wrote: >> 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 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