Pin Diagram of 8086
(RD)’ - this pin indicates that the microprocessor is reading from the Memory or
I/O devices. It’s an Active low pin.
(WR)’ - indicates that the processor is writing data to memory or an I/O device. It’s
an active low pin.
(DEN)’ - DEN enables data pins (D from the AD pins) to transfer data along the
Data Bus. It’s an Active Low pin.
After the address is latched (ALE goes low), DEN becomes active (low) to enable
data bus. This means the bus now carries data to or from memory/I-O devices.
Instruction Set and Assembly Language
Numbers
Hex numbers can’t start with a letter, and will start with a 0 if there has to be a
letter.
Variables and how to Define them
In 8086 assembly language, the statement:
Alpha db 23
means the following:
● Alpha: This is a label (or variable name) — it represents a memory location
where the data will be stored.
● db: Stands for Define Byte — it's a directive that tells the assembler to reserve 1
byte of memory and initialize it with the given value.
● 23: This is the value (in decimal) that will be stored in that byte.
Similarly, to store Two bytes or One Word, the command ‘dw’ is used
Basic Syntax
Here’s the BASIC SYNTAX used to write an assembly program in 8086 Assembly
language:
.model small ; Define memory model
.stack 100h ; Reserve 256 bytes or 100h of stack in memory
.data ; Data segment (here, data variables are defined)
var1 db 05h
.code ; Code segment
main proc ; Start of main procedure (function)
mov ax, @data ; Initialize DS with address of data segment
mov ds, ax ;
{These two lines of code are needed to import addresses of variables that are defined in “.data.’ }
{OTHER CODE FOR THE PROGRAM}
main endp ; End of main procedure (function)
end main ;
End of file and this indicates that the program should start from the “main”
procedure/fuction
Instruction Set commands
MOV
● MOV stands for "move".
● It copies data from a source operand to a destination operand.
destination: The register, memory location, or segment register where data
will be copied to.
source: The register, memory location, immediate value, or segment register
from which data is copied.
Source Destination Example Description
Register to Register Register MOV AX, BX Copy content of BX into AX
Immediate to Register Register MOV CX, Load immediate value 1234h into CX
1234h
Memory to Register Register MOV AX, Load data at memory address 1234h
[1234h] into AX
Register to Memory Memory MOV Store contents of AX into memory
[1234h], address 1234h
AX
Immediate to Memory Memory MOV Store immediate byte 56h at memory
[1234h], address 1234h
56h
XCHG
● XCHG stands for "Exchange".
● It swaps the contents of two operands.
● Both operands are exchanged simultaneously — no temporary register
needed.
Register to Register:
XCHG AX, BX
Swaps contents of AX and BX registers.
Register to Memory:
XCHG AX, [1234h]
Swaps contents of AX with the 16-bit value stored at memory address 1234h.
NEG
Negates any value in a register and stores it as its 2’s complement.
mov ax, 5 ; AX = 5
neg ax ; AX = -5 (in two's complement, AX = FFFBh)
ADD – Add Source to Destination
● Syntax: ADD destination, source
● Adds source to destination and stores result in destination.
mov ax, -5 ; AX = -5
mov bx, 10 ; BX = 10
add bx, ax ; BX = 10 + (-5) = 5
SUB – Subtract Source from Destination
● Syntax: SUB destination, source
● Subtracts source from destination and stores result in destination.
mov cx, 20 ; CX = 20
mov bx, 5 ; BX = 5
sub cx, bx ; CX = 20 - 5 = 15
INC – Increment by 1
● Syntax: INC register/memory
● Increases value by 1.
mov ax, 5
inc ax ; AX = AX + 1 -> 6
DEC – Decrement by 1
● Syntax: DEC register/memory
● Decreases value by 1.
mov bx, 10
dec bx ; BX = BX - 1 -> 9
MUL
● MUL performs unsigned multiplication.
● It multiplies the accumulator register (AL or AX) by the operand you specify.
● The result is stored in AX, and for larger results, DX is also used.
mov ax, 35000
mov bx, 2
mul bx
answer -> 1 11 70h
The first “1” is in DX, and the rest are in AX (AH and AL).
INT 21h – DOS Interrupt for Services
● Used to perform various DOS functions based on the value in register AH.
AH = 01h → Read a Character (Take an Input) from Keyboard
● Waits for a key press and stores its ASCII value in AL.
mov ah, 01h
int 21h ; Waits for key, returns ASCII in AL
AH = 02h → Display a Character
● Displays the character that is stored in DL when “int 21h” is called.
mov dl, 'A' ; Load character to display
mov ah, 02h
int 21h ; Displays 'A'