You are on page 1of 18

ASSEMBLY for8086

4/4/2016

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

Types of Programming Language

Machine Language
Assembly Language
High-Level Language

4/4/2016

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

Assembly vs HLL
Advantages of HLL
Easier to write
Easier to
understand
Better control
Doesnt depend on
particular machine

4/4/2016

Advgs of Assembly
Closer to Machine
code
Access to specific
memory location
Helps understand
how computer
actually works

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

Remember
ASSEMBLY language program is machine
specific
ASSEMBLER converts it into machine
code
Not case-sensitive

4/4/2016

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

Syntax
Each line of an ASSEMBLY program
contains a statement
A statement can either be an instruction
or an assembler directive
Instruction: MOV, SHL, JMP etc
Assembler Directive: ORG, ASSUME, END
etc (Pseudo Op-Code)

4/4/2016

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

Synatx
General syntax for a statement is
Name: Instruction Operand(s) ; Comment
Example:
MYLABEL :

4/4/2016

MOV

AX,BX

; abrakadabra

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

Name Field
Used for instruction labels, procedure
names and variable names
1 to 31 characters long
Can contain letters, digits and following
special characters
.

Period must be used at the beginning

4/4/2016

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

Syntax
Operand : There can be 1,2 or no operand
at all. For two operands, generally, they are
Destination, Source
Comment : Anything after (;)
One of the operands can be a data

4/4/2016

MOV AX,10

MOV AX,10D

MOV AX, 1010B

MOV AX,0AH

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

Syntax
Hex number cant start with an alphabet
+/- sign is allowed
String or character is allowed as data
MOV AX, AB
MOV AX,0ABCDH
MOV AX, ABCD
MOV AX, ABCDH
4/4/2016

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

Variables
Byte
Word

8
16

DB
DW

Double Word
Quad Word
Ten Bytes

32
64
80

DD
DQ
DT

MYBYTE

DB

15

MYWORD

DW

MYARRAY

DB

MYSTRING DB
4/4/2016

4,5,6,?,?,?
abrakadabra

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

Named Constant
Name

EQU

constant

MYCONSTANT

EQU

EQU is a pseudo-opcode
Constant can be a string as well

4/4/2016

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

MOV
MOV destination, source
Source
Operand

Destination Operand
General Segment Memory Constant
Register Register Location

General
Register

Segment
Register

Memory
Location

X
X

Constant

X
X

-no change in flag


4/4/2016

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

XCHG
XCHG destination, source
Source
Operand

Destination
Operand
General Memory
Register Location

General
Register
Memory
Location

-no change in flag


4/4/2016

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

ADD/SUB
ADD destination, source
Source
Operand

Destination
Operand
General Memory
Register Location

General
Register
Memory
Location

Constant

-all flags are updated


4/4/2016

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

INC/DEC
Single operand instruction
INC destination
Destination is either a register or a
memory location.
Updates all flags but CF
INC AX ;
ax++
DEC MYBYTE;
mybyte - 4/4/2016

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

NEG
Single operand instruction
NEG destination
Destination is either a register or a
memory location.
Updates all flags
CF=1 unless result is 0
OF=1 if word destination is 8000h or
byte destination is 80h
4/4/2016

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

Type Agreement of Operands


The operands of preceding two operand
instructions must be of the same type
MOV AX, MYBYTE ; illegal
MOV AH, A
MOV AX, A
4/4/2016

; ah=41H
; ax =0041H
EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

ORG
ORG stands for origin
Assembler directive
Displacement from the start of a segment
ORG 1000H
ORG $+1000H

4/4/2016

EEE 315: MICROPROCESSOR & INTERFACING

Md. Ayaz Masud


Lecturer, Dept of EEE, BUET

You might also like