CSE2006 Lab
CSE2006 Lab
Interfacing
L49L50
Introduction to 8086
• Backward compatible with 8085
• Memory interfacing technique is similar, though
memory addressing is different
• 40-pin DIP, 5V supply
• 29,000 transistors
• 20 bit address to access memory
• (memory space = 220 = 1MB)
Block diagram of 8086
3
General Purpose Registers
AX - the Accumulator
BX - the Base Register
CX - the Count Register
DX - the Data Register
• BX
– Base Register
– Also serves as an address register
5
General Purpose Registers
• CX
– Count register
– Used as a loop counter
– Used in shift and rotate operations
• DX
– Data register
– Used in multiplication and division
– Also used in I/O operations
6
Pointer and Index Registers
ADD AX, BX
Lab 4
DATA segment
MAT1 DW 0022h, 0011h, 0020h, 0033h, 0016h, 0011h, 0013h
MAT2 DW 0020h, 0013h, 0010h, 0023h, 0015h, 0042h, 0031h
RESMAT DW 7 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
mov cx, 07h
mov bx, cx
mov ax, Data
mov ds, ax
mov ax, 00h
RPT: ADD ax, MAT1[SI]
ADD ax, MAT2[SI]
mov RESMAT[SI], ax
mov ax, 00h
add SI, 02h
loop RPT
hlt
Code ENDS
END START
Lab 6 - Sorting
1. Write 8086 Assembly language program to
sort the array in ascending order.
2. Write 8086 Assembly language program to
sort the array in descending order.
3. Write 8086 Assembly language program to
find the smallest value in a given array.
4. Write 8086 Assembly language program to
find the largest value in a given array.
Task 2 - Descending
data segment
list dw 0003h, 0005h, 0002h, 0007h
count equ 4h
data ends
code segment
assume cs:code, ds:data
Start:
mov ax, data
mov ds, ax
mov dx, count-1
l0:mov cx,dx
mov si, offset list
l1:
mov ax, [si]
cmp ax, [si+2]
jnl pr1
xchg [si+2],ax
xchg [si], ax
pr1:
add si, 2
loop l1
dec dx
jnz l0
hlt
code ends
END START
Lab 7 – Logical Operator
1. Write 8086 Assembly language program to
perform logical operators AND, OR, NOT and
XOR.
2. Write 8086 Assembly language program to
perform conversion of BCD to ASCII.
3. Write 8086 Assembly language program to
perform conversion of BCD to HEX.
Task 2
• Unpack the BCD
– Rotate the result right by 4 times
– AND by 0F0F
• OR the result with 3030
Task 3
• Unpack the BCD
– Shift the value right by 4 times
– AND by 0F0F
• Result is then multiplied by 0AH
• Add it to lower nibble result to get the
hexadecimal number
ASSUME CS:CODE,DS:DATA MOV CL,04H
DATA SEGMENT
ROR AL,CL
BCD DW 27H
HEX DW ? MOV CX,0AH
DATA ENDS MUL CX
CODE SEGMENT ADD AX,BX
START:
MOV AX,DATA
MOV HEX,AX
MOV DS, AX
MOV AH,4CH
MOV AX,BCD
INT 21H
AND AX,0FH
MOV BX,BCD CODE ENDS
AND AX,0FH END START
Lab 10
Perform the following task using 8086 hardware
kit.
1. Sum first ‘n’ natural numbers
2. Binary to hexadecimal conversion
3. Ascending and descending order
ADC
1. Program 8086 to convert analog to digital signal.
Select channel 0. Start the analog to digital
conversion process by pressing the SOC switch and
displays the output with the LEDs.
2. Modify the above program to initiate the analog to
digital conversion process by means of software and
displays the output with the LEDs.
3. Modify the task 2 which instructs the processor to
store the converted digital data at RAM location
1100H (Hex).
Stepper Motor
1. Write a program to rotate a stepper motor in
clockwise direction.
2. Write a program to rotate a stepper motor in
anti-clockwise direction.