0% found this document useful (0 votes)
9 views5 pages

Unit2 Assebly-Prog

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 5

SNJB’S SHHJB Polytechnic, Chandwad

CH.2 8086 Art of Assembly Lang Prog.

Chapter 2 Marks 08
Art of Assembly Language Programming
2.0 Introduction:

What is Assembly Language?

Each personal computer has a microprocessor that manages the computer's arithmetical, logical and
control activities.

Each family of processors has its own set of instructions for handling various operations like getting input
from keyboard, displaying information on screen and performing various other jobs. These set of
instructions are called 'machine language instruction'.

Processor understands only machine language instructions which are strings of 1s and 0s. However
machine language is too obscure and complex for using in software development. So the low level assembly
language is designed for a specific family of processors that represents various instructions in symbolic code
and a more understandable form.

Advantages of Assembly Language

An understanding of assembly language provides knowledge of:

· Interface of programs with OS, processor and BIOS;

· Representation of data in memory and other external devices;

· How processor accesses and executes instruction;

· How instructions accesses and process data;

· How a program access external devices.

Other advantages of using assembly language are:

· It requires less memory and execution time;

· It allows hardware-specific complex jobs in an easier way;

· It is suitable for time-critical jobs;

2.1 Assembly language program development steps.

1. Defining the problem: The first step in writing program is to think very carefully about the problem that
the program must solve.

2. Algorithm: The formula or sequence of operations to be performed by the program can be specified as a
step in general English is called algorithm.

3. Flowchart: The flowchart is a graphically representation of the program operation or task.

Mr. P R Sali 1 MIC (22415)


SNJB’S SHHJB Polytechnic, Chandwad

CH.2 8086 Art of Assembly Lang Prog.

4. Initialization checklist: Initialization task is to make the checklist of entire variables, constants, all the
registers, flags and programmable ports

5. Choosing instructions: Choose those instructions that make program smaller in size and more
importantly efficient in execution.

6. Converting algorithms to assembly language program: Every step in the algorithm is converted into
program statement using correct and efficient instructions or group of instructions.

There are many good assembler programs, like:

· Microsoft Assembler (MASM)

· Borland Turbo Assembler (TASM)

· The GNU assembler (GAS)

We will use the NASM assembler, as it is:

· Free. You can download it from various web sources.

· Well documented and you will get lots of information on net.

· Could be used on both Linux and Windows

2.2 List assembly language programming tools.

1. Editors

2. Assembler

3. Linker

4. Debugger.

Program Development

• Problem: must convert ideas (human thoughts) into an executing program (binary image in memory)

• The Program Development Process uses a set of tools to provide a people-friendly way to write programs
and then convert them to the binary image.

1. Editor

An editor is a program, which is used to construct assembly language program inappropriate format so that
the assembler will translate it correctly to machine language.

Programming Language

– Syntax: set of symbols + grammar rules for constructing statements using symbols

– Semantics: what is meant by statements �ultimately, what happens upon execution

Mr. P R Sali 2 MIC (22415)


SNJB’S SHHJB Polytechnic, Chandwad

CH.2 8086 Art of Assembly Lang Prog.

– Assembly Language : A readable language that maps one-to-one to the machine instructions, to what
operations are supported by the CPU.

2. Assembler : A Program that converts the assembly language to object format

• Object Code is the program in machine format (ie. binary)

• May contain unresolved references (ie. file contains some or all of complete program)

3. Linker : A program that combines object files to create an single “executable” file

– Major functional difference is that all references are resolved. (ie. Program contains all parts needed to
run)

4. Loader : A program that loads executable files into memory, and may initialize some registers (e.g. IP )
and starts it going.

5. Debugger : A program that loads but controls the execution of the program. To start/stop execution, to
view and modify state variables

2.3 ASSEMBLER DIRECTIVES


 Assembler directives are the commands to the assembler that direct the assembly process.
 They indicate how an operand is treated by the assembler and how assembler handles the program.
 They also direct the assembler how program and data should arrange in the memory.
 ALP’s are composed of two type of statements.

(i) The instructions which are translated to machine codes by assembler.


(ii) The directives that direct the assembler during assembly process, for which no machine code is
generated.

1. ASSUME: Assume logical segment name.


The ASSUME directive is used to inform the assembler the names of the logical segments to be assumed for
different segments used in the program .In the ALP each segment is given name.
Mr. P R Sali 3 MIC (22415)
SNJB’S SHHJB Polytechnic, Chandwad

CH.2 8086 Art of Assembly Lang Prog.

Syntax: ASSUME segreg:segname,…segreg:segname


Ex: ASSUME CS:CODE
ASSUME CS:CODE,DS:DATA,SS:STACK

2. DB: Define Byte


The DB directive is used to reserve byte or bytes of memory locations in the available memory.
Syntax: Name of variable DB initialization value.
Ex: MARKS DB 35H,30H,35H,40H
NAME DB “VARDHAMAN”

3. DW: Define Word


The DW directive serves the same puposes as the DB directive,but it now makes the assembler reserve the
number of memory words(16-bit) instead of bytes.
Syntax: variable name DW initialization values.
Ex: WORDS DW 1234H,4567H,2367H
WDATA DW 5 Dup(522h)
(or) Dup(?)

4. DD: Define Double:


The directive DD is used to define a double word (4bytes) variable.
Syntax: variablename DD 12345678H
Ex: Data1 DD 12345678H

5. DQ: Define Quad Word


This directive is used to direct the assembler to reserve 4 words (8 bytes) of memory for the specified
variable and may initialize it with the specified values.
Syntax: Name of variable DQ initialize values.
Ex: Data1 DQ 123456789ABCDEF2H

6. DT: Define Ten Bytes


The DT directive directs the assembler to define the specified variable requiring 10 bytes for its storage and
initialize the 10-bytes with the specified values.
Syntax: Name of variable DT initialize values.
Ex: Data1 DT 123456789ABCDEF34567H

7. END: End of Program


The END directive marks the end of an ALP. The statement after the directive END will be ignored by the
assembler.

8. ENDP: End of Procedure


The ENDP directive is used to indicate the end of procedure. In the AL programming the subroutines are
called procedures.
Ex: Procedure Start
:
Start ENDP

9. ENDS: End of segment


The ENDS directive is used to indicate the end of segment.
Ex: DATA SEGMENT
:
DATA ENDS
Mr. P R Sali 4 MIC (22415)
SNJB’S SHHJB Polytechnic, Chandwad

CH.2 8086 Art of Assembly Lang Prog.

10. EVEN: Align on Even memory address


The EVEN directive updates the location counter to the next even address.
Ex: EVEN
Procedure Start
:
Start ENDP
The above structure shows a procedure START that is to be aligned at an even address.

11. EQU: Equate


The directive EQU is used to assign a label with a value or symbol.
Ex: LABEL EQU 0500H
ADDITION EQU ADD

Mr. P R Sali 5 MIC (22415)

You might also like