Microprocessor and Assembly Language
Microprocessor and Assembly Language
Microprocessor and Assembly Language
ASSEMBLY LANGUAGE
LECTURE-5-PROGRAM STRUCTURE OF
ASSEMBLY LANGUAGE
MUHAMMAD HAFEEZ
DEPARTMENT OF COMPUTER SCIENCE
GC UNIVERSITY LAHORE
TODAY’S AGENDA
Program Structure
Assembler Directives
MEMORY MODELS
Memory Models defines how much memory
we need for a program
TINY
SMALL
MEDIUM
COMPACT
LARGE
HUGE
MEMORY MODELS
TINY
64K for both code and data segment
SMALL
64K for code segment
64K for data segment
MEDIUM
64K data segment
Code can exceed 64K
COMPACT
data segment can exceed 64K
Code segment 64K
LARGE
Code can exceed 64K
Data can exceed 64K but Array declared in one data segment
can not exceed 64K
HUGE
Code can exceed 64K
Data can exceed 64K, Array declared in one data segment can
exceed 64K
MEMORY MODELS
ASSEMBLY LANGUAGE
STATEMENTS
Assembly Language Statements are either,
Instructions
Directive (also called Pseudo-Ops)
Assigns Stack of
a Title program
to your Data of
Source Label program
File
Assembler
Directive
Comment
DATA DEFINING DIRECTIVES
Storage is defined using data definition
directives
Storage is created at assembly time.
Variables can be initialized to character
string
Syntax
DATA1 DB 15H
DATA2 DB 15H, 1FH, 4AH
DATA3 DB ? ;SET ASIDE ONE BYTE
DATA4 DB ‘STRING OF CHARACTERS’,’$’
EQU Syntax
Name EQU Constant
Example:
LF EQU 0AH
CR EQU 0DH
EQU Syntax
Name EQU Constant
Example:
LF EQU 0AH
CR EQU 0DH
Read a Character
Display a Character
Display a String
SOME BASIC I/O
OPERATIONS
Read a Character
INT 21h / AH=1 - read character from
standard input, with echo, result is stored
in AL.
If there is no character in the keyboard
buffer, the function waits until any key is
pressed.
Example:
mov ah, 1
int 21h
SOME BASIC I/O
OPERATIONS
Display a Character
INT 21h / AH=2 - write character to
standard output.
DL = character to write, after execution AL
= DL.
Example:
mov ah, 2
mov dl, ’a’
int 21h
SOME BASIC I/O
OPERATIONS
Display a String
INT 21h / AH=9 - display a string character
string on the console.
The offset of string must be in DX
string must be end with $ (24h)
??????????????????????????