0% found this document useful (0 votes)
11 views29 pages

CH - 2 - Art of Assembly Language Programming

The document outlines the course structure for Microprocessor studies at Vidyalankar Polytechnic for the academic year 2021-2022, focusing on assembly language programming. It details program development steps, assembly language tools, and assembler directives specific to the 8086 microprocessor. The content is presented by Prof. Sheetal Shelar and includes various instructional resources and examples.

Uploaded by

v.a.z.zi.er6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views29 pages

CH - 2 - Art of Assembly Language Programming

The document outlines the course structure for Microprocessor studies at Vidyalankar Polytechnic for the academic year 2021-2022, focusing on assembly language programming. It details program development steps, assembly language tools, and assembler directives specific to the 8086 microprocessor. The content is presented by Prof. Sheetal Shelar and includes various instructional resources and examples.

Uploaded by

v.a.z.zi.er6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Vidyalankar Polytechnic

Program: Computer Engineering (NBA Accredited)

Academic Year: 2021-2022

Course: Microprocessor
Course Code: 22415

Presented By: Prof. Sheetal Shelar


Teaching and Examination scheme:
Course Outcomes:
Why Microprocessor?

https://www.youtube.com/watch?v=AkFi90lZmXA
https://www.youtube.com/watch?v=p3q5zWCw8J4
Unit 2- The art of assemble language programming - 8 Marks
 Topics and Subtopics
1) Program Development Steps
2) Assembly Language Programming Tools
3) Assembler Directives
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 such as
getting input from keyboard, displaying information on screen and performing various other
jobs.

 These set of instructions are called 'machine language instructions’.

 A processor understands only machine language instructions, which are strings of 1's and 0's.
However, machine language is too obscure and complex for using in software development.

 An assembly language is a low-level programming language designed for a specific type of


processor.
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.
Defining
the
problem

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.

Algorithm
Program Development steps

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

Flowchart

4. Initialization checklist: Initialization task is to make the checklist of entire variables,


constants, all the registers, flags and programmable ports

Initializatio
n checklist
Program Development steps

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

Choosing
instructions

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.
Converting
algorithms
to assembly
language
program
Program Development steps
Program Development steps
Assembly language programming tools
Assembly language programming tools
Editor

a) It is a program which helps to construct assembly language program with a file


extension .asm in right format so that the assembler will translate it to machine language.

b) It enables one to create, edit, save, copy and make modification in source file.

Assembler
a) Assembler is a program that translates assembly language program to the correct binary
code for each instruction i.e. machine code and generate the file called as object file with
extension .obj .

b) It also displays syntax errors in the program, if any.

c) It can be also be used to produce list (.lst) which contains assembly language statements,
binary codes, and offset address for each instruction
Assembly language programming tools
Linker

a) It is a programming tool used to convert Object code into executable program.

b) It combines, if requested ,more than one separated assembled modules into one executable
module such as two or more assembly programs or an assembly language with C program.

c) It generates .EXE module

Debugger

a) Debugger is a program that allows the execution of program in single step mode under the
control of the user.

b) The errors in program can be located and corrected using a debugger.


Assembler Directives
Assembler Directives of the 8086 Microprocessor

(a) The DB directive


(b) The DW directive
(c) The DD directive
(d) The STRUCT (or STRUC) and ENDS directives (counted as one)
(e)The EQU Directive
(f)The COMMENT directive
(g)ASSUME
(h) EXTERN
(i) GLOBAL
(j) SEGMENT
(k)OFFSET
(l) PROC
(m)GROUP
(n) INCLUDE
1. DB – The DB directive is used to declare a BYTE -2-BYTE variable – A
BYTE is made up of 8 bits.
Declaration examples:
Byte1 DB 10h
Byte2 DB 255 ; 0FFh, the max. possible for a BYTE
CRLF DB 0Dh, 0Ah, 24h ;Carriage Return, terminator BYTE

2. DW – The DW directive is used to declare a WORD type variable – A WORD


occupies 16 bits or (2 BYTE).
Declaration examples:
Word DW 1234h
Word2 DW 65535; 0FFFFh, (the max. possible for a WORD)
3. DD – The DD directive is used to declare a DWORD – A DWORD
double word is made up of 32 bits =2 Word’s or 4 BYTE.
Declaration examples:
Dword1 DW 12345678h
Dword2 DW 4294967295 ;0FFFFFFFFh.
4. STRUCT and ENDS directives
to define a structure template for grouping data items.
(1) The STRUCT directive tells the assembler that a user defined uninitialized data structure
follows. The uninitialized data structure consists of a combination of the three supported
data types. DB, DW, and DD. The labels serve as zero-based offsets into the structure. The
first element’s offset for any structure is 0. A structure element is referenced with the base
“+” operator before the element’s name.
A Structure ends by using the ENDS directive meaning END of Structure.
Syntax:
STRUCT
Structure_element_name element_data_type?
...
...
...
ENDS
(OR)
STRUC
Structure_element_name element_data_type?
...
...
...
ENDS
DECLARATION:
STRUCT
Byte1 DB?
Byte2 DB?
Word1 DW?
Word2 DW?
Dword1DW?
Dword2 DW?
ENDS
Use OF STRUCT:
The STRUCT directive enables us to change the order of items in the structure when, we reform
a file header and shuffle the data. Shuffle the data items in the file header and reformat the
sequence of data declaration in the STRUCT and off you go. No change in the code we write
that processes the file header is necessary unless you inserted an extra data element.
(5) The EQU Directive
The EQU directive is used to give name to some value or symbol. Each time the assembler finds
the given names in the program, it will replace the name with the value or a symbol. The value
can be in the range 0 through 65535 and it can be another Equate declared anywhere above or
below.
The following operators can also be used to declare an Equate:
THIS BYTE
THIS WORD
THIS DWORD
A variable – declared with a DB, DW, or DD directive – has an address and has space reserved
at that address for it in the .COM file. But an Equate does not have an address or space reserved
for it in the .COM file.
Example:
A – Byte EQU THIS BYTE
DB 10
A_ word EQU THIS WORD
DW 1000
A_ dword EQU THIS DWORD
DD 4294967295
Buffer Size EQU 1024
Buffer DB 1024 DUP (0)
Buffed_ ptr EQU $ ; actually points to the next byte after the; 1024th byte in buffer.
(6) Extern:
It is used to tell the assembler that the name or label following the directive are I some other
assembly module. For example: if you call a procedure which is in program module assembled at
a different time from that which contains the CALL instructions ,you must tell the assembler that
the procedure is external the assembler will put information in the object code file so that the
linker can connect the two module together.
Example:
PROCEDURE -HERE SEGMENT
EXTERN SMART-DIVIDE: FAR ; found in the segment; PROCEDURES-HERE
PROCEDURES-HERE ENDS
(7) GLOBAL:
The GLOBAL directive can be used in place of PUBLIC directive .for a name defined in the
current assembly module; the GLOBAL directive is used to make the symbol available to the
other modules. Example:
GLOBAL DIVISOR:
WORD tells the assembler that DIVISOR is a variable of type of word which is in another
assembly module or EXTERN.
(8) SEGMENT:
It is used to indicate the start of a logical segment. It is the name given to the the segment.
Example: the code segment is used to indicate to the assembler the start of logical segment.
(9) PROC: (PROCEDURE)
It is used to identify the start of a procedure. It follows a name we give the procedure.
After the procedure the term NEAR and FAR is used to specify the procedure Example:
SMART-DIVIDE PROC FAR identifies the start of procedure named SMART-DIVIDE and tells
the assembler that the procedure is far.
(10) NAME:
It is used to give a specific name to each assembly module when program
consists of several modules.
Example: PC-BOARD used to name an assembly module which contains the
instructions for controlling a printed circuit board.
(11) INCLUDE:
It is used to tell the assembler to insert a block of source code from the named
file into the current source module. This shortens the source module. An
alternative is use of editor block command to cop the file into the current source
module.
(12) OFFSET:
It is an operator which tells the assembler to determine the offset or displacement of a named
data item from the start of the segment which contains it. It is used to load the offset of a
variable into a register so that variable can be accessed with one of the addressed modes.
Example: when the assembler read MOV BX.OFFSET PRICES, it will determine the offset
of the prices.
(13) GROUP:
It can be used to tell the assembler to group the logical segments named after
the directive into one logical group. This allows the contents of all he segments
to be accessed from the same group. Example: SMALL-SYSTEM GROUP
CODE, DATA, STACK-SEG.
Thank You!!!

You might also like