Linking masm obj's to Borland c++ 
Author Message
 Linking masm obj's to Borland c++

Greetings,

    I've been fiddling around with Borland C++ on the Uni machines
here and I've tried to link in some of my own MASM assembler code,
with no luck.  I have a few questions:

    Is it possible to link a MASM OBJ into Borland C in the first
place?
    How do you specify that you want to link in a certain OBJ?  in
MS Quick C I can do that from the command line, but Quick C sucks!
Do I have to build a library or something, if so what's the
definition of a library and do things get very messy indeed?  ;)
    Oh yes, and whilst I'm here ... how do you pass floating point
values into an assembly function?
    And another thing (...this could go on for a looonng time!), I
_hate_ having to have a separate BGI file for graphics! (one of the
reasons I want to link in my own MASM graphics routines)  Is there
any way you can link it straight into the code?

    Many thanks in advance,
Alex

+-------------------+---------------+
|>ThisEYE +-------+ | btf / Esponge | "Ooo-ooooARGHH"
|IsWatchi |       | |               |        - Bjork 1995
|ngYou.Yo |  (0)  | |  main coder,  |

|nLOGGED! +-------+ |   lazy git    |
+-------------------+---------------+



Sat, 29 Nov 1997 03:00:00 GMT  
 Linking masm obj's to Borland c++
To generate ASM objects to link with any C compiler, you have to

1) Set the 'case sensitive' or 'preserve case' flag, so that MASM
   doesn't uppercase everything. ('/ML' in optasm, don't remember MASM)

2) Add a leading _underscore to all externalized ASM functions and vars

--

// "But the sun is going down!"   "No, no, you're confused:
//  the horizon is moving up"   (Firesign Theatre)



Sat, 29 Nov 1997 03:00:00 GMT  
 Linking masm obj's to Borland c++

Quote:
>    Is it possible to link a MASM OBJ into Borland C in the first
>place?

As far as I know.

Quote:
>    How do you specify that you want to link in a certain OBJ?

Just list the filenames, i.e.,
tlink file1.obj file2.obj file3.obj,prog.exe,prog.map,lib1.lib lib2.lib lib3.lib

Quote:
>Do I have to build a library or something, if so what's the
>definition of a library and do things get very messy indeed?  ;)

You could (and if you're going to use a function a lot, you might want to) but
you don't need to.

Quote:
>    Oh yes, and whilst I'm here ... how do you pass floating point
>values into an assembly function?

The same way you pass other parameters.

Quote:
>    And another thing (...this could go on for a looonng time!), I
>_hate_ having to have a separate BGI file for graphics! (one of the
>reasons I want to link in my own MASM graphics routines)  Is there
>any way you can link it straight into the code?

Yes, but you need the manuals--fortunately I've got them sitting right next to
me...(pause)...and the manuals say to read the file UTIL.DOC (which is in the
\BC\DOCS subdirectory, I think) for information on BGIOBJ.EXE--you'll need to
run that, and use the function registerbgidriver() and link in the .OBJ file
created from the .BGI, but UTIL.DOC will give info on it.

Hope this helps.

Richard Cooley Extraordinaire --=*=-- Linux Linux Linux Linux Linux Linux Linux

       Daisemi'in rhhaensuriuu meillunsiateve rh'e Mnhei'sahe yie ahr'en:
         Mnahe afw'ein qiuu; rh'e hweithnaef mrht Heis'he ehl'ein qiuu.



Tue, 02 Dec 1997 03:00:00 GMT  
 Linking masm obj's to Borland c++


[snip]
Quote:
>    Is it possible to link a MASM OBJ into Borland C in the first
>place?

Yes, the Borland OBJ file format is sufficiently similar to the
Microsoft one that this'll work.
Well, saying that, it worked when I linked some code from MASM 5.1
to Turbo C++ 2, and Borland C++ 3
It was a long time ago, but I may have made a library and linked with
that.

Quote:
>    How do you specify that you want to link in a certain OBJ?  in
>MS Quick C I can do that from the command line, but Quick C sucks!
>Do I have to build a library or something, if so what's the
>definition of a library and do things get very messy indeed?  ;)

