Board index » delphi » Using Borland C++ 5.02 IDE w/TASM

Using Borland C++ 5.02 IDE w/TASM

Borland IDE does compile assembly programs.  But when I try to link, I get
an error message "Fatal: Unsupported 16-bit segment(s) in module
c:\bc5\wb\hello.asm" with 32-bit windows console option.  When I switch to
16-bit standard dos, I get this error "(1, 1) undefined symbol _main in
module c0.asm".  I am guessing that IDE is trying to use BASM which is a
integrated assembler.  In compiling, I see that program is being transfered
to TASM32 and TASM respectively.  The problem might be in linker.  TASM 5.0
is installed top of the BC++ 5.02 just like README file says.  I compiled
and linked same program using command line compiler (both TASM, TASM32 and
TLINK, TLINK32).  It produced exe file w/o problems.  Borland says TASM 5.0
is designed to be used with BCC++ 5.02.  I do not know what I have to do to
use TASM from IDE.  If anybody had the same problem, please reply.  Here is
the simple "Hello world!" program.

title Hello World Program     (hello.asm)

; This program displays "Hello, world!"
.model small
.stack 100h
.data
message db "Hello, world!",0dh,0ah,'$'

.code
main proc
   mov   ax,@data
   mov   ds,ax

   mov   ah,9
   mov   dx,offset message
   int   21h

   mov   ax,4C00h
   int   21h
main endp
end main

--
Osman K Eroktay
okerok...@aaahawk.com

 

Re:Using Borland C++ 5.02 IDE w/TASM


"Osman K Eroktay" <okerok...@aaahawk.com> wrote:

Quote
>Borland IDE does compile assembly programs.  But when I try to link, I get
>an error message "Fatal: Unsupported 16-bit segment(s) in module
>c:\bc5\wb\hello.asm" with 32-bit windows console option.

You probably should post questions like this in borland.public.tasm

Yep, that's a 16 bit DOS app, and won't work as a 32-bit windows
console.

Quote
>  When I switch to
>16-bit standard dos, I get this error "(1, 1) undefined symbol _main in
>module c0.asm".

Yep, you have a main, but no _main.  Change your proc to _main and it
will work.

Re:Using Borland C++ 5.02 IDE w/TASM


The program that you show is a 16 bit DOS program and the error messages are
correct.

It cannot be used as a 32 bit program because it uses small model which not
compatible with the flat model used in the 32 bit world, because it uses a
256 byte stack when Win32 programs use a minimum of a 2 Meg stack, it does a
DOS call to end the program and Win32 programs do not use DOS, it specifies
a starting point which conflicts with the starting point created by the
compiler startup code and the entry point the startup code is supposed to
call is not declared public so cannot be seen by the startup code.

It is incompatible with a 16 bit DOS program created by the compiler because
the startup point still conflicts, setting the stack conflicts with the
startup code setting the stack, it does a DOS call to end the program,
conflicting with the compiler's code doing cleanup, error checking and
ending the program and the function that the startup code calls is not a
public symbol.

If you want to do it all with the assembler then do it all with the
assembler.  If you want to use the compiler then use it.  Decide which you
are going to use.  You cannot do both in the same assembly source file.
Either write a program which uses the compiler's startup code and libraries
or assemble it with tasm/tasm32 and link it yourself.

If your program were called hello.asm then the commands to create the
executable without the compiler would be:

tasm hello
tlink hello

If you want your program to be able to be used in a 16 bit DOS program by
the compiler, get rid of setting up the stack, get rid of the int 21H
function 4C00H end the program call, either specify the language as C or
change main to _main and declare main (or _main, whichever) as public.

.  Ed

Other Threads