0% found this document useful (0 votes)
106 views33 pages

CSE2006 Lab

The document discusses the 8086 microprocessor, providing an overview of its architecture including general purpose registers, pointer and index registers, segment registers, and instruction format. It also covers assembly language programming using MASM and provides examples of tasks like adding numbers, finding the sum and average of arrays, and sorting arrays.

Uploaded by

Bharath Bunny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views33 pages

CSE2006 Lab

The document discusses the 8086 microprocessor, providing an overview of its architecture including general purpose registers, pointer and index registers, segment registers, and instruction format. It also covers assembly language programming using MASM and provides examples of tasks like adding numbers, finding the sum and average of arrays, and sorting arrays.

Uploaded by

Bharath Bunny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33

CSE2006-Microprocessor and

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

• Normally used for storing temporary results


• Each of the registers is 16 bits wide (AX, BX, CX, DX)
• Can be accessed as either 16 or 8 bits AX, AH, AL
4
General Purpose Registers
• AX
– Accumulator Register
– Preferred register to use in arithmetic, logic and data
transfer instructions because it generates the shortest
Machine Language Code
– Must be used in multiplication and division operations
– Must also be used in I/O operations

• 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

• All 16 bits wide, L/H bytes are not accessible

• Used as memory pointers


– Example: MOV AH, [SI]
• Move the byte stored in memory location whose address is contained in
register SI to register AH

• IP is not under direct control of the programmer 7


Segment Registers
• Out of the available 1MB memory, at any
given time, 8086 works only with four 64KB
segments (total 16 segments).
• SR holds the first 16 bits of the starting
address of the four memory segments.
Segment register
• − BIU has 4 segment buses, i.e. CS, DS, SS& ES.
• It holds the addresses of instructions and data in memory, which are used by the
processor to access memory locations.
• It also contains 1 pointer register IP, which holds the address of the next
instruction to be executed by the EU.
• CS − It stands for Code Segment. It is used for addressing a memory location in
the code segment of the memory, where the executable program is stored.
• DS − It stands for Data Segment. It consists of data used by the program andis
accessed in the data segment by an offset address or the content of other
register that holds the offset address.
• SS − It stands for Stack Segment. It handles memory to store data and addresses
during execution.
• ES − It stands for Extra Segment. ES is additional data segment, which is used by
the string to hold the extra destination data.
Assembly language program
• abbreviated asm, is any
low-level programming language in which
there is a very strong correspondence
between the instructions in the language and
the architecture's machine code instructions.
• Boot loader program, device driver etc
• Improves the performance
ALP-Instruction Format

Loop: ADD AX, 05H ; adding 05 to the content of AX register


& the result will be stored in AX

ADD AX, BX
Lab 4

8086 assembly programing using


MASM
Procedure for MASM
• mount c c:\MASM611
• c:
• cd BIN
• Open notepad
• Write your program and save it with .asm in Bin
folder
• To execute:
• In command prompt, type masm filename.asm [this
step assembles the program]
• In command prompt, type link filename.obj
• After linking, press enter 4 times
• In command prompt type debug filename.exe
• -u unassemble
• -r register value
• -g 0006- halt address
Task 1
Adding two 8-bit numbers
codeseg segment
assume cs:codeseg
start:
mov al,02h
mov bl,02h
add al,bl
hlt
codeseg ends
end
Task 2
To find the sum of array elements
DATA SEGMENT
ARRAY DW 0061H, 0043H, 0081H, 0001H, 0065H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV CX, 0005H
MOV AX, DATA
MOV DS, AX
MOV AX, 00H
REPEAT: ADD AX, ARRAY[SI]
ADD SI, 02H
LOOP REPEAT
HLT
CODE ENDS
END START
Task 3
To find the average of array elements and store
it in data segment
DATA segment
ARRAY DW 0022h, 0011h, 0020h, 0033h, 0016h,
0011h, 0013h
RESULT DW ?
DATA ENDS
Lab 5
1. Write 8086 Assembly language program to
find summation of two arrays.
2. Write 8086 Assembly language program to
find product of two arrays.
3. Write 8086 Assembly language program to
generate Fibonacci Series.
Write 8086 Assembly language program to find
summation of two arrays

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.

You might also like