Well, with Microsoft, just type lib and answer the questions.  
Borland uses tlib (I think).
As far as using the library, I think you just add it to the project.

Quote:
>    Oh yes, and whilst I'm here ... how do you pass floating point
>values into an assembly function?

...with extreme difficulty - you have to use the maths copro stack,
or the emulator's equivalent.

Quote:
>    And another thing (...this could go on for a looonng time!), I
>_hate_ having to have a separate BGI file for graphics! (one of the
>reasons I want to link in my own MASM graphics routines)  Is there
>any way you can link it straight into the code?

Yes, read the manual.

--

http://www.dcs.warwick.ac.uk/~csusm
"Live moves on... I nearly caught it yesterday, though"



Fri, 05 Dec 1997 03:00:00 GMT  
 Linking masm obj's to Borland c++

Quote:

>>    Oh yes, and whilst I'm here ... how do you pass floating point
>>values into an assembly function?

>The same way you pass other parameters.

Actually, this varies between C/C++ compilers. Borland passes floating
point paramters on the FP stack, while Microsoft, I believe, passes a
pointer to a memory location. Other compilers may differ as well, this is a
pretty gray area.

Christopher Hill
Aiea, Hawai`i (O`ahu)



Fri, 05 Dec 1997 03:00:00 GMT  
 Linking masm obj's to Borland c++

Quote:

>>>    Oh yes, and whilst I'm here ... how do you pass floating point
>>>values into an assembly function?

>>The same way you pass other parameters.

> Actually, this varies between C/C++ compilers. Borland passes floating
> point paramters on the FP stack,

Borland Turbo Pascal ver 4 tried that, yes -- apparently it was no
good because in ver 5 they went back to pushing f.p. arguments on the
stack.  Borland/Turbo C and C++ has always passed f.p. arguments on
the normal 80x86 stack.

Quote:
> while Microsoft, I believe, passes a pointer to a memory location.

Bzzt -- wrong!  Microsoft too passed f.p. arguments on the stack.

It appears you're confusing passing arguments to a function with
returning function results.  Borland does indeed return f.p. function
results in ST(0) of the FPU (and in the emulated ST(0) if an FPU is
missing and the emulated FPU is running instead), while Microsoft
returns a pointer to memory where the f.p. result is stored.

Quote:
> Other compilers may differ as well, this is a pretty gray area.

In returning f.p. function results, yes.  Still another variety is
Zortech/Symantech C/C++, which returns f.p. results in the 80x86 CPU
registers (!): a float is returned in AX+BX, and a double in
AX+BX+CX+DX.  In the 32-bit memory models a float is returned in EAX
and a double in EAX+EBX.  Zortech/Symantech does not and never has
supported "long double" as 10-byte reals -- it treats "long double"
as a normal "double", as opposed to Borland and Microsoft which both
implements "long double" as 10-byte reals.

One reason Zortech/Symantech returns f.p. function results in this
weird way is that it enables them to, if the FPU is missing, make
the code in the FPU emulator re-entrant, in case you want to write
multi-threaded programs using f.p. arithmetic that should run on a
system without an FPU.

--
----------------------------------------------------------------
Paul Schlyter,  Swedish Amateur Astronomer's Society (SAAF)
Nybrogatan 75 A,  S-114 40 Stockholm,  SWEDEN



Sun, 07 Dec 1997 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Need help linking NASM .obj's to C++ obj's

2. Linking MF copiled obj's with Turbo C++ obj's

3. link MASM assembled obj files with BCC55 ones using borland ilink32

4. Help linking a (trivial) NASM object file (.obj) with Borland C++ 3.0

5. linking obj's with Borland TLINK

6. Link a MASM .obj file with a C .obj file

7. Linking C++ OBJ's

8. Linking MF copiled obj's with Turbo C++

9. Help: Linking .obj files from MS-Fortran and Borland C

10. Did somebody ever try link *.obj prolog with C (borland)

11. Using MASM or WASM with Borland C++

12. borland c++ 5.5 and masm

 

 
Powered by phpBB® Forum Software