Uploaded by popeded623

INTRODUCTION TO TASM

advertisement
INTRODUCTION TO TASM
Introduction: The aim of this experiment is to introduce the student to assembly language
programming and the use of the tools that he will need throughout the lab experiments. This
first experiment let the student use the Dos Debugger and the Microsoft Turbo Assembler
(TASM). Editing, Assembling, Linking, Execute up can be done using TASM software
Objectives:
1. Introduction to Microsoft Turbo Assembler (TASM)
2. General structure of an assembly language program
3. Use of the DOS Debugger program
Overview:
In general, programming of microprocessor usually takes several iterations before the right
sequence of machine code instruction is written. The process, however is facilitated using a
special program called an “Assembler”. The Assembler allows the user to write alphanumeric
instructions. The Assembler, in turn, generates the desired machine instructions from the
assembly language instructions.
Assembly language programming consists of following steps:
STEP
PRODUCES
1
Editing
Source file
2
Assembling
Object file
3
Linking
Executable file
4
Executing
Results
Assembling the program:
The assembler is used to convert the assembly language instructions to machine code. It is
used immediately after writing the Assembly language program. The assembler starts by
checking the syntax or validity of the structure of each instruction in the source file .if any
errors are found, the assemblers displays a report on these errors along with brief explanation
of their nature. However If the program does contain any errors, the assembler produces an
object file that has the same name as the original file but with the “obj” extension.
Linking the program:
The Linker is used convert the object file to an executable file. The executable file is the final
set of machine code instructions that can directly be executed by the microprocessor. It is the
different than the object file in the sense that it is self-contained and re-locatable. An object
file may represent one segment of a long program. This segment cannot operate by itself, and
must be integrated with other object files representing the rest of the program, in order to
produce the final self-contained executable file.
Executing the program
The executable contains the machine language code .it can be loaded in the RAM and
executed by the microprocessor simply by typing, from the DOS prompt ,the name of the
file followed by the carriage Return Key (Enter Key). If the program produces an output on
the screen or sequence of control signals to control a piece of hard ware, the effect should be
noticed almost immediately. However, if the program manipulates data in memory, nothing
would seem to have happened as a result of executing the program.
Steps to operate the TASM
1. Edit file name.asm:- an edit window will be open, write the assembly code, save it and exit
it.
2. Tasm filename: - this will compile the program.
3. Tlink file name: - if there is no error, do this step.
4. Td filename: - this will debug the program and program execution window will open.
5. Press F9 to run the program.
6. To view the result goes to dump and see the result.
When you indicates that you want a listing file, even if you did not explicitly specify it on the
command line.
tasm /l <filename>.asm
edit <filename>.lst
Flowchart of how Program
Execute
Description of Output Window Screen
General Purpose Registers Used:
Ex:No:04
To Study of TASM Addition and Subtraction of 8bit number
AIM:-WAP in assembly language involving arithmetic instruction of 8 bit data for Addition.
Assembly code:data segment
a dw 0202h
b dw 0408h
c dw ?
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov ax,a
mov bx,b
add ax,bx
mov c,ax
int 3
code ends
end start
Code Table:
Hex Code
Mnemonic operand
Comments
Final Result:
Output:
Learning outcome: Learn about the mov instruction and assembler directives such db,
segment, assume.
AIM:-WAP in assembly language involving arithmetic instruction of 8 bit data for Subtraction
Assembly code:-
data segment
a db 2Ah
b db 13h
c dw ?
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov al,a
mov bl,b
sub al,bl
mov c,ax
int 3
code ends
end start
Code Table:
Hex Code
Mnemonic operand
Comments
Final Result:
Output:
Learning outcome: Learn about the mov instruction and assembler directives such db, segment,
assume.
Ex:No:05
To perform the Addition of 16-bit number,
Subtraction of 16-bit number
AIM:-WAP in assembly language involving arithmetic instruction of 16 bit data for
Addition.
Assembly code:-
data segment
a dw 0202h
b dw 0408h
c dw ?
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov ax,a
mov bx,b
add ax,bx
mov c,ax
int 3
code ends
end start
Code Table:
Hex Code
Mnemonic operand
Comments
Final Result:
Output:
Learning outcome: Learn about the mov instruction and assembler directives such db, segment,
assume.
AIM :-WAP in assembly language involving arithmetic instruction of 16 bit data for
Subtraction.
Assembly code:-
data segment
a dw 0202h
b dw 0408h
c dw ?
data ends
code segment
assume cs:code,ds:data
start: move ax,data
mov ds,ax
mov ax,a
mov bx,b
sub ax,bx
mov c,ax
int 3
code ends
end start
Code Table:
Hex Code
Mnemonic operand
Comments
Final Result:
Output:
Learning outcome: Learn about the mov instruction and assembler directives such db, segment,
assume.
Ex:No:06
To perform the Multiplication of 8-bit number,
Factorial of a given number
AIM:-WAP in assembly language involving arithmetic instruction of 16 bit data for Multiplication.
Assembly code:data segment
a dw 0003h
b dw 0002h
c dd ?
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov ax,a
mov bx,b
mul bx
mov word ptr c,ax
mov word ptr c+2,dx
int 3
code ends
end start
Code Table:
Hex Code
Mnemonic operand
Comments
Final Result:
Output:
Learning outcome: Learn about the mov instruction, how to use 32 bit data and assembler
directives such db, segment, assume. Also learn about how the data mov between 32 bit.
AIM:-WAP in assembly language involving arithmetic instruction of 16 bit data for
Factorial of a given number.
Assembly code:data segment
a dw 5
data ends
code segment
assume cs:code,ds:data
start: move ax,data
mov ds,ax
mov ax,00
mov ax,a
L1:
dec a
mul a
mov cx,a
cmp cx,01
jnz L1
int 3
code ends
end start
Code Table:
Hex Code
Mnemonic operand
Comments
Final Result:
Output:
Learning outcome: Learn about the mov instruction and assembler directives such db, segment,
assume. Also how the loop works.
Download