Académique Documents
Professionnel Documents
Culture Documents
SHIHABUDEEN H
Prepared by
SHIHABUDEEN H
MICROPROCESSORS-8086
1.Architecture
2.Programming
3.Interfacing
Address bus
To address 1,048,,576 (220 ) memory
locations/ports.
Sends out the address of memory location
thats is to be written to or read from
Sends out the address of ports thats is to be
written to or read from
Data bus
To manipulate and/or operate on 16-bits(2bytes) of data at a time.
Read /write data from/to memory and port
through data bus
HARDWARE
1.Queue
While an EU is decoding an instruction or
executing an instruction which does not require
use of the buses, Fetches up to six instruction
bytes of following instructions
When EU is ready for its next instruction, it
simply reads the queue in the BIU.
This is much faster than sending out the
address to the memory and waiting for the
memory to send back the next instruction byte
First in First out register( FIFO)
Fetching: Before the CPU can execute an instruction, the control unit
must retrieve (or fetch) a command or data from the computers
memory.
Decoding: Before a command can be executed, the control unit must
break down (or decode) the command into instructions.
Executing: Part of the execution cycle. When the command is
executed, the CPU carries out the instructions in order by converting
them into microcode.
Storing: The CPU maybe required to store the results of an instruction
in memory.
2. Segmentation
HARDWIRED ZERO
Condition Flags
Carry Flag
Auxiliary carry Flag
Zero Flag
Overflow Flag
Sign Flag
Parity Flag
Control Flags
Direction Flag
Trap Flag
Interrupt Flag
U U U U OF DF IF TF SF ZF U AF U PF U CF
It is impossible to memorize
2.
Assembly language
Four letter mnemonics are used to represent instruction
Easy to memorize
Assembler is used to convert assembly languages to
binary words
Opcode field
MOV
Operand field
Ax,ABC2H
Comment field
;move the value to Ax
1]ADD dest,src
2] ADC dest,src: Add with carry
3] AAA : ASCII adjust after addition.
We can add two ASCII numbers directly and
use AAA after addition so as to get result
directly in BCD. (Works with AL only)
4] DAA : Decimal adjust accumulator.
( Works with AL only)
SF
0
0
1
9] NOP : No Operation
10] ESC: Escape
Executed by Co-processors and actions are
performed according to 6 bit coding in the
instruction.
11] LOCK : Assert bus lock Signal
This is a prefix instruction.
12] WAIT :Wait for test or Interrupt Signal.
Assert wait states.
1]INT type
2] INTO Interrupt on overflow
3] IRET Interrupt return
1.
2.
3.
4.
A] Data Category
B] Branch Category
A] Data Category
1) Immediate Addressing
2) Direct Addressing
( Segment Override prefix)
3) Register Addressing
4) Register Indirect Addressing
mov ax,0006
mov bx,0007
add ax,bx
mov [3000],ax
hlt
mov si,2000
mov di,3000
mov cx,000a
L1:mov al,[si]
mov [di],al
inc si
inc di
dec cx
jnz L1
hlt
mov si,4000
mov cx,[si]
mov ax,0000
inc si
inc si
mov ax,[si]
cmp ax,0000
jz L1
cmp ax,0001
jz L1
L3: dec cx
jz L2
mul cx
jmp L3
L1: mov ax,0001
L2: mov [3000],ax
hlt
mov si,2000
mov cx ,000a
mov ax,[si]
L1: inc si
inc si
dec cx
jz end
cmp ax,[si]
jnc L1
mov ax, [si]
jmp L1
END: mov si,3000
mov [si],ax
hlt
mov si,2000
mov al,[si]
mov bl,01
mov cl,00
L1: sub al,bl
jc L2
inc cl
inc bl
inc bl
jmp L1
L2: mov si,3000
mov [si],cl
hlt
mov si,4000
mov cx,[2000]
mov ax,0000
mov [si],ax
dec cx
jz END
mov bx,0001
inc si
inc si
mov [si],bx
dec cx
jz END
L1: inc si
inc si
add ax,bx
mov [si],ax
mov ax,bx
mov bx,[si]
dec cx
jnz L1
END:hlt
C:\users\user pc
Cd..
C:\users>
Cd..
C:\>
D:
D:\> cd masm
D:\masm
Step 1: Edit
Step 2: Enter or type the program
Step 3: Save as filename.asm
Step 4: Quit editor
Step 5: Assembling process
D:\masm>
D:\masm> masm filename.asm
.LINK file created
1] ASSUME
Used to tell assembler the name of logical segment.
eg: ASSUME CS: Code, DS:DATA
2] END
3] DB :- Define byte. Used to reserve byte/bytes in
memory. User can also initialize these bytes with
ASCII codes of characters specified as string
eg: Ranks DB 01H,02H 03H,04H
mes DB good morning
8] PROC Procedure
Procedure name ENDP
9] ENDP :- End of procedure
eg: EVEN
eg: DATA SEGMENT
10] ENDS:- End of segment
PROC ROOT
11] EQU
Assign a value or a symbol
ROOT ENDP
12] EVEN:
DATA ENDS
Align on even memory
address.
eg: CREATE EQU ADD
13] OFFSET
LABEL EQU 0003
14] PTR Pointer
eg: MOV SI ,OFFSET LIST
eg: MOV AL,BYTEPTR[SI]
:- specify data type
17] PUBLIC
Links modules together
18] EXTRN
Tells the assembler that the names or labels following
this directive is in some other assembly module as
PUBLIC
If AH = 09H
Displays the string pointed by DS:DX
If AH = 01H
The keyboard entry is accepted & its value is store
in AL register
If AH = 4CH
This will bring the computer to DOS prompt
If AH = 0AH
Reads the string from keyboard and stores to the
location pointed by DS: DX. Function will
terminate when enter key is pressed
If AH = 02H
It will send a character in DL to CRT display
ENDM
DATA SEGMENT
DATA ENDS
CODE SEGMENT
ASSUEME CS:CODE,DS:DATA
START: MOV AX, DATA
MOV DS,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
data segment
x db 01h
y db 02h
r db 02dup(?)
data ends
code segment
assume cs: code, ds: data
start: mov ax , data
mov ds , ax
mov ax , x
add ax , y
mov di, offset r
mov [di] , ax
mov ah,4ch
int 21h
code ends
end start
code segment
assume cs: code, ds: data
start: mov ax , data
mov ds , ax
print msg1
call read
add sum , cx
print msg2
call read
add sum,cx
print msg3
mov ax , sum
call disp
print outs
mov ah,4ch
int 21h
read proc
mov ax,0000h
mov bx,000ah
mov cx,0000h
L1: mov ah,01h
int 21h
cmp al.0dh
jz L2
mov ah,00h
sub al,30h
push ax
mov ax,cx
mul bx
mov cx,ax
pop ax
add cx,ax
jmp L1
L2: ret
read endp
disp proc
mov bx,000ah
mov cx,0000h
mov di , offset outs
mov dx,0024h
push dx
inc cx
L3: mov dx,0000h
div bx
add dx,0030h
push dx
inc cx
cmp ax,0000h
jz L3
L4: pop [di]
inc di
loop L4
ret
disp endp
code ends
end start
code segment
assume cs: code, ds: data
start: mov ax , data
mov ds , ax
print msg1
call read
cmp cx,0000h
jz L5
mov bx,0000h
mov ax,0001h
L6: push cx
inc bx
mul bx
pop cx
dec cx
jnz L6
print msg3
call disp
print outs
jmp L7
L5: print msg2
L7: mov ah,4ch
int 21h
read proc
disp proc
code ends
end start
code segment
assume cs: code, ds: data
start: mov ax , data
mov ds , ax
print m1
call read
cmp cx,0000h
jz L5
cmp cx,0001h
jz L5
mov bx , cx
print m3
jmp L8
L6: print m2
jmp L8
L5: print m4
L8: mov ah,4ch
int 21h
read proc
disp proc
code ends
end start
code segment
assume cs: code, ds: data
start: mov ax , data
mov ds , ax
print m1
mov si , offset outs1
mov cx, 0000h
L1:
mov ah,01h
int 21h
cmp al,0dh
jz L2
mov [si],al
inc si
inc cx
jmp L1
print m2
print outs1
L2: mov di , offset outs2
L3: dec si
mov al,[si]
mov [di],al
inc di
loop L3
mov al,24h
mov [di],al
print m3
print outs2
mov ah,4ch
int 21h
code ends
end start