Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 20

Coaa Lab Assignment

Name- Dhiraj Kurhade


Roll no.- 68
GR no.- 12011151
Div – CS-B
Batch – B3

1) Study of Microprocessor 8086


Microprocessor - 8086 Pin Configuration
8086 was the first 16-bit microprocessor microprocessor available available in 40-pin DIP
(Dual Inline Package) Package) chip.
8086 Pin Diagram
Power supply and frequency signals
It uses 5V DC supply at V pin 40, and uses ground at V pin 1 and 20 for its operation.
Clock signal
Clock signal is provided through Pin-19. It provides timing to the processor for operations. Its
frequency is different for different versions, i.e. 5MHz, 8MHz and 10MHz.
Address/data bus
AD0-AD15. These are 16 address/data bus. AD0-AD7 carries low order byte data and AD8-
AD15 carries higher order byte data. During the first clock cycle, it carries 16-bit address and
after that it carries 16-bit data.
Address/status bus
A16-A19/S3-S6. A16-A19/S3-S6. These are the 4 address/status address/status buses.
During the first clock cycle, it carries 4-bit address and later it carries status signals.
S7/BHE
BHE stands for Bus High Enable. It is available at pin 34 and used to indicate the transfer of
data using data bus D8-D15. This signal is low during the first clock cycle, thereafter it is
active.
Read($\overline{RD}$)
It is available at pin 32 and is used to read signal for Read operation.
Ready
It is available at pin 22. It is an acknowledgement signal from I/O devices that data is
transferred. It is an active high signal. When it is high, it indicates that the device is ready to
transfer data. When it is low, it indicates wait state.
RESET
It is available at pin 21 and is used to restart the execution. It causes the processor to
immediately terminate its present activity. This signal is active high for the first 4 clock cycles
to RESET the microprocessor.
INTR
It is available at pin 18. It is an interrupt request signal, signal, which is sampled during the
last clock cycle of each instruction to determine if the processor considered this as an
interrupt or not.
NMI
It stands for non-maskable interrupt and is available at pin 17. It is an edge triggered input,
which causes an interrupt request to the microprocessor.
$\overline{TEST}$
This signal is like wait state and is available at pin 23. When this signal is high, then the
processor has to wait for IDLE state, else the execution continues.
MN/$\overline{MX}$
It stands for Minimum/Maximum and is available at pin 33. It indicates what mode the
processor is to operate in; when it is high, it works in the minimum mode and vice-versa.
INTA
It is an interrupt acknowledgement signal and id available at pin 24. When the
microprocessor receives this signal, it acknowledges the interrupt.
ALE
It stands for address enable latch and is available at pin 25. A positive pulse is generated
each time the processor begins any operation. This signal indicates the availability of a valid
address on the address/data lines.
DEN
It stands for Data Enable and is available at pin 26. It is used to enable Transreceiver 8286.
The transreceiver is a device used to separate data from the address/data bus.
DT/R
It stands for Data Transmit/Receive signal and is available at pin 27. It decides the direction
of data flow through the transreceiver. When it is high, data is transmitted out and vice-
versa.
M/IO
This signal is used to distinguish between memory and I/O operations. When it is high, it
indicates I/O operation and when it is low indicates the memory operation. It is available at
pin 28
WR
It stands for write signal and is available at pin 29. It is used to write the data into the
memory or the output device depending on the status of M/IO signal.
HLDA
It stands for Hold Acknowledgement signal and is available at pin 30. This signal
acknowledges the HOLD signal.
HOLD
This signal indicates to the processor that external devices are requesting to access the
address/data buses. It is available at pin 31.
QS0 and QS1
These are queue status signals and are available at pin 24 and 25. These signals provide
the status of instruction queue.
Their conditions are shown in the following table –

S0 , S1 , S2
These are the status signals that provide the status of operation, operation, which is used by
the Bus Controller 8288 to generate memory & I/O control signals. These are available at pin
26, 27, and 28. Following is the table showing their status −

