Download Unit 1 Assembly Language programming

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
ASSEMBLY LANGUAGE
PROGRAMMING
1
ASSEMBLY LANGUAGE
 Assembly language is mnemonic
PROGRAMMING





representation of machine code
Instruction has mnemonics (text form)
Instruction decoder generates opcode
Opcode is machine code
It helps to learn internal architecture of
computer
Programs requires less space in assembly
language
2
Assembly Language Development
MOV AX, BX
..
..
..
Loader
OBJ
Errors
Linked Modules
3
LIB
ASSEMBLER
MASM (Microsofts micro assembler)
TASM (Borland Turbo assembler)
NASM (Netwide assembler)
It converts instructions into binary code
It generates two files( .OBJ file and .LST file)
Object file contains binary code of instruction
and address of instruction
 List file contains program statements, binary
code of each instruction and offset of
eachinstruction






4
LINKER
 It is used to join many object files into one
file
 Large programs are divided into smaller files
 Link file contains binary code of all combined
modules
 It produces .Exe file
5
LOADER
 It is used to LOAD FILE in memory
 It assigns specific address
 It converts .EXE file into .BIN file which has
physical address
 EXE2BIN
6
Assembly Instruction Format
Label :
Mnemonics
Operand1,
Operand2
Label – Symbolic Name Assigned to First Byte of Instruction
Mnemonics – Operation to be performed
Operands – Operation to be performed on.
Comments – Documentation, Non Executable .
7
; Comments
Assembler Directives

These are not the part of processor
instruction set.

Instructions to assembler, linker and loader.

Also referred as pseudo-operations.

They enable to control the way in which
program assembles and lists.

Act during assembly of program and do not
generate any machine executable code.
8
Classification
Segment Simplification
 Data Allocation
 Segment Related
 Macros Declarations
 Code label
 Scope Declaration
 Listing Control
 Miscellaneous

9
Segment Simplification

.CODE :beginning of code segment
◦ Ex .CODE [name]
.DATA : beginning of code segment
 .STACK :used for defining stack

◦ Ex .STACK [size]
.EXIT
 .MODEL :used for selecting
standard memory model

◦ Ex .MODEL [Memory model]
10
Memory Models
Model
No. of code
segments
No. of data
segments
Small
One CS <=64KB
One DS<=64KB
Medium
Any no. and any
size
One DS<=64KB
Compact
One CS <=64KB
Any no. and any
size
Large
Any no. and any
size
Any no. and any
size
Huge
Any no. and any
size
Any no. and any
size
Data allocation
DB :define byte type of variable
DW :define variable of 1 word length
DD :define double word
DQ :define quad(4) word
DT
:define ten bytes (stores no in
decimal
form)
 EQU :Equate
 ORG
:originate , it is used to set
location
pointer at
desired location in program
e.g. org 500h





12
Segment related
SEGMENT :indicates start of logical
segment
 ENDS
: indicates end of segment
 END
:last statement of program
 ASSUME :used to tell assembler name
of
logical segment
 GROUP :collect segment of same type
under
one name
e.g. NAME GROUP SEG1, SEG2

13
scope

PUBLIC
◦ e.g. PUBLIC VAR1, VAR2
◦ Var1 and var2 is to be referred from
other module

EXTRN
◦ e.g. EXTRN SQRT : FAR
◦ Labels are in other module
14
Listing control

PAGE
◦
◦
◦
◦

PAGE [length], [width]
e.g. PAGE 10, 35
Maximum no of lines on a page
Maximum no of characters in line
TITLE
◦ TITLE text
◦ e.g.TITLE MY FIRST PROGRAM
15
Code Label

ALIGN
◦ ALIGN number
◦ e.g. ALIGN 16

EVEN
◦ e.g. EVEN NAME DB 5 DUP(0)

LABEL
◦ e.g. NEXT LABEL FAR

PROC
◦ procedure-name PROC type
16
Macro Declarations

MACRO and ENDM
◦ DISP MACRO
MOV DL, AL
MOV AH, 4CH
INT 21H
◦ ENDM
17
Miscellenous

INCLUDE
◦ INCLUDE path:file name

NAME
Assign name to each assembly module

GLOBAL
◦ GLOBAL variable-name
18