[comp.sys.ibm.pc] External variables using Microsoft C and MASM

pad3563@ultb.UUCP (P.A. Deupree ) (10/27/88)

I've recently been trying to figure out how to interface between Microsoft C
and Microsoft Macro Assembler and I'm having a few problems.  To start off,
I'm using C 5.0 and MASM 5.0 (I think that's the number, but in any case it's
the version that has the 286 commands in it).

I've written stuff and gotten it to successfully link up as far as external
function and procedure calls go.  The C program can find the assembly procedures
and the Assembly program can find the C procedures.  Here's where the problem is
It won't accept my externally defined variables.  I defined them all as EXTRN
in the assembly program and gave them _ in front.  However, I'm still getting
tons of linker messages saying they are undefined and I can't figure it.

Oh yeah, I got the C program to accept a value that I defined in my Assembly
program just fine also (course, I havn't been able to run it and see if it
is REALLY accepting things).  The linker doesn't cough on them.  Just the 
darn C to ASM values.

While I'm at it I may as well bring up another one.  Has anyone successfully
written something to field interrupts from the Logitech Bus Mouse?  I've got
one and found the interrupt vector listed in the instruction manual (is that a
miracle or what?) but it didn't work out.  Course, I could just be a bonehead
that didn't set up my ISR correctly (those addresses are tricky).

Any help would be greatly appreciated since I've been noodling over this one
for about a week.
-- 
Patrick A. Deupree				Bitnet: PAD3563@RITVAX.BITNET
						UUCP: pxd3563@ultb.UUCP
"I have great faith in fools.  Self confidence my friends call it."
						Edgar Allen Poe 

hollen@spot.megatek.uucp (Dion Hollenbeck) (11/02/88)

From article <142@ultb.UUCP>, by pad3563@ultb.UUCP (P.A. Deupree ):
> I've recently been trying to figure out how to interface between Microsoft C
> and Microsoft Macro Assembler and I'm having a few problems.  
    [.....stuff deleted....]
> It won't accept my externally defined variables.  I defined them all as EXTRN
> in the assembly program and gave them _ in front.  However, I'm still getting
> tons of linker messages saying they are undefined and I can't figure it.
> 
This seems to be your problem, do not use the '_' in front.  While it is true
that the complier prepends a '_' in front of all functions, it does not do
this for variables.  This should solve your problem.

	Dion Hollenbeck             (619) 455-5590 x2814
	Megatek Corporation, 9645 Scranton Road, San Diego, CA  92121

                                seismo!s3sun!megatek!hollen
                                ames!scubed/

mbrands@idca.tds.PHILIPS.nl (Manfred Brands) (11/03/88)

In article <142@ultb.UUCP>, pad3563@ultb.UUCP (P.A. Deupree ) writes:
> I've recently been trying to figure out how to interface between Microsoft C
> and Microsoft Macro Assembler and I'm having a few problems.
> 	[stuff deleted]
> 
> I've written stuff and gotten it to successfully link up as far as external
> function and procedure calls go. The C program can find the assembly procedures
> and the Assembly program can find the C procedures.  
> 
> 	[stuff deleted]

I have tried to reach you by email, but the mail was returned to me, 
so I'll post it here.

In reply to your article in comp.sys.ibm.pc:

To access external routines from assembler in C you have to declare them as
PUBLIC (e.g.  PUBLIC _AsmRoutine). To use C routines in ASM it is sufficient
to declare them as EXTRN (they must not be static in C of course).

Besides that MASM is NOT case sensitive by default (C is). MASM converts all
input to UPPER CASE. To make MASM case sensitive, use the /Mx option.

This should solve your first problem.

P.S. I have no experience with mice.


Manfred Brands
Philips Apeldoorn.