LOCK
When this signal is active, it indicates to the other processors not to ask the CPU to leave
the system bus. It is activated using the LOCK prefix on any instruction and is available at
pin 29.
RQ/GT1 and RQ/GT0
These are the Request/Grant signals used by the other processors requesting the CPU to
release the system bus. When the signal is received by CPU, then it sends
acknowledgment.RQ/GT0 has a higher priority than RQ/GT1.

Memory Models in 8086 –


The memory models in 8086 specify the size of memory assigned to the different parts of a
program. The. MODEL directive is used at the start to specify which model is going to be
used. There are total 6 memory models:
1. TINY – In this model both code and data occupy a single physical segment of memory.
On linking a file with this model, it automatically generates a com file which is smaller than
exe file.
2. SMALL – In this model, the code and data occupy individual physical segments from
memory.
3. COMPACT – In this model the code occupies a single physical segment while the
contents of data can be given their own separate segments.
4. MEDIUM – In this model the data occupies a single segment.
5. LARGE – In this model, both code and data are stored in different physical statements.
6. HUGE – It is similar to LARGE with an only difference that a data array may have a size
that exceeds one physical segment.

Sample program:

Instructions –

 MOV: This instruction is used to move data from one location to another.

Syntax – mov destination, source

 LEA (Load Effective Address): It loads the specified register with the offset of a

memory location.

Commands –

1. 09h: Displays the string until “$” is reached.

2. Int 21h: Interrupt used to exit the program.


3. .data: This Command is used only when we want to store in Data Segment,

basically, it is the memory access of the Data Segment. Whatever we want to print

must be written here.Also, the variables are declared here.

4. 10, 13: They work as Escape Sequence Character

5. $: It states the end of a Statement

6. Db (Define Byte): It acts as an Assembler Directive

COA – Lab Assignment 1

7. . code: Full Logical Program is written here

8. Tasm – Used for Compilation

9. tlink– Perform linking operation

Code:

;Print hello world message

.model small

.data

msg db 10, 13, "Hello world$"

.code

mov ax, @data

mov ds, ax

mov ah, 09h

lea dx, msg


int 21h

mov ah, 4ch

int 21h

end

Output:

2) Display two strings using ALP.


Instructions –

 MOV: This instruction is used to move data from one location to another.

Syntax – mov destination, source

 LEA (Load Effective Address): It loads the specified register with the offset of a

memory location.

Commands –

1. 09h: Displays the string until “$” is reached.

2. Int 21h: Interrupt used to exit the program.

3. .data: This Command is used only when we want to store in Data Segment,
basically, it is the memory access of the Data Segment. Whatever we want to print

must be written here.Also, the variables are declared here.

4. 10, 13: They work as Escape Sequence Character

5. $: It states the end of a Statement

6. Db (Define Byte): It acts as an Assembler Directive

COA – Lab Assignment 1

7. . code: Full Logical Program is written here

8. Tasm – Used for Compilation

9. tlink– Perform linking operation

Code:

;Print 2 messages

.model small

.data

msg db 10, 13, "Hello world$"

msg1 db 10, 13, "Welcome to VIT$"

.code

mov ax, @data

mov ds, ax

mov ah, 09h

lea dx, msg

int 21h
mov ah, 09h

lea dx, msg1

int 21h

mov ah, 4ch

int 21h

end

Output:

3) Display addition of two nos and two digit


addition using ALP. 
Instructions –

MOV: This instruction is used to move data from one location to another.

Syntax – mov destination, source

LEA (Load Effective Address): It loads the specified register with the offset of a memory
location.

SUB: Subtract immediate data from accumulator, memory or register.


ADD: Adds data to the accumulator i.e. AL or AX register or memory locations.

CMP: Compare Immediate data, register or memory with accumulator, register or memory
location(s).

JBE: Jump if below, not above, or equal i.e. when CF and ZF = 1

ROL: Rotate all bits of the operand left by specified number of bits.

DEC: Decrement register or memory by 1.

Commands –

1. 09h: Displays the string until “$” is reached.

2. Int 21h: Interrupt used to exit the program.

3. .data: This Command is used only when we want to store in Data Segment,

basically, it is the memory access of the Data Segment. Whatever we want to print

must be written here.Also, the variables are declared here.

4. 10, 13: They work as Escape Sequence Character

5. $: It states the end of a Statement

