Professional Documents
Culture Documents
UNit 1.3
UNit 1.3
UNit 1.3
Dr.R.D.Chintamani
Assistant Professor
Sanjivani Rural Education Society’s
Microprocessors & Microcontrollers – Unit-I: Topic 1.3 Dr.R.D.Chintamani Department of Information Technology
Assembly Language Program- Introduction
Any assembly language program consists of assembly language instructions and
assembler directives.
Assembler converts assembly language programs in to machine language.
Every instruction in assembly language program is converted into machine language.
Hence there is one to one mapping of assembly language instructions with machine
instructions.
No machine code is generated corresponding to assembler directives.
• ALP’s are composed of two type of statements.
• The instructions which are translated to machine codes by assembler.
• The directives that direct the assembler during assembly process, for which
no machine code is generated.
Microprocessors & Microcontrollers – Unit-I: Topic 1.3 Dr.R.D.Chintamani Department of Information Technology
Assembler Directives - Introduction
Assembler directives helps assembler in the process of
assembling the program to machine language. No code is
generated for it.
E.g. assembly language programs tells assembler
Where a program segment is going to start.
Where a program segment is going to end.
What is the type of the data defined byte/word etc.
Microprocessors & Microcontrollers – Unit-I: Topic 1.3 Dr.R.D.Chintamani Department of Information Technology
SEGMENT & ENDS - Directives
8086 uses segmentation of memory for writing ALP and
storing programs.
8086 Assembly Language programs are written into
logical segments.
When these programs are assembled they are converted to
machine code they are stored into memory in physical
memory segments.
A segment is used to store data, code(i.e. instructions)
or temporary data called stack.
Based on contents a segment may be a data segment,
code segment or stack segment.
Microprocessors & Microcontrollers – Unit-I: Topic 1.3 Dr.R.D.Chintamani Department of Information Technology
SEGMENT & ENDS - Directives
SEGMENT- assembler directive is used to mark the start of a
logical segment.
ENDS – assembler directive is used to specify end of a
logical segment.
Both SEGMENT and ENDS directives should be preceded
by name of the logical segment being defined.
E. g.
MYSEG1 SEGMENT
DATA/CODE/TEMP
DATA
MYSEG1 ENDS
Microprocessors & Microcontrollers – Unit-I: Topic 1.3 Dr.R.D.Chintamani Department of Information Technology
Assembler Directive
1. ASSUME: Assume logical segment name
Syntax: ASSUMEsegreg:segname,…segreg:segname Ex: ASSUME
CS:CODE
• ASSUME CS:CODE,DS:DATA,SS:STACK
Defining data in 8086 Assembly Languag
Microprocessors & Microcontrollers – Unit-I: Topic 1.3 Dr.R.D.Chintamani Department of Information Technology
Assembler Directive
2.DB: Define Byte
MYSEG1 SEGMENT
DATA/CODE/TEMP
DATA
MYSEG1 ENDS
END
Microprocessors & Microcontrollers – Unit-I: Topic 1.3 Dr.R.D.Chintamani Department of Information Technology
END Directive
DATASEG1 SEGMENT
;DATA
DATASEG1 ENDS
STACKSEG1 SEGMENT
;TEMP
DATA
STACKSEG1 ENDS
CODESEG1 SEGMENT
;CODE
CODESEG1 ENDS
END
Microprocessors & Microcontrollers – Unit-I: Topic 1.3 Dr.R.D.Chintamani Department of Information Technology
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
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
12. EXTRN: External and public
• The directive EXTRN informs the assembler that the names,
procedures and labels declared after this directive have been
already defined in some other AL modules.
• While in other module, where names, procedures and labels actually
appear, they must be declared public using the PUBLIC directive.
• Ex: MODULE1 SEGMENT PUBLIC FACT FAR MODULE1 ENDS
MODULE2 SEGMENT EXTRN FACT FAR MODULE2 END
13. GROUP: Group the related segments
• This directive is used to form logical groups of segments with
similar purpose or type. Ex: PROGRAM GROUP CODE, DATA,
STACK*CODE, DATA and STACK segments lie within a 64KB
memory segment that is named as PROGRAM.
14. LABEL: label
• The label is used to assign name to the current content of the
location counter.
• Ex: CONTINUE LABEL FAR
• The label CONTINUE can be used for a FAR jump, if the
program contains the above statement.
15. LENGTH: Byte length of a label
• Ex : Name “addition”
18. OFFSET: offset of a label
• When the assembler comes across the OFFSET operator along
with a label, it first computing the 16-bit offset address of a
particular label and replace the string ‘OFFSET LABEL’ by the
computed offset address.
• Ex : MOV SI, offset list
19. ORG: origin
• The ORG directive directs the assembler to start the memory
allotment for the particular segment, block or code from the
declared address in the ORG statement.
• Ex: ORG 1000H
20. PROC: Procedure
• The PROC directive marks the start of a named procedure in
the statement. Ex: RESULT PROC NEAR
• ROUTINE PROC FAR
21. PTR: pointer
• The PTR operator is used to declare the type of a label, variable
or memory operator.
• Ex : MOV AL, BYTE PTR [SI] MOV BX, WORD PTR [2000H]
22. SEG: segment of a label
Microprocessors & Microcontrollers – Unit-I: Topic 1.3 Dr.R.D.Chintamani Department of Information Technology
Next Topic – Far and Near Procedure - I
Modular programming
Defining a near procedures
Calling a near procedures
Use of stack in the near procedures
Passing and returning parameter from near
procedures
Microprocessors & Microcontrollers – Unit-I: Topic 1.3 Dr.R.D.Chintamani Department of Information Technology
Ask Questions & Share Responses
You can ask your questions and share your responses at:
Email: chintamanirameshwarit@Sanjivani.org.in
Google Class room
Lecture Presentation and Literature
To refer presentation of this lecture and literature visit:
Google Classroom: Microprocessors & Microcontrollers
References:
1 Peter Abel, Niyaz Nizamuddin, "IBM PC Assembly Language and Programming", Pearson Education.
2 Ray Duncan, "Advanced MS DOS Programming", 2nd Edition, BPB Publications.
3 Douglas Hall, “Microprocessors and Interfacing”, 2nd Edition, 1992, MGH, ISBN-0-07-100462-9.
Microprocessors & Microcontrollers – Unit-I: Topic 1.3 Dr.R.D.Chintamani Department of Information Technology