100% found this document useful (1 vote)
30 views6 pages

MIC Chapter 2 Art of Assembly Language Ali Karim Sir Notes

Chapter 2 discusses the art of assembly language programming, outlining the steps for program development including problem definition, algorithm creation, flowcharting, and instruction selection. It also covers essential programming tools such as editors, assemblers, linkers, and debuggers, along with the role of assembler directives. Additionally, it explains various assembler directives and their usage in defining variables and managing program structure.

Uploaded by

raheen.shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
30 views6 pages

MIC Chapter 2 Art of Assembly Language Ali Karim Sir Notes

Chapter 2 discusses the art of assembly language programming, outlining the steps for program development including problem definition, algorithm creation, flowcharting, and instruction selection. It also covers essential programming tools such as editors, assemblers, linkers, and debuggers, along with the role of assembler directives. Additionally, it explains various assembler directives and their usage in defining variables and managing program structure.

Uploaded by

raheen.shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

MIC Chp 2 Ali Karim Sir MUMBRA 9220990566

Chapter 2
The Art of Assembly Language Programming
Syllabus:
2.1 Program development steps: Defining problem and constrains, Writing Algorithms, Flowchart,
Initialization checklist, choosing instructions, Converting algorithms to assembly language programs
2.2 Assembly Language Programming Tools: Editors, Assembler, Linker, Debugger
2.3 Assembler directives

Q. Demonstrate in detail the program development steps in assembly language programming.


Ans:
Program Development steps
1. Defining the problem
The first step in writing program is to think very carefully about the problem that you want the program to
solve.
2. Algorithm
The formula or sequence of operations or task need to perform by your 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.

4. Initialization checklist
Initialization task is to make the checklist of entire variables, constants, all the registers, flags and
programmable ports.
5. Choosing instructions
We should 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.

Q. List assembly language programming tools.


Ans:
1. Editors
2. Assembler
3. Linker
4. Debugger

Q. Assembler:
An assembler is a program that converts source-code programs written in assembly
language into object files in machine language.
➢ An Assembler is used to translate the assembly language mnemonics into machine language( i.e
binary codes).

1
MIC Chp 2 Ali Karim Sir MUMBRA 9220990566
➢ When you run the assembler, it reads the source file of your program from where you have saved it.
The assembler generates two files.
➢ The first file is the Object file with the extension .OBJ. The object file consists of the binary codes
for the instructions and information about the addresses of the instructions.
➢ After further processing, the contents of the file will be loaded in to memory and run. The second file
is the assembler list file with the extension .LST.

Q. Linker:
➢ A linker is a program that combines your program's object file created by the assembler with other
object files and link libraries, and produces a single executable program.
➢ A linker utility to produce executable files.
➢ Two linkers: LINK.EXE and LINK32.EXE are provided with the MASM 6.15 distribution to link
16-bit real-address mode and 32-bit protected-address mode programs respectively.
➢ A linker is a program used to connect several object files into one large object file. While writing
large programs it is better to divide the large program into smaller modules.
➢ Each module can be individually written, tested and debugged. Then all the object modules are
linked together to form one, functioning program.

Q. Locator:
➢ A locator is a program used to assign the specific addresses of where the segments of object code are
to be loaded into memory.
➢ A locator program called EXE2BIN comes with the IBM PC Disk Operating System (DOS).
EXE2BIN converts a .EXE file to a .BIN file which has physical addresses.
Q. State the role Debugger in assembly language programming.
Ans:
Debugger:
➢ Debugger is the program that allows the extension of program in single step mode under the control
of the user.
➢ The process of locating & correcting errors using a debugger is known as Debugger.
Some examples of debugger are DOS debug command Borland turbo debugger TD, Microsoft
debugger known as code view cv, etc…
2
MIC Chp 2 Ali Karim Sir MUMBRA 9220990566
Q. Editor
➢ An Editor is a program which allows us to create a file containing the assembly language statements
for the program. Examples of some editors are PC write WordStar.
➢ As we type the program the editor stores the ACSII codes for the letters and numbers in successive
RAM locations. If any typing mistake is done editor will alert us to correct it.
➢ If we leave out a program statement an editor will let you move everything down and insert a line.
➢ After typing all the program, we have to save the program for a hard disk. This we call it as source
file.
➢ The next step is to process the source file with an assembler. While using TASM or MASM we
should give a file name and extension .ASM.
➢ Ex: Sample. asm
Q. Emulator:
Ans:
An emulator is a mixture of hard ware and software. It is usually used to test and debug the hardware and
software of an external system such as the prototype of a microprocessor based instrument.
ASSEMBLER DIRECTIVES AND OPERATORS
ASSEMBLER DIRECTIVES :
Assembler directives are the directions to the assembler which indicate how an operand or
section of the program is to be processed. These are also called pseudo operations which are not
executable by the microprocessor. The various directives are explained below.
Q. Explain any two assembler directives of 8086
Ans:

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
Words or 4 BYTE.
Declaration examples:
Dword1 DW 12345678h
Dword2 DW 4294967295 ;0FFFFFFFFh
4. EQU -
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.

