Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TASM & Turbo C++ 3.0

416 views
Skip to first unread message

Chad Helfenberger

unread,
Jun 22, 1995, 3:00:00 AM6/22/95
to
Sorry for such a simple question.. but I've racked my brains on this.
There is almost no support for Turbo C in the TASM 4.0 manual, which
leaves me without a clue. I am a very inexperienced 80x86 asm programmer
so I'd appreciate any info on this problem.

What I'm trying to do is interface some assembly routines to C (not C++).
here is a sample asm file I have tried to link with a c file..

test.asm
--------
.model small,c

public clear_screen

.code
clear_screen proc
;whatever I put here has NO bearing on the result
clear_screen endp
end

test.c
------
main() { clear_screen(); }

Now when I compile/assemble and link, it ALWAYS locks up. I used td
and traced through it, and it worked up until the closing } of test.c.

Please help.

--
--
quare


gcli...@ulkyvx.louisville.edu

unread,
Jun 23, 1995, 3:00:00 AM6/23/95
to
In article <DAK1C...@iglou.com>, qu...@iglou.iglou.com (Chad Helfenberger) writes:
> Sorry for such a simple question.. but I've racked my brains on this.
> There is almost no support for Turbo C in the TASM 4.0 manual, which
> leaves me without a clue. I am a very inexperienced 80x86 asm programmer
> so I'd appreciate any info on this problem.
>
> What I'm trying to do is interface some assembly routines to C (not C++).
> here is a sample asm file I have tried to link with a c file..
>
> test.asm
> --------
> .model small,c
>
> public clear_screen
>
> .code
> clear_screen proc
> ;whatever I put here has NO bearing on the result

Hi,

you'd better put a RET or it will hang


> clear_screen endp
> end
>
> test.c
> ------
> main() { clear_screen(); }
>
> Now when I compile/assemble and link, it ALWAYS locks up. I used td
> and traced through it, and it worked up until the closing } of test.c.
>
> Please help.

Also, make sure your compiler is compiling for the SMALL model since
that is what your assembler is doing. I think turbo C defaults to small
model so if you don't override it you are probably ok, but you just might
want to check. If you don't compile for the small model then the kind
of return the assembler generates will not be the kind of return the C
program expects to get... and it will hang. Oh you don't have docs;
in BC3.0 the model selection is one of the things somewhere under
the options menu. I imagine it's similar in TC3.0. There are several
models, it will probably say something like 'Memory Model' and then give you
a choice between 'tiny,small,medium,large,huge'. Make sure it's set
to small.

Also, Borland changed the format of object files between BC3.0 and BC4.0;
I imagine TASM V4.0 has the new style. i'm unclear whether this will
affect you with TASM output or not, but I know Borland recommended that
anyone with 3.0 libraries or executables written in C rebuild them
when they switched to 4.0. So if everything else fails you can always
blame it on your compiler and TASM being incompatible!

David
>
> --
> --
> quare
>

Wilson, Kevin

unread,
Jun 25, 1995, 3:00:00 AM6/25/95
to
In article <DAK1C...@iglou.com>, qu...@iglou.iglou.com says...


here is a sample asm file I have tried to link with a c file..

test.asm
--------
.model small,c

public clear_screen

.code
_clear_screen proc <- pretty simple fix I think!


;whatever I put here has NO bearing on the result

clear_screen endp
end

test.c
------
main() extern clear_screen(); <-I assume you did this or the function
wouldn't be called.
{ clear_screen(); }

>Now when I compile/assemble and link, it ALWAYS locks up. I used td
>and traced through it, and it worked up until the closing } of test.c.

Try just adding the underscore which is necessary with your compiler.
If I missed something I hope to stand corrected!?!?


phla...@mhv.net

unread,
Jun 28, 1995, 3:00:00 AM6/28/95
to
In <1995Jun23...@ulkyvx.louisville.edu>, gcli...@ulkyvx.louisville.edu writes:

>In article <DAK1C...@iglou.com>, qu...@iglou.iglou.com (Chad Helfenberger) writes:

>Also, Borland changed the format of object files between BC3.0 and BC4.0;
>I imagine TASM V4.0 has the new style. i'm unclear whether this will
>affect you with TASM output or not, but I know Borland recommended that
>anyone with 3.0 libraries or executables written in C rebuild them
>when they switched to 4.0. So if everything else fails you can always
>blame it on your compiler and TASM being incompatible!

well here is a question for ya...I have tc++ v3.0 for dos and I have tasm v4.0
tasm has tlink of it's own that Turbo Debugger only will understand the symbols from
but if i use tasm's tlink i get a dpmi stack error and it dumps out forcing me to use
the tlink that came with tc++ v3. Is there any way that I can use tasm's tlink to do
what I want? (this only happens in a makefile or from a tcc command line)

--Dave

Christopher HILL

unread,
Jun 29, 1995, 3:00:00 AM6/29/95
to
In article <3siob0$1...@news.nucleus.com>, Wilson, Kevin wrote:
>test.asm
>--------
>..model small,c

>public clear_screen

>..code


>_clear_screen proc <- pretty simple fix I think!
> ;whatever I put here has NO bearing on the result
>clear_screen endp
> end

>test.c
>------
>main() extern clear_screen(); <-I assume you did this or the function
> wouldn't be called.
> { clear_screen(); }

>>Now when I compile/assemble and link, it ALWAYS locks up. I used td
>>and traced through it, and it worked up until the closing } of test.c.
>
>Try just adding the underscore which is necessary with your compiler.
>If I missed something I hope to stand corrected!?!?

No, no, no, no, no!!! Look at the .MODEL statement. It has the C language
modifier which automatically adds the underscore. He has declared things
correctly in the .ASM file.

Sorry to get so upset about this, but I can't believe how many times I've
seen this same thing said in error, day after day.

The directive:

.MODEL <size>,C

automatically adds an underscore to all public symbols, and correctly
interperets the order of function parameters on the stack. Anyone linking
assembly language modules with a C language program, SHOULD use the
language modifier with the .MODEL directive. This makes the assembly
language programming a lot easier and catches a number of potential bugs
before they happen.

The following is an example of an assembly language file and a C language
file that will compile and link properly, and will run without error.

---------------------------------- testasm.asm
--------------------------------
.model small,c

public testfunc

.code

testfunc proc
ret
testfunc endp

end

--------------------------------------- test.c
---------------------------------
extern void testfunc(void);

int main(void)
{
testfunc();
return(0);
}

----------------------------------------------------------------------------
----

You can compile and link the two files with the following command:

bcc -ms -v test.c testasm.asm

The -ms switch compiles to small model, and the -v switch includes
debugging information.

NOTE: There are NO UNDERSCORES used in the function name in the assembly
language file.

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

Chad Helfenberger

unread,
Jun 29, 1995, 3:00:00 AM6/29/95
to
Wilson, Kevin (wils...@nucleus.com) wrote:
: In article <DAK1C...@iglou.com>, qu...@iglou.iglou.com says...

: Try just adding the underscore which is necessary with your compiler.


: If I missed something I hope to stand corrected!?!?

I fixed that problem.. it was because I was not linking in the init
code and the standard library.

I'm still having trouble with the two products. I wish Borland would
consider older users a little more. For example, I can't get td to
execute the startup code now.. leaving me to search for main() manually.

oh well.. i guess if you don't have big bucks to spend you can't really
complain.

--
--
quare


0 new messages