6. Db (Define Byte): It acts as an Assembler Directive

COA – Lab Assignment 1

7. . code: Full Logical Program is written here

8. Tasm – Used for Compilation

9. tlink– Perform linking operation

Code:

; Program to add two numbers

.model small

.data
msg1 db 10,13,"Enter first no.$"

msg2 db 10,13,"Enter second no.$"

msg3 db 10,13,"Addition is:$"

.code

mov ax,@data

mov ds,ax

lea dx,msg1

mov ah,09H

int 21H

mov ah,01H

int 21H

sub al,30H

cmp al,09H

JBE L1

sub al,07H

L1: mov cl,04H

ROL al,cl

mov bl,al

mov ah,01H
int 21H

sub al,30H

cmp al,09H

JBE L2

sub al,07H

L2:ADD bl,al

lea dx,msg2

mov ah,09H

int 21H

mov ah,01H

int 21H

sub al,30H

cmp al,09H

JBE L3

sub al,07H

L3: mov cl,04H

ROL al,cl

mov bh,al

mov ah,01H

int 21H
sub al,30H

cmp al,09H

JBE L4

sub al,07H

L4:ADD bh,al

ADD bl,bh

lea dx,msg3

mov ah,09H

int 21H

mov ch,02H

mov cl,04H

L5:ROL bl,cl

mov bh,bl

AND bl,0FH

cmp bl,09H

JBE L6

ADD bl,07H

L6:ADD bl,30H

mov dl,bl

mov ah,02H
int 21H

mov bl,bh

dec ch

JNZ L5

mov ah,4ch

int 21H

end

4) Static and Dynamic array using ALP.


Instructions –

MOV: This instruction is used to move data from one location to another.

Syntax – mov destination, source

LEA (Load Effective Address): It loads the specified register with the offset of a

memory location.

LOOP: Jump to defined label until CX = 0.

ADD: Adds data to the accumulator i.e. AL or AX register or memory locations.


INC: Increment Register or memory by 1.

Commands –

1. 09h: Displays the string until “$” is reached.

2. Int 21h: Interrupt used to exit the program.

3. .data: This Command is used only when we want to store in Data Segment,

basically, it is the memory access of the Data Segment. Whatever we want to print

must be written here.Also, the variables are declared here.

4. 10, 13: They work as Escape Sequence Character

5. $: It states the end of a Statement

6. Db (Define Byte): It acts as an Assembler Directive

COA – Lab Assignment 1

7. . code: Full Logical Program is written here

8. Tasm – Used for Compilation

9. tlink– Perform linking operation

Static-

;Program to demo array of 5 elements

.model small

.stack 100h

.data

array db 3,4,5,6,7

msg db 10,13, "Array Elements are$"

.code

main proc
mov ax, @data

mov ds, ax

mov si, offset array

mov cx, 5

mov ah,09h

lea dx, msg

int 21h

loopx:

mov dl,[si]

add dl, 48

mov ah,02h

int 21h

mov dl, 32

mov ah,02h

int 21h

inc si

loop loopx

mov ah, 4ch


int 21h

main endp

end

Output:

Dynamic-

Code:

;Program for taking 4 values and store and display with array

.model small

.stack 100h

.data

array db 4 dup(?)

m1 db 10,13, "Enter the numbers - $"


m2 db 10,13, "Array elements are as :- $"

.code

main proc

mov ax, @data

mov ds, ax

mov ah, 09h ;m1 mesg

lea dx, m1

int 21h

mov cx, 4 ;Counter of 4

mov si, offset array ;starting index of array

loop1:

mov ah, 01h

int 21h

mov [si], al ;input

inc si

loop loop1

;display the array elements

mov dl, 10 ;space


mov ah,02h

int 21h

mov dl, 13 ;new line

mov ah,02h

int 21h

mov ah,09h ;display second msg

lea dx,m2

int 21h

mov cx, 4

mov si, offset array

loop2:

mov dl, [si]

mov ah,02h

int 21h

mov dl, 32 ;Space between 2 nos

mov ah, 02h

int 21h

inc si

loop loop2

mov ah, 4ch


int 21h

main endp

end

Output:

You might also like