BORLAND TURBO ASSEMBLER v3.1 & TURBO LINK v5.1
General Information
Borland Turbo Assembler v3.1 is a multi-pass
assembler. It has features such as forward referencing, MASM compatibility, and
an Ideal mode. Turbo Assembler (tasm) is a command-line
assembler that produces object files (.obj) from your assembly
source code (.asm). Then, you use the Borland Turbo Link v5.1
to link the object files into an executable file (.exe). This
version of tasm can generate machine instructions for 8086, 80186, 80286, and
80386 processors as well as 8087, 80287, and 80387 numeric
coprocessors.
Turbo Assembler may also be used to interface with other
languages. Programs written in Borland C, Turbo C++, and Turbo Pascal can be
combined with programs written in Turbo Assembler. For complete details on this
procedure, please see the User's Manual.
Getting Started
Before you can assemble your programs you must first write them using a text
editor. On the PC, this includes programs such as DOS Edit (edit), wordpad, or UEdit. You can use
either of these programs to create and edit your source files (with an
.asm extension).
Once your program has been written and
saved as a text file, you are ready to assemble and link it. Following is a
brief desciption of how to assemble and link a program. A more thorough
explanation of the assembler and linker will follow.
To call the Turbo Assembler, you may first invoke NTVDM (using the "cmd.exe").
Then, simply type:
l:\bc31\bin\tasm filename
where
filename is the name of your source file to be assembled (assume the current directory). Turbo
Assembler will then ask which options you wish. Pressing <ENTER> will
accept the default filename. If no errors were produced then you can call Turbo
Link by typing the following:
l:\bc31\bin\tlink filename
where
filename is the name of your source file. You can then choose
which files to generate and what names they will use. If no linker errors were
found, you will be able to run the executable file.
Using Turbo Assembler
To get a list of all the command line options,
simply enter the command tasm with no filename specified. With
the command line options, you can specify the filename of multiple programs to
be assembled as well as various options. To assemble more than one file,
separate the filenames with a semicolon. Each file can have its own options
specified before its respective filename. You can also use the DOS wildcard
characters (* and ?) to specify a list of files to assemble.
The comma
can be used to accept the default filenames from the command line. After the
filename, tasm expects the name to use for the
.obj, the .lst, and then the
.xrf files. Specifying a filename of nul will
tell tasm not to generate that specific file. For example, the
command:
l:\bc31\bin\tasm reverse,,prog1,nul
will assemble the
file reverse.asm and produce the object file
reverse.obj, the listing file prog1.lst, and
will not produce a cross reference file.
For a complete list of the
command line options and their meanings, please see the Borland Turbo Assembler
User's Guide.
Ideal Mode
Turbo Assembler offers a directive called IDEAL mode. This
mode is useful for beginning assembly programmers because it is cleaner and
easier to understand. It also assembles faster than MASM mode. Ideal mode offers
a new syntax for expressions and instruction operands. It is, however, similar
to MASM syntax so as not to be too confusing.
Using Turbo Link
Once the program has been assembled, you will need to
link the various .obj files into an executable file. To do this,
you will need to use Turbo Link. To link your file, simply
type:
l:\bc31\bin\tlink filename
where
filename is the name of your .obj
file.
Running tlink without specifying any
options will display a help screen. Any options should be specified before the
filename. After the filename, you can specify all other .obj
files to be linked together. After the list of .obj files, you
can specify the name of the .exe, the name of the
.map, and a list of libraries to be linked into the program.
Each option should be separated by a comma. For example, the
command:
l:\bc31\bin\tlink /c reverse prog2,,,lib\bri
will
link the files reverse.obj and prog2.obj into a
file reverse.obj and create a map file
reverse.map and using the supporting library
lib\bri.lib. The /c option specifies that the
.obj file is case sensitive.
Helpful Hints
· Beginner programmers might find Ideal mode easier and
more straight forward for writing their assembly programs. It is closer to
programming in a higher level language than MASM mode.
· The DOS
operating system does not protect itself. Therefore, it is very possible to
write programs that accidentally or intentionally overwrite the operating
system, which may freeze or lock up your computer (i.e., your computer does not
respond to the keyboard). When this happens, you will need to reboot the
computer.
Examples
The following are example Turbo Assembler programs.
Example 1
.MODEL small
.STACK 100h
.DATA
Message DB ‘Hello, there!’,13,10,’$’
.CODE
mov ax,@data
mov ds,ax ;set DS to point to the data segment
mov ah,9 ;DOS print string function
mov dx,OFFSET Message ;point to “Hello, there!”
int 21h ;display “Hello, there!”
mov ah,4ch ;DOS terminate program function
int 21h ;terminate the program
END
Example 2
.MODEL small
.STACK 100h
.DATA
TimePrompt DB 'Is it after 12 noon (Y/N):$'
MorningMessage LABEL BYTE
DB 13,10,'Good morning!',13,10,'$'
AfternoonMessage LABEL BYTE
DB 13,10,'Good afternoon!',13,10,'$'
.CODE
mov ax,@data
mov ds,ax ;set DS to point to data segment
mov dx,OFFSET TimePrompt ;point to the time prompt
mov ah,9 ;DOS print string function #
int 21h ;display the time prompt
mov ah,1 ;DOS get character function #
int 21h ;get a single-character response
cmp al,'y' ;typed lowercase y for after noon?
jz IsAfternoon ;yes, it's after noon
cmp al,'Y' ;typed uppercase Y for after noon?
jnz IsMorning ;no, it's before noon
IsAfternoon:
mov dx,OFFSET AfternoonMessage ;point to the afternoon
;greeting
jmp DisplayGreeting
IsMorning:
mov dx,OFFSET MorningMessage ;point to the before noon
;greeting
DisplayGreeting:
mov ah,9 ;DOS print string function #
int 21h ;display the appropriate greeting
mov ah,4ch ;DOS terminate program function #
int 21h ;terminate the program
END
Common Problems & Solutions
Q. When I try to assemble my program, I
get an error message that it can’t find my file. What’s wrong?
A. If you
specify no filename extension when you are assembling your program, by default
Turbo Assembler will look for that filename with a .asm
extension. If your program has no extension or a different one, change it to
.asm and try again.
References/Manuals
Borland Turbo Assembler v3.1 User’s
Guide
Borland Turbo Link v5.1 User’s
Guide