Professional Documents
Culture Documents
Processing
Input/Output/
Read/Write/
Load/Store
Subroutine/
Procedure
Decision making
Connector
3. Initialization checklist:
The program may be using variables and constants. It may be using segments, flags, I/O ports. Before
using these entities it may be required to initialize them. It is better to prepare a list of items to be
initialized. Once the list is available, all parameters in the list can be checked whether these are
initialized properly or not.
4. Choosing instructions:
Next step is to determine the instructions required for different parts of program. For this, you must
know all the instructions available in the instruction set of microprocessor and their working. For each
instruction its general form, number and type of operands which will be used with instruction should
be known. It must be cleared that which flags are affected by different instructions.
5. Converting algorithms to assembly language programs:
Once instructions have been selected for different operations, these are arranged in sequence as per
algorithm.
If different segment registers are used, such as data segment, stack segment, extra segment, they must
be initialized properly. If variables are used, they must be declared first and initialized. Jump and loop
labels must be used carefully at proper locations. Procedures/subroutines, if used, must be defined
carefully.
In the last, program must be terminated properly.
Assembler:
An assembler is a program which is used to translate the assembly language program to machine
language program. The assembler reads the source file from disk where it is stored. The translation
may be done in one pass or two passes. In first pass, the assembler creates a symbol table in which
displacement of named data items and offset of the labels used in the programs is stored. After
successful assembly, it generates two file. The first file is called object file and has an extension
.OBJ. This file contains the machine code for the assembly language instructions. The second file
generated by assembler is a list file and has an extension .LST. This file has some extra information
as compared to object file such as assembly language statements, binary or machine code for each
instruction and offset of each instruction. TASM (Turbo Assembler) is assembler from Borland
Software Corporation and MASM is Microsoft Macro Assembler from Microsoft Corporation.
Linker:
A linker is a program used to link (or combine/join) several object files into one executable program.
When the programs are large, they are usually divided into smaller modules. Each module is
individually written, tested and debugged. After this, all modules can be linked together to form a
large program.
FileName.OBJ FileName.EXE
The linker produces relocatable executable files. It also produces a link map file which contains the
address information about the linked files. TLINK is a linker from Borland Software Corporation and
LINK is a linker from Microsoft Corporation.
Debugger:
Debugger is a program which allows you to load machine language program in memory and execute
it. Using debugger, contents of registers and memory locations can be examined. These contents can
be changed and you can re-execute your program. Using debugger programs can be executed in single
step mode. A debugger allows setting break points in program. The program will be executed up to the
break point and stop. Registers and memory locations can be examined to see if the results are correct
at that point. If the results are correct, the break point can be removed and can be set to a new location.
If the results are not correct, the program can be checked to fix the problem. TD is a debugger from
Borland Software Corporation and Code View CV is a debugger from Microsoft Corporation.
Assembler Directives:
Assembler provides a number of reserved words. These reserved words are known as assembler
directives. Assembler directives are helpful in writing programs. These direct or tell the assembler to
perform a particular task. Since these are not the part of 8086 instruction set, machine code is not
generated for assembler directives.
ASSUME:
This directive is used to inform the assembler the name of logical segment. This name is used to refer
to a particular segment. In assembly language programming each segment is given a name e.g. code
segment may be given a name as CODE, data segment as DATA and so on.
General form:
ASSUME segment_register: segment_name, segment_register: segment_name
where segment_register may be CS, DS, ES, SS and segment_name is the name given
to the segment.
For example,
ASSUME CS: CODE, DS: DATA
EQU: Equate
This directive is used to give a name to some value or symbol. Each time, while assembling, the
assembler finds the given name in the program, it will replace the name with the value or symbol.
General form:
In the above statements, CODE and DATA are the segment names.
PROC: Procedure
This directive is used to identify the start of a procedure. This directive is used after the name of
procedure. After PROC directive, the terms NEAR or FAR is used to give the type of procedure.
General form:
procedure_name PROC NEAR/FAR
For example,
FACTORIAL PROC FAR
At the end of procedure ENDP directive is used to indicate the end of procedure.
MACRO:
This directive informs the assembler the beginning of a macro. Before this directive, name of macro is
used. After this directive, macro arguments can be given. At the end of macro ENDM directive is used
to indicate end of the macro.
General form:
macro_name MACRO argument1, argument2
For example,
DISPLAY MACRO message
In the above statement, DISPLAY is macro name and message is an argument.
ORG: Originate
As assembler assembles the program, it uses a location counter to keep track of the allotted addresses.
If the ORG statement is not used, the location counter is initialized to 0000H. If an ORG value
statement is present at the start of a logical segment then first data item or first instruction will be
placed at an offset value. For example, if ORG 0200H statement is present at the start of code
segment, then the code will be placed from offset 0200H in code segment. In other words, the location
counter will be initialized with a value 0200H instead of 0000H. $ symbol can be used to refer current
value of location counter.
LENGTH:
This directive is an operator which tells the assembler to determine the number of elements in some
named data item, such as a string or an array.
When a statement like MOV CX, LENGTH string1 is used, the assembler will determine the no.
of elements in string1 and transfer it to CX.
PTR: Pointer
This is used to declare the type of a label, variable or memory operand. This is used with BYTE or
WORD. If used with BYTE, then the particular label, variable or memory operand is treated as an 8
bit quantity. If used with WORD, then the particular label, variable or memory operand is treated as a
16 bit quantity.
For Example,
MOV AL, BYTE PTR[SI]
INC BYTE PTR[BX]
MOV BX,WORD PTR[2000H]
INC WORD PTR[3000H]
OFFSET:
This directive tells the assembler to determine the offset or displacement of particular label from the
start of the segment which contains it.
Consider the fig. below:
(See next page)
module1 SEGMENT
PUBLIC FACTORIAL FAR
module1 ENDS
module2 SEGMENT
EXTERN FACTORIAL: FAR
Module2 ENDS
GLOBAL:
The GLOBAL directive can be used in place of PUBLIC or EXTERN directive. This directive makes
a name or symbol available to other modules.
For Example,
GLOBAL DIVISOR makes DIVISOR public.
GROUP:
This directive is used to tell assembler to group the logical segment names which appear after the
directive into one logical group segment. This allows the contents of all segments to be accessed from
same group segment base.
For Example,
SMALL_SYSTEM GROUP CODE, DATA, STACK_SEG
ASSUME CS: SMALL_SYSTEM, DS: SMALL_SYSTEM, SS: SMALL_SYSTEM