Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fatal: 16 bit segments not supported in module TEST.ASM

Status
Not open for further replies.

CppMaster

Programmer
Apr 19, 2006
12
0
0
CA
I'm currently learning ASM and trying one of the code examples. I have no problem assembling, but when I get to linking, using TLINK32 on a computer running Windows XP with an Intel Pentium 3 processor, I get the following output:
Turbo Link Version 1.6.65.0 Copyright (c) 1993,1996 Borland International
Beta version built at 13:11:48 on Jan 4 1996
Fatal: 16 bit segments not supported in module TEST.ASM
The code in test.asm is:
Code:
		MODEL	small
		.STACK	64
		.DATA
DATA1	DB	52H
DATA2	DB	59H
SUM		DB	?

		.CODE
MAIN	PROC FAR
		MOV	AX, @DATA
		MOV DS, AX
		MOV AL, DATA1
		MOV BL, DATA2
		ADD AL, BL
		MOV SUM, AL
		MOV AH, 4CH
		INT 21H
MAIN	ENDP
		END	MAIN
What would be the problem and possible solution(s)? Thank you in advance for your help.

 
Just a guess, but is it saying that TLINK32 (a 32 bit linker) can't cope with the example, which looks remarkably like a 16 bit dos program...
 
If you use the model small, what is the same as tiny, you can't use segment definitions.

So the code MOV AX,@DATA is wrong, as it assumes that you are using a one segment program.
All the segment registers are set to the same page.

Succes, Tessa
 
If you use the model small, what is the same as tiny, you can't use segment definitions.

So the code MOV AX,@DATA is wrong, as it assumes that you are using a one segment program.
All the segment registers are set to the same page.

Succes, Tessa
I'm assuming you meant I should simply remove them, which would mean:
Code:
MODEL    small
        .STACK    64
        .DATA
DATA1    DB    52H
DATA2    DB    59H
SUM        DB    ?

        .CODE
MAIN    PROC FAR
        MOV AL, DATA1
        MOV BL, DATA2
        ADD AL, BL
        MOV SUM, AL
        MOV AH, 4CH
        INT 21H
MAIN    ENDP
        END    MAIN

I tried compiling it and I get the same result. I've also tried some example code belonging with TASM, for instance:
Code:
; Turbo Assembler example. Copyright (c) 1993 By Borland International, Inc.

; From the Turbo Assembler User's Guide - Getting started

.MODEL  SMALL
.STACK  100h
.DATA

TimePrompt              DB 'Is it after 12 noon (Y/N)?$'
GoodMorningMessage      DB  13,10,'Good morning, world!',13,10,'$'
GoodAfternoonMessage    DB  13,10,'Good afternoon, world!',13,10,'$'
DefaultMessage          DB  13,10,'Good day, world!',10,13,'$'

.CODE
start:
  ;mov     ax,@data
  ;mov     ds,ax                   ;set DS to point to the data segment
  mov     dx,OFFSET TimePrompt    ;point to the time prompt
  mov     ah,9                    ;DOS: print string
  int     21h                     ;display the time prompt
  mov     ah,1                    ;DOS: get character
  int     21h                     ;get a single-character response
  or      al,20h                  ;force character to lower case

  cmp     al,'y'                  ;typed Y for afternoon?
  je      IsAfternoon
  cmp     al,'n'                  ;typed N for morning?
  je      IsMorning

  mov     dx,OFFSET DefaultMessage            ;default greeting
  jmp     DisplayGreeting

IsAfternoon:
  mov     dx,OFFSET GoodAfternoonMessage      ;afternoon greeting
  jmp     DisplayGreeting

IsMorning:
  mov     dx,OFFSET GoodMorningMessage        ;before noon greeting

DisplayGreeting:
  mov     ah,9                    ;DOS: print string
  int     21h                     ;display the appropriate greeting
  mov     ah,4ch                  ;DOS: terminate program
  mov     al,0                    ;return code will be 0
  int     21h                     ;terminate the program

END start
Did not work either, with or without the segment assignment lines.
 
Code:
         MODEL    small
        .STACK    64
        .DATA
DATA1    DB    52H
DATA2    DB    59H
SUM        DB    ?

        .CODE
MAIN    PROC FAR
        MOV AL, DATA1
        MOV BL, DATA2
        ADD AL, BL
        MOV SUM, AL
        MOV AH, 4CH
        INT 21H
MAIN    ENDP
        END    MAIN

I ment all references!

So FAR go's out .DATA go's out .STACK go's out, then you
get a realy tiny or small model.

Since it is much easier to use the MEDIUM model, that let 
you use FAR procedures and you can use all the extra's
to, I recommend using:

 .MODEL MEDIUM

and start your main code with:

Main proc near (or far, when using medium)
     .startup

     your code

     .exit   ( this is what the mov ah and the int 
               replaces.)

Now your code is DOS style and musk work.

If not, there is something wrong in the linking, that mide
produce 32 bit loadable code that is allways asumed to be
window stile, but with the missing start and end code
that has to go with it.

Succes, Tessa
 
p.s I read a bit back in the post and sow that you are
using a 32 bit linker.
Thats the main error in your handling the code.
Just use Link or any other 16 bit real mode linker and
your error will not pop up again.

In 32 bit mode (called the protected mode) segment registers are not handled any more like in the 16 bit real mode.
The difference is to great to explain in a few lines.

Succes, Tessa
 
First off, I assembled and linked your code ; no problems whatsoever.

There is a switch in older versions of TASM that changes the object code tell the asembler to use either 16 bit segments or 32 bit flat code; these are USE16 and USE32. Try putting a USE16 at the top of your ASm file and see if this doesnt fix the problem

The simplest solution is the best!
 
Okay, found the problem. You are trying to use a 32 bit linker with a 16 bit assembler. If you want to build a 16 bit program, you need to use Tlink, not Tlink32. if you want to build a 32 bit program, you need to use TASM32 to assemble the asm file. Mixing TASM with with Tlink32 will produce the error you noted above. I am assuming that you have both 16 and 32 bit versions of both programs installed. They both should have come with your install package. The program you have written above is a 16 bit program so use tasm and tlink. This will get'er done


The simplest solution is the best!
 
Hoorah!

We've sorted it...

Or not, if the OP doesn't have a 16 bit linker... :eek:)
 
Then trow it out of the window.

Look for the police first athorwise you get a fine.

Tessa

p.s. You can allmost allways run a linker on a os.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top