3
MIC Chp 2 Ali Karim Sir MUMBRA 9220990566
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.

5. SEGMENT:
It is used to indicate the start of a logical segment. It is the name given to the segment. Example: the code
segment is used to indicate to the assembler the start of logical segment.

6. 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.

Q. Explain the use of assembler directives.


1) DW 2) EQU 3) ASSUME 4) OFFSET 5) SEGMENT 6) EVEN
Ans:
DW (DEFINE WORD)
The DW directive is used to tell the assembler to define a variable of type word or to reserve storage
locations of type word in memory. The statement MULTIPLIER DW 437AH, for example, declares a
variable of type word named MULTIPLIER, and initialized with the value 437AH when the program is
loaded into memory to be run.

EQU (EQUATE)
EQU is used to give a name to some value or symbol. Each time the assembler finds the given name in the
program, it replaces the name with the value or symbol you equated with that name.

Example
Data SEGMENT
Num1 EQU 50H
Num2 EQU 66H
Data ENDS
Numeric value 50H and 66H are assigned to Num1 and Num2.

ASSUME
ASSUME tells the assembler what names have been chosen for Code, Data Extra and Stack segments.
Informs the assembler that the register CS is to be initialized with the address allotted by the loader to the
label CODE and DS is similarly initialized with the address of label DATA.
4
MIC Chp 2 Ali Karim Sir MUMBRA 9220990566

OFFSET
OFFSET is an operator, which tells the assembler to determine the offset or displacement of a named data
item (variable), a procedure from the start of the segment, which contains it. Example
MOV BX;
OFFSET PRICES;
It will determine the offset of the variable PRICES from the start of the segment in which PRICES is
defined and will load this value into BX.

SEGMENT
The SEGMENT directive is used to indicate the start of a logical segment. Preceding the SEGMENT
directive is the name you want to give the segment.
For example, the statement CODE SEGMENT indicates to the assembler the start of a logical segment
called CODE. The SEGMENT and ENDS directive are used to “bracket” a logical segment containing code
of data

EVEN (ALIGN ON EVEN MEMORY ADDRESS)


As an assembler assembles a section of data declaration or instruction statements, it uses a location counter
to keep track of how many bytes it is from the start of a segment at any time. The EVEN directive tells the
assembler to increment the location counter to the next even address, if it is not already at an even address.
A NOP instruction will be inserted in the
location incremented over

1. ASSUME : The ASSUME directive is used to inform the assembler the name of the logical segment it
should use for a specified segment.
Ex: ASSUME DS: DATA tells the assembler that for any program instruction which refers to the data
segment ,it should use the logical segment called DATA.

2. DB -Define byte. It is used to declare a byte variable or set aside one or more storage locations of type
byte in memory.
For example, CURRENT_VALUE DB 36H tells the assembler to reserve 1 byte of memory for a variable
named CURRENT_ VALUE and to put the value 36 H in that memory location when the program is loaded
into RAM .

3. DW -Define word. It tells the assembler to define a variable of type word or to reserve storage
locations of type word in memory.

4. DD(define double word) :This directive is used to declare a variable of type double word or restore
memory locations which can be accessed as type double word.
5. DQ (define quadword) :This directive is used to tell the assembler to declare a variable 4 words in
length or to reserve 4 words of storage in memory .

6. DT (define ten bytes):It is used to inform the assembler to define a variable which is 10 bytes in length
or to reserve 10 bytes of storage in memory.

7. EQU –Equate It is used to give a name to some value or symbol. Every time the assembler finds the
given name in the program, it will replace the name with the value or symbol we have equated with that
name
5
MIC Chp 2 Ali Karim Sir MUMBRA 9220990566

8. ORG -Originate : The ORG statement changes the starting offset address of the data. It allows to set the
location counter to a desired value at any point in the program.For example the statement ORG 3000H tells
the assembler to set the location counter to 3000H.

9. PROC- Procedure: It is used to identify the start of a procedure. Or subroutine.

10. END- End program .This directive indicates the assembler that this is the end of the program
module.The assembler ignores any statements after an END directive.

11. ENDP- End procedure: It indicates the end of the procedure (subroutine) to the assembler.
12. ENDS-End Segment: This directive is used with the name of the segment to indicate the end of that
logical segment.
Ex: CODE SEGMENT : Start of logical segment containing code
CODE ENDS : End of the segment named CODE.
Q. Draw flowchart for multiplication of two 16-bit numbers.
Ans:

You might also like