Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 147

REG NO:212214106291

STUDY OF 8086 MICROPROCESSOR

AIM:

To know the general information ,hardware and software details of 8086 microprocessor
trainer kit

HARDWARE SPECIFICATION:
CPU processor and clock frequency :

INTEL 8086/8088 CPU operator at 5/4.7 MHZ clock rate (optionally 8 MHZ)

MEMORY:

 Monitor EPROM 0000-3FFF (16K)


 EPROM Expansion 0000-1FFF (For 64 K)
 System RAM 1000 -3FFF (for 16 K)
 System RAM expansion 1000 –FFFF (For 64 K)
 Interrupt vectors 0000-03FF
 Stack data area 0400-0FFF

PERIPERALS:

o PARALLEL I/O: 48 I/O lines using 2 numbers of 8255


o SERIAL I/O: one Rs 2320 serial interface using
o TIMER: 3 channel 16 bit programmable timerusing 8253 channel/zero is
used as band rate
 generator for the serial code
o DISPLAY: 16*2 LCD display ( with backlight provision)
o KEYBOARD: IBM PC –AT keyboard
o BATTERY BACK UP: on board battery provided for RAM (V3 & V4)
o POWER CONSUMPTION:+5 volts,1.5 amps

COMMAND KEY FUNCTION:

RES:

Res causes the processor to immediately terminate its present activity. To be recognised, the signal
must be active high for at least four clock cycles, except after power-on which requires a 50
Micro Sec. pulse. It causes the 8086 to initialize registers DS, SS, ES, IP and flags to all
zeros. It also initializes CS to FFFF H. Upon removal of the RESET signal from the RESET
pin, the 8086 will fetch its next instruction from the 20 bit physical address FFFF0H.
REG NO:212214106291

INT:

INT is an assembly language instruction for x86 processors that generate a software interrupt.

INPUT AND OUTPUT OF THE CPU:

The cpu generates clock signal from the clock generator (8284) which uses a crystal at 15 or 14.318
or 24 MHz .the reset interrupt lines and the data lines are also input to the cpu the cpu outputs
comprises the address lines, data lines and control lines.

ADDRESS AND DATA BUS:

The 8086/8088 has an internal 20-bit address bus and 16-bit data bus. Externally, the address bus is
20-bits, and the data bus is 16-bits for the 8086 and 8-bits for the 8088.
The data bus in the 8086 is 16 bits in size, while the address bus is 20. The data bus
is multiplexed with the address bus in order to fit all of the control lines into a standard 40-pin dual
in-line package. It provides a 16-bit I/O address bus, supporting 64 KB of separate I/O space. The
maximum linear address space is limited to 64 KB, simply because internal address/index registers
are only 16 bits wide.
CONTROL BUS:

The control pins, which carry essential signals for all external operations, have more than one
function depending upon whether the device is operated in min or max mode. The former mode was
intended for small single-processor systems, while the latter was for medium or large systems using
more than one processor.

CHIP SELECT LOGIC:

Chip select (CS) or slave select (SS) is the name of a control line in digital electronics used to
select one chip (or set of chips) out of several connected to the same computer bus usually
utilizing the three-state logic.
One bus that uses the chip/slave select is the Serial Peripheral Interface Bus.
When an engineer needs to connect several devices to the same set of input wires (e.g., a
computer bus), but retain the ability to send and receive data or commands to each device
independently of the others on the bus, they can use a chip select. The chip select is a command
pin on many integrated circuits which connects the I/O pins on the device to the internal circuitry
of that device.
ARCHITECTURE OF 8086:

The microprocessors functions as the CPU in the stored program model of the digital computer.
Its job is to generate all system timing signals and synchronize the transfer of data between
memory, I/O, and itself. It accomplishes this task via the three-bus system architecture
previously discussed.
REG NO:212214106291

The microprocessor also has a S/W function. It must recognize, decode, and execute
program instructions fetched from the memory unit. This requires an Arithmetic-Logic Unit
(ALU) within the CPU to perform arithmetic and logical (AND, OR, NOT, compare, etc)
functions.

The 8086 CPU is organized as two separate processors, called the Bus Interface Unit (BIU) and
the Execution Unit (EU). The BIU provides H/W functions, including generation of the memory
and I/O addresses for the transfer of data between the outside world -outside the CPU, that is-
and the EU.

The EU receives program instruction codes and data from the BIU, executes these instructions,
and store the results in the general registers. By passing the data back to the BIU, data can also
be stored in a memory location or written to an output device. Note that the EU has no
connection to the system buses. It receives and outputs all its data thru the BIU.

BUS INTERFACE UNIT:

The EU receives program instruction codes and data from the BIU, executes these instructions,
and store the results in the general registers. By passing the data back to the BIU, data can
also be stored in a memory location or written to an output device. Note that the EU has no
connection to the system buses. It receives and outputs all its data through the BIU.

POINTER AND INDEX REGISTERS:

 Stack pointer (SP)


 Base pointers (BP)
 Source index (SI)
 Destination index (DI)
 Instruction pointer (IP)

Stack pointer and base pointer are the two pointer registers whereas the Source index and
Destination index are the index group of registers.

They are primarily used to store relative to segment registers the locations of offset addresses of
memory locations. They serve the purpose of being memory pointers.

The source index and destination index are also used as general purpose register. In such cases
the SI and DI are implemented as source and destination index registers

In stacks, data areas might exist, to be able to access such data which contains the BP register.
REG NO:212214106291

FLAG REGISTERS:

Active flag:- There are nine active flags out of 16, in the 8086 flag register. The remaining
are undefined flag.

Control Flag:- Out of nine active flags, six are conditional flags and the remaining three are
called as the control flag. The three control flags are:

1. The Trap flag(TF)


2. The interrupt flag(IF)
3. The direction flag(DF)

The Trap Flag:


 · Setting TF puts the processor into single step mode for debugging, In single

stepping microprocessor executes a instruction and enters into single step ISR.

 · If TF=1, the CPU automatically generates an internal interrupt after each

instruction, allowing a program to be inspected as it executes instruction by instruction.

The Interrupt Flag:-


 · If IF=1, the CPU will recognize external interrupt request (Interrupt Disabled). If

IF=0, then interrupt disabled.

 · Clearing IF disables these interrupts.

 · IF has no effect on either non-maskable external or internally generated interrupt.

The Direction Flag:-


 · This bit is specially for string instructions.

 · If DF=1, the string instruction will automatically decrement the pointer. If

DF=0,the string instruction will automatically increment the pointer.


REG NO:212214106291

ARCHITECTURE OF 8086

RESULT:

Thus the specification and architecture of 8086 has been studied.

ARITHMETIC OPERATIONS USING 8086 MICROPROCESSOR


EX NO:
REG NO:212214106291

DATE:

AIM:

To write and execute Assembly language Program to perform arithmetic operations for
8086 microprocessor

APPARATUS REQUIRED: 8086 microprocessor kit


Personal computer with MASM software
A)ADDITION

(i)DIRECT METHOD:

ALGORITHM:

Step I : Open command prompt.


Step II : Typr d: then cd masm->edit .
Step III : Then type the program.
Step IV : Initialize the memory location of 1st number.
Step V : Then increment the content of hl register pair and get second
data.
Step VI : Then perform the operation with accumulator and store the
result in memory location.
Step VII : For output type masm filename.asm,,;
link filename,,;
debug filename.exe
Step VIII : Stop.

PROGRAM :

A) By using MASM
CODE SEGMENT
ASSUME CS: CODE,DS:CODE
ORG 1000H
MOV CL,00H
MOV AX,1234H
MOV BX,1234H
ADD AX,BX
JNC LOOP
INC CL
LOOP: MOV SI,1200H
MOV [SI],AX
MOV [SI+2],CL
REG NO:212214106291

MOV AH,4CH
INT 21H
CODE ENDS
END

B)By using 8086 kit

MEMORY LOCATION OP CODE LABEL MNEMONIC


1000 B8 1234 MOV AX,1234H
1003 BB 1234 MOV BX,1234H
1006 03 C3 ADD AX,BX
1008 73 02 JNC LOOP(100C)
100A FE C1 INC CL
100C BE 1200 LOOP MOV SI,1200H
100F 89 04 MOV [SI],AX
1011 88 4C 06 MOV [SI+2],CL
1014 F4 HLT

(ii) INDIRECT METHOD:

ALGORITHM:

Step I : Initialize the memory location for 1st data in HL register.


Step II : Store 1st data in memory location.
Step III : Increment the content of HL register for entering data in
memory location.
Step IV : Store second data in memory location.
Step V : Move 2nd number in accumulator.
Step VI : Decrease the content of HL register pair.
Step VII : Add the content of memory with accumulator.
Step VIII : Store the result in memory location.
Step IX : Stop.

PROGRAM

A)By using MASM


REG NO:212214106291

CODE SEGMENT
ASSUME CS: CODE,DS:CODE
ORG 1000H
MOV SI,2000H
MOV CL,00H
MOV AX,[SI]
MOV BX,[SI+02H]
ADD AX,BX
JNC LOOP
INC CL
LOOP:
MOV [SI+04H],AX
MOV [SI+06H],CL
MOV AH,4CH
INT 21H
CODE ENDS
END

B) By using 8086 kit

MEMORY LOCATION OP CODE LABEL MNEMONIC


1000 BE 2000 MOV SI,2000H
1003 B1 00 MOV CL,00H
1005 8B 04 MOV AX,[SI]
1007 8B 5C 02 MOV BX,[SI+02H]
100A 03 C3 ADD AX.BX
100C 73 02 JNC LOOP(1010)
100E FE C1 INC CL
1010 89 44 04 LOOP MOV [SI+04H],AX
1013 88 4C 06 MOV [SI+06H],CL
1016 F4 HLT
REG NO:212214106291
REG NO:212214106291
REG NO:212214106291

OUTPUT FOR ADDITION (DIRECT METHOD):


BY USING MASM SOFTWARE:

BY USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

OUTPUT FOR ADDITION (INDIRECT METHOD):


BY USING MASM SOFTWARE:
REG NO:212214106291

BY USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

B) SUBTRACTION:

(i)DIRECT METHOD:

ALGORITHM:

Step I : Load address of first number in MC register pair.


Step II : Move first data into accumulator.
Step III : Increment the content of MC register pair.
Step IV : Subtract the second data from accumulator.
Step V : Store the result in Memory location.

PROGRAM

A)By using MASM


CODE SEGMENT
ASSUME CS: CODE,DS:CODE
ORG 1000H
MOV AX,1234H
MOV BX,1234H
SUB AX,BX
JNC LOOP
INC CL
LOOP:MOV SI,1200H
MOV [SI],AX
MOV [SI+2],CL
MOV AH,4CH
INT 21H
CODE ENDS
END
REG NO:212214106291

B)By using 8086 kit

MEMORY OP CODE LABEL MNEMONIC


LOCATION
1000 B8 1234 MOV AX,1234H
1003 BB 1234 MOV BX, 1234H
1006 03 C3 SUB AX,BX
1008 73 02 JNC LOOP(100C)
100A FE C1 INC CL
100C BE 1200 LOOP MOV SI,1200H
100F 89 04 MOV [SI],AX
1011 88 4C 02 MOV [SI+2],CL
1014 F4 HLT

(ii) INDIRECT METHOD:

ALGORITHM:

Step I : Initialize the memory location and store the 1st data.
Step II : Increment the content of AL and get the 2nd data.
Step III : Move the 2nd data in accumulator.
Step IV : Subtract the content of memory and store the result.

PROGRAM
A)By using MASM
CODE SEGMENT
ASSUME CS: CODE,DS:CODE
ORG 1000H
MOV SI,2000H
MOV CL,00H
MOV AX,[SI]
MOV BX,[SI+02H]
SUB AX,BX
JNC LOOP
INC CL
LOOP:
MOV [SI+04H],AX
MOV [SI+06H],CL
MOV AH,4CH
INT 21H
CODE ENDS
END
REG NO:212214106291

B)By using 8086 kit:

MEMORY LOCATION OP CODE LABEL MNEMONIC


1000 BE 2000 MOV SI,2000H
1003 B1 00 MOV CL,OOH
1005 8B 04 MOV AX,[SI]
1007 8B 5C 02 MOV BX [SI+04H], AX
100A 2B C3 SUB AX,BX
100C 73 02 JNC LOOP(1010)
100E FE C1 INC CL
1010 89 44 04 LOOP MOV [SI+04H],AX
1013 88 4C 06 MOV [SI+06H],CL
1016 F4 HLT
REG NO:212214106291

FLOWCHART(DITECT METHOD) FLOWCHART(INDIRECT


METHOD)
REG NO:212214106291
REG NO:212214106291

OUTPUT FOR SUBTRACTION(DIRECT METHOD)


BY USING MASM SOFTWARE:
REG NO:212214106291

BY USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

OUTPUT FOR SUBTRACTION(Indirect Method)


BY USING MASM SOFTWARE:

BY USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA
REG NO:212214106291

C) MULTIPLICATION

(i)DIRECT METHOD:

ALGORITHM:
Step I : Move the first number into the accumulator.
Step II : Increment the content of register pair.
Step III : Multiply both the data.
Step IV : Store the result in memory location.

PROGRAM

A)By using MASM


CODE SEGMENT
ASSUME CS: CODE,DS:CODE
ORG 1000H
MOV AX,1234H
MOV BX,1234H
MUL BX
MOV SI,1200H
MOV [SI],AX
MOV [SI+02H],DX
MOV AH,4CH
INT 21H
CODE ENDS
END

B)By using 8086 kit

MEMORY OP CODE LABEL MNEMONIC


REG NO:212214106291

LOCATION
1000 B8 12 34 MOV AX,1234H
1003 BB 12 34 MOV BX, 1234H
1006 F7 E3 MUL BX
1008 BE 12 00 MOV SI,1200H
100B 89 04 MOV [SI],AX
100D F4 HLT

(ii) INDIRECT METHOD:

ALGORITHM:

Step I : initialize the memory location of


Step II : increment the context of and get 2nd data
Step III : move the 2nd data in a accumulator.
Step IV : multiply the contents & store the result.

PROGRAM

A)By using MASM


CODE SEGMENT
ASSUME CS: CODE,DS:CODE
ORG 1000H
MOV SI,2000H
MOV AX,[SI]
MOV BX,[SI+02H]
MUL BX
MOV [SI+04H],AX
MOV [SI+06H],DX
MOV AH,4CH
INT 21H
CODE ENDS
END

B)By using 8086 kit:

MEMORY OP CODE LABEL MNEMONIC


LOCATION
REG NO:212214106291

1000 BE 20 00 MOV SI,2000H


1003 8B 04 MOV AX,[SI]
1005 8B 5C 02 MOV BX,[SI+02H]
1008 F7 E3 MUL BX
100A 89 44 04 MOV [SI+04H],AX
100D 89 54 06 MOV [SI+06H],DX
1010 F4 HLT

Flow chart (DIRECT METHOD) flowchart(INDIRECT METHOD)

MULTIPLY THE CONTENT OF BX USING


MUL INSTRUCTION

DIV INSTRUCTION
REG NO:212214106291

OUTPUT FOR MULTIPLICATION(DIRECT METHOD)

BY USING MASM SOFTWARE:

BY USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

OUTPUT FOR MULTIPLICATION(INDIRECT METHOD)


BY USING MASM SOFTWARE:
REG NO:212214106291

BY USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

D)DIVISION:

(i)DIRECT METHOD:

ALGORITHM:

Step I : load first no in register ax


Step II : store the 2nd data In register bx.
Step III : divide the content of ax by cx and result In ax.

PROGRAM

A)By using MASM


CODE SEGMENT
ASSUME CS: CODE,DS:CODE
ORG 1000H
MOV AX,1234H
MOV BX,1234H
DIV BX
MOV SI,1200H
MOV [SI],AX
MOV AH,4CH
INT 21H
CODE ENDS
REG NO:212214106291

END

B)By using 8086 kit

MEMORY OP CODE LABEL MNEMONIC


LOCATION
1000 B8 12 34 MOV AX,1234H
1003 BB 12 34 MOV BX, 1234H
1006 F7 F3 DIV BX
1008 BE 12 00 MOV SI,1200H
100B 89 04 MOV [SI],AX
100D 89 5C 02 MOV [SI+2].BX
1010 F4 HLT

(ii) INDIRECT METHOD:

ALGORITHM:

Step I : load memory location of datas in the reg pair


Step II : move data to accumulator & perform division
Step III : store the result.

PROGRAM

A)By using MASM


CODE SEGMENT
ASSUME CS: CODE,DS:CODE
ORG 1000H
MOV SI,2000H
MOV AX,[SI]
MOV BX,[SI+02H]
DIV BX
MOV [SI+04H],AX
MOV [SI+06H],DX
MOV AH,4CH
INT 21H
CODE ENDS
END
REG NO:212214106291

B)By using 8086 kit:

MEMORY LOCATION OP CODE LABEL MNEMONIC


1000 BE 20 00 MOV SI,2000H
1003 8B 04 MOV AX,[SI]
1005 8B 5C 02 MOV BX,[SI+02H]
1008 F7 F3 DIV BX
100A 89 44 04 MOV [SI+04H],AX
100D 89 54 06 MOV [SI+06H],DX
1010 F4 HLT
REG NO:212214106291

Flowchart (DIRECT METHOD): Flowchart (INDIRECT METHOD):


REG NO:212214106291

LOAD THE DEVIDEND IN REGISTER AX

LOAD THE DEVISOR IN REGISTER BX

DIVIDE THE CONTENT OF AX BY BX USING


DIV INSTRUCTION

STORE THE RESULT IN ACCUMULATOR

OUTPUT FOR DIVISION(DIRECT METHOD)


BY USING MASM SOFTWARE:
REG NO:212214106291

BY USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

OUTPUT FOR DIVISION(INDIRECT METHOD)


BY USING MASM SOFTWARE:

BY USING 8086 KIT:


REG NO:212214106291

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

RESULT :
Thus the Assembly language Program to perform arithmetic operations both direct and
indirect in 8086 microprocessor is written and executed both in MASM software and 8086 kit.
LOGICAL OPERATIONS USING 8086 MICROPROCESSOR
EX NO:
REG NO:212214106291

DATE:

AIM:

To write and execute Assembly language Program to perform logical operations for
8086 microprocessor

APPARATUS REQUIRED: 8086 microprocessor kit


Personal computer with MASM software

(i)ROTATE RIGHT:(DIRECT METHOD)

ALGORITHM:

Step I : Open command prompt.


Step II : Typr d: then cd masm->edit .
Step III : Then type the program.
Step IV : Initialize the memory location of 1st number.
Step V : Then increment the content of hl register pair and get second
data.
Step VI : Then perform the Rotate Right operation with accumulator and store
the result in memory location.
Step VII : For output type masm filename.asm,,;
link filename,,;
debug filename.exe
Step VIII : For displaying the output type d 2000
Step VIII : Stop.

PROGRAM :
A)By using MASM
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV AL,68H
MOV CL,04H
ROR AL,CL
MOV SI,2000H
MOV [SI],AL
MOV AH,4CH
INT 21H
CODE ENDS
END

B)By using 8086 kit


REG NO:212214106291

MEMORY LOCATION OPCODE LABEL MNEMONICS


1004 D2C8 MOV AL,68H
1006 BE 20 00 MOV CL,04H
1009 88 04 ROR AL,CL
100B B4 4C MOV SI,2000H
100D CD 21 MOV[SI], AL
100F F4 HLT

INDIRECT METHOD:
ALGORITHM:
Step I : Initialize the memory location for 1st data in HL register.
Step II : Store 1st data in memory location.
Step III : Increment the content of HL register for entering data in
memory location.
Step IV : Store second data in memory location.
Step V : Move 2nd number in accumulator.
Step VI : Decrease the content of HL register pair.
Step VII : Rotate right the content of memory with accumulator.
Step VIII : Store the result in memory location.
Step IX : Stop.

PROGRAM:
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,2000H
MOV AX,[SI]
MOV BX,[SI+02H]
ROR AX,BX
MOV [SI+04H],AX
MOV AH,4CH
INT 21H
CODE ENDS
END

B)By using 8086 kit


REG NO:212214106291

ADDRESS OPCODE LABEL MNEMONICS


1000 BE 20 00 MOV SI,2000H
1002 8B 04 MOV AX,[SI]
1004 8B 5C 02 MOV BX,[SI+02H]
1006 88 04 ROR AX,BX
1009 89 44 04 MOV [SI+04H],AX
100B F4 HLT

(ii) ROTATE LEFT:(DIRECT METHOD)

ALGORITHM:

Step I : Open command prompt.


Step II : Typr d: then cd masm->edit .
Step III : Then type the program.
Step IV : Initialize the memory location of 1st number.
Step V : Then increment the content of hl register pair and get second
data.
Step VI : Then perform the Rotate Left operation with accumulator and store the
result in memory location.
Step VII : For output type masm filename.asm,,;
link filename,,;
debug filename.exe
Step VIII : For displaying the output type d 2000
Step VIII : Stop.

PROGRAM
A)By using MASM
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV AL,68H
MOV CL,04H
ROL AL,CL
MOV SI,2000H
MOV [SI],AL
MOV AH,4CH
INT 21H
CODE ENDS
END

B)By using 8086 kit


REG NO:212214106291

ADDRESS OPCODE LABEL MNEMONICS


1000 B0 68 MOV AL,68H
1002 B1 04 MOV CL,04H
1004 D2C0 ROL AL,CL
1006 BE 20 00 MOV SI,2000H
1009 88 04 MOV [SI], AL
100B F4 HLT

INDIRECT METHOD:

ALGORITHM:
Step I : Initialize the memory location for 1st data in HL register.
Step II : Store 1st data in memory location.
Step III : Increment the content of HL register for entering data in
memory location.
Step IV : Store second data in memory location.
Step V : Move 2nd number in accumulator.
Step VI : Decrease the content of HL register pair.
Step VII : Rotate left the content of memory with accumulator.
Step VIII : Store the result in memory location.
Step IX : Stop.

PROGRAM:
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,2000H
MOV AX,[SI]
MOV BX,[SI+02H]
ROL AX,BX
MOV [SI+04H],AX
MOV AH,4CH
INT 21H
CODE ENDS
END

B)By using 8086 kit


REG NO:212214106291

ADDRESS OPCODE LABEL MNEMONICS


1000 BE 20 00 MOV SI,2000H
1002 8B 04 MOV AX,[SI]
1004 8B 5C 02 MOV BX,[SI+02H]
1006 D2 C0 ROL AX,BX
1009 89 44 04 MOV [SI+04H],AX
100B F4 HLT

(iii)SHIFT RIGHT:(DIRECT METHOD)

ALGORITHM:

Step I : Open command prompt.


Step II : Typr d: then cd masm->edit .
Step III : Then type the program.
Step IV : Initialize the memory location of 1st number.
Step V : Then increment the content of hl register pair and get second
data.
Step VI : Then perform the Shift Right operation with accumulator and store the
result in memory location.
Step VII : For output type masm filename.asm,,;
link filename,,;
debug filename.exe
Step VIII : For displaying the output type d 2000
Step VIII : Stop.

PROGRAM :
A)By using MASM
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV AL,68H
MOV CL,04H
SHR AL,CL
MOV SI,2000H
MOV [SI],AL
MOV AH,4CH
INT 21H
CODE ENDS
END

B)By using 8086 kit


REG NO:212214106291

ADDRESS LABEL OPCODE Mnemonics


1000 B0 68 MOV AL,68H
1002 B1 04 MOV CL,04H
1004 D2E8 SHR AL,CL
1006 BE 20 00 MOV SI,2000H
1009 88 04 MOV [SI],AL
100B F4 HLT

INDIRECT METHOD:

ALGORITHM:
Step I : Initialize the memory location for 1st data in HL register
Step II : Store 1st data in memory location.
Step III : Increment the content of HL register for entering data in
memory location.
Step IV : Store second data in memory location.
Step V : Move 2nd number in accumulator.
Step VI : Decrease the content of HL register pair.
Step VII : Shift right the content of memory with accumulator.
Step VIII : Store the result in memory location.
Step IX : Stop.

PROGRAM:
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,2000H
MOV AX,[SI]
MOV BX,[SI+02H]
SHR AX,BX
MOV [SI+04H],AX
MOV AH,4CH
INT 21H
CODE ENDS
END

B)By using 8086 kit


REG NO:212214106291

ADDRESS OPCODE LABEL MNEMONICS


1000 BE 20 00 MOV SI,2000H
1002 8B 04 MOV AX,[SI]
1004 8B 5C 02 MOV BX,[SI+02H]
1006 D2 F0 SHR AX,BX
1009 89 44 04 MOV [SI+04H],AX
100B F4 HLT

iv)SHIFT LEFT:(DIRECT METHOD)


ALGORITHM:
Step I : Open command prompt.
Step II : Type d: then cd masm->edit .
Step III : Then type the program.
Step IV : Initialize the memory location of 1st number.
Step V : Then increment the content of hl register pair and get second
data.
Step VI : Then perform the Shift Left operation with accumulator and store the
result in memory location.
Step VII : For output type masm filename.asm,,;
link filename,,;
debug filename.exe
Step VIII : For displaying the output type d 2000
Step VIII : Stop.

PROGRAM

A)By using MASM


CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV AL,68H
MOV CL,04H
SHL AL,CL
MOV SI,2000H
MOV [SI],AL
MOV AH,4CH
INT 21H
CODE ENDS
END

B)By using 8086 kit:


REG NO:212214106291

MEMORY LOCATION OP CODE LABEL MNEMONIC


1000 B0 68 MOV AL,68H
1002 B1 04 MOV CL,04H
1004 D2 F0 SHL AL,CL
1006 BE 20 00 MOV SI,2000H
1009 88 04 MOV[SI], AL
100B F4 HLT

INDIRECT METHOD:

ALGORITHM:
Step I : Initialize the memory location for 1st data in HL register
Step II : Store 1st data in memory location.
Step III : Increment the content of HL register for entering data in
memory location.
Step IV : Store second data in memory location.
Step V : Move 2nd number in accumulator.
Step VI : Decrease the content of HL register pair.
Step VII : shift left the content of memory with accumulator.
Step VIII : Store the result in memory location.
Step IX : Stop.

PROGRAM:
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,2000H
MOV AX,[SI]
MOV BX,[SI+02H]
SHL AX,BX
MOV [SI+04H],AX
MOV AH,4CH
INT 21H
CODE ENDS
END

B)By using 8086 kit


REG NO:212214106291

ADDRESS OPCODE LABEL MNEMONICS


1000 BE 20 00 MOV SI,2000H
1002 8B 04 MOV AX,[SI]
1004 8B 5C 02 MOV BX,[SI+02H]
1006 D2 F0 SHL AX,BX
1009 89 44 04 MOV [SI+04H],AX
100B F4 HLT

(v)AND:(DIRECT METHOD)

ALGORITHM:

Step I : Open command prompt.


Step II : Typr d: then cd masm->edit .
Step III : Then type the program.
Step IV : Initialize the memory location of 1st number.
Step V : Then increment the content of hl register pair and get second
data.
Step VI : Then perform the AND operation with accumulator and store the
result in memory location.
Step VII : For output type masm filename.asm,,;
link filename,,;
debug filename.exe
Step VIII : For displaying the output type d 2000
Step VIII : Stop.

PROGRAM
A)By using MASM
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV AX,68H
MOV CX,04H
AND AX,CX
MOV SI,2000H
MOV [SI],AX
MOV AH,4CH
INT 21H
CODE ENDS
END
REG NO:212214106291

B)By using 8086 kit

MEMORY LOCATION OP CODE LABEL MNEMONIC


1000 B8 00 49 MOV AX,68H
1003 B9 00 03 MOV CX,04H
1006 23 C1 AND AX,CX
1008 BE 20 00 MOV SI,2000H
100B 89 04 MOV[SI], AX
100D B4 4C MOV AH,4CH
100F CD 21 INT 21H

INDIRECT METHOD:

ALGORITHM:
Step I : Initialize the memory location for 1st data in HL register
Step II : Store 1st data in memory location.
Step III : Increment the content of HL register for entering data in
memory location.
Step IV : Store second data in memory location.
Step V : Move 2nd number in accumulator.
Step VI : Decrease the content of HL register pair.
Step VII : AND the content of memory with accumulator.
Step VIII : Store the result in memory location.
Step IX : Stop.

PROGRAM:
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,2000H
MOV AX,[SI]
MOV BX,[SI+02H]
AND AX,BX
MOV [SI+04H],AX
MOV AH,4CH
INT 21H
CODE ENDS
END
REG NO:212214106291

B)By using 8086 kit

ADDRESS OPCODE LABEL MNEMONICS


1000 BE 20 00 MOV SI,2000H
1002 8B 04 MOV AX,[SI]
1004 8B 5C 02 MOV BX,[SI+02H]
1006 23 C3 AND AX,BX
1009 89 44 04 MOV [SI+04H],AX
100B F4 HLT

(vi)OR:(DIRECT METHOD)

ALGORITHM:

Step I : Open command prompt.


Step II : Type d: then cd masm->edit .
Step III : Then type the program.
Step IV : Initialize the memory location of 1st number.
Step V : Then increment the content of hl register pair and get second
data.
Step VI : Then perform the OR operation with accumulator and store the
result in memory location.
Step VII : For output type masm filename.asm,,;
link filename,,;
debug filename.exe
Step VIII : For displaying the output type d 2000
Step VIII : Stop.

PROGRAM
A)By using MASM
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV AX,68H
MOV CX,04H
OR AX,CX
MOV SI,2000H
MOV [SI],AX
MOV AH,4CH
INT 21H
CODE ENDS
REG NO:212214106291

END
B)By using 8086 kit:

MEMORY OP CODE LABEL MNEMONIC


LOCATION
1000 B8 00 49 MOV AX,68H
1003 B9 00 03 MOV CX,04H
1006 0B C1 OR AX,CX
1008 BE 20 00 MOV SI,2000H
100B 89 04 MOV[SI], AX
100D F4 F4

INDIRECT METHOD:

ALGORITHM:
Step I : Initialize the memory location for 1st data in HL register
Step II : Store 1st data in memory location.
Step III : Increment the content of HL register for entering data in
memory location.
Step IV : Store second data in memory location.
Step V : Move 2nd number in accumulator.
Step VI : Decrease the content of HL register pair.
Step VII : OR the content of memory with accumulator.
Step VIII : Store the result in memory location.
Step IX : Stop.

PROGRAM:
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,2000H
MOV AX,[SI]
MOV BX,[SI+02H]
OR AX,BX
MOV [SI+04H],AX
MOV AH,4CH
INT 21H
CODE ENDS
END
REG NO:212214106291

B)By using 8086 kit

ADDRESS OPCODE LABEL MNEMONICS


1000 BE 20 00 MOV SI,2000H
1002 8B 04 MOV AX,[SI]
1004 8B 5C 02 MOV BX,[SI+02H]
1006 0B C3 OR AX,BX
1009 89 44 04 MOV [SI+04H],AX
100B F4 HLT

(vii)XOR:(DIRECT METHOD)

ALGORITHM:

Step I : Open command prompt.


Step II : Typr d: then cd masm->edit .
Step III : Then type the program.
Step IV : Initialize the memory location of 1st number.
Step V : Then increment the content of hl register pair and get second
data.
Step VI : Then perform the XOR operation with accumulator and store the
result in memory location.
Step VII : For output type masm filename.asm,,;
link filename,,;
debug filename.exe
Step VIII : For displaying the output type d 2000
Step VIII : Stop.

PROGRAM
A)By using MASM
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV AX,68H
MOV CX,04H
XOR AX,CX
MOV SI,2000H
MOV [SI],AX
MOV AH,4CH
INT 21H
CODE ENDS
REG NO:212214106291

END

B)By using 8086 kit:

MEMORY OP CODE LABEL MNEMONIC


LOCATION
1000 B8 00 49 MOV AX,68H
1003 B9 00 03 MOV CX,04H
1006 33 C1 XOR AX,CX
1008 BE 20 00 MOV SI,2000H
100B 89 04 MOV[SI], AX
100D F4 HLT

INDIRECT METHOD:

ALGORITHM:
Step I : Initialize the memory location for 1st data in HL register
Step II : Store 1st data in memory location.
Step III : Increment the content of HL register for entering data in
memory location.
Step IV : Store second data in memory location.
Step V : Move 2nd number in accumulator.
Step VI : Decrease the content of HL register pair.
Step VII : XOR the content of memory with accumulator.
Step VIII : Store the result in memory location.
Step IX : Stop.

PROGRAM:
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,2000H
MOV AX,[SI]
MOV BX,[SI+02H]
XOR AX,BX
MOV [SI+04H],AX
MOV AH,4CH
INT 21H
CODE ENDS
END
REG NO:212214106291

B)By using 8086 kit

ADDRESS OPCODE LABEL MNEMONICS


1000 BE 20 00 MOV SI,2000H
1002 8B 04 MOV AX,[SI]
1004 8B 5C 02 MOV BX,[SI+02H]
1006 33 C 3 XOR AX,BX
1009 89 44 04 MOV [SI+04H],AX
100B F4 HLT

(viii)NOT:(DIRECT METHOD)

ALGORITHM:

Step I : Open command prompt.


Step II : Typr d: then cd masm->edit .
Step III : Then type the program.
Step IV : Initialize the memory location of 1st number.
Step V : Then increment the content of hl register pair and get second
data.
Step VI : Then perform the NOT operation with accumulator and store the
result in memory location.
Step VII : For output type masm filename.asm,,;
link filename,,;
debug filename.exe
Step VIII : For displaying the output typed 2000
Step VIII : Stop.
PROGRAM
A)By using MASM
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV AX,68H
NOT AX
MOV SI,2000H
MOV [SI],AX
MOV AH,4CH
INT 21H
CODE ENDS
END
REG NO:212214106291

B)By using 8086 kit:

MEMORY OP CODE LABEL MNEMONIC


LOCATION
1000 B8 00 49 MOV AX,68H
1003 F7 D0 NOT AX
1005 BE 20 00 MOV SI,2000H
1008 89 04 MOV[SI], AX
100A F4 HLT

INDIRECT METHOD:

ALGORITHM:
Step I : Initialize the memory location for 1st data in HL register
Step II : Store 1st data in memory location.
Step III : Increment the content of HL register for entering data in
memory location.
Step IV : NOT the content of memory with accumulator.
Step V : Store the result in memory location.
Step VI : Stop.

PROGRAM:
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,2000H
MOV AX,[SI]
NOT AX
MOV [SI+02H],AX
MOV AH,4CH
INT 21H
CODE ENDS
END

B)By using 8086 kit

ADDRESS OPCODE LABEL MNEMONICS


1000 BE 20 00 MOV SI,2000H
1002 8B 04 MOV AX,[SI]
REG NO:212214106291

1004 F7 D0 NOT AX
1006 89 44 02 MOV [SI+02H],AX
1009 F4 HLT

OUTPUT FOR ROATE RIGHT


BY USING MASM SOFTWARE

BY USING 8086 KIT

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

OUTPUT FOR ROATE LEFT


BY USING MASM SOFTWARE
REG NO:212214106291

BY USING 8086 KIT

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

OUTPUT FOR SHFIT RIGHT


BY USING MASM SOFTWARE

BY USING 8086 KIT

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

OUTPUT FOR SHFIT LEFT


BY USING MASM SOFTWARE
REG NO:212214106291

BY USING 8086 KIT

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

OUTPUT FOR AND


BY USING MASM SOFTWARE

BY USING 8086 KIT

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

OUTPUT FOR OR
BY USING MASM SOFTWARE
REG NO:212214106291

BY USING 8086 KIT

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

OUTPUT FOR XOR


BY USING MASM SOFTWARE

BY USING 8086 KIT

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

OUTPUT FOR NOT


BY USING MASM SOFTWARE
REG NO:212214106291

BY USING 8086 KIT

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

RESULT :
REG NO:212214106291

Thus the Assembly language Program to logical operations in 8086 microprocessor is


written and executed both in MASM software and 8086 kit.

BCD ADDITION USING 8086 MICROPROCESSOR


EX NO:

DATE:

AIM:
To write and execute Assembly language Program to perform BCD addition for 8086
microprocessor

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 1

2. Power Supply +5 V dc,+12 V dc 1

3. ADC Interface board - 1

ALGORITHM:

Step I : Open command prompt.


Step II : Type d: then cd masm->edit .
Step III : Then type the program.
Step IV : Initialize the memory location of 1st number.
Step V : Then increment the content of hl register pair and get second
data.
Step VI : Then perform the operation with accumulator and store the
result in memory location.
Step VII : For output type masm filename.asm,,;
link filename,,;
debug filename.exe
Step VIII : Stop.

PROGRAM :

C) By using MASM
REG NO:212214106291

CODE SEGMENT
ASSUME CS: CODE,DS:CODE
ORG 1000H
MOV SI,2000H
MOV CL,00H
MOV AX,[SI]
MOV BX,[SI+2]
ADD AL,BL
DAA
MOV DL,AL
MOV AL,AH
ADC AL,BH
DAA
MOV DH,AL
JNC AHEAD
INC CL
AHEAD:MOV[SI+4],DX
MOV[SI+6],CL
MOV AH,4CH
INT 21H
CODE ENDS
END

B)By using 8086 kit

MEMORY OPCODE LABEL MNEMONIC


LOCATION
1000 BE 20 00 MOV SI,2000H
1003 B1 00 MOV CL,00H
1005 8B 04 MOV AX,[SI]
1007 8B 5C 02 MOV BX.[SI+2]
100A 02 C3 ADD AL,BL
100C 27 DAA

100D 8A D0 MOV DL,AL

100F 8A C4 MOV AL,AH

1011 12 C4 ADC AL,BH

1013 27 DAA
REG NO:212214106291

1014 8A F0 MOV DH,AC

1016 73 00 JNC D

1018 FE C1 AHEAD MOV [SI+4],DX

101A 89 54 04 MOV [SI+6],CL

OUTPUT FOR BCD ADDITION :


BY USING MASM SOFTWARE:

BY USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA
REG NO:212214106291

RESULT :
Thus the Assembly language Program to perform BCD addition in 8086
microprocessor is written and executed in MASM software and 8086 kit.
ARITHMETIC OPERATIONS OF TWO N*N MATRICES
EX NO:

DATE:

AIM:
To write and execute Assembly language Program to perform arithmetic operations of
two n*n matrices for 8086 microprocessor

APPARATUS REQUIRED: 8086 microprocessor kit


Personal computer with MASM software

A)ADDITION OF TWO N*N MATRICES

ALGORITHM:

Step I : Initialize the pointer to memory for data and result.


Step II :Load CL with count.
Step III : Add two matrices by each element.
Step IV : Process continues until CL is 0.
Step V : Store the result into Memory.

PROGRAM
A) By using MASM
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,1500H
MOV BX,0050H
MOV DI,1600H
MOV CL,04H
L2:MOV CH,00H
MOV AX,[SI+BX]
ADD AX,[SI]
JNC L1
INC CH
L1:MOV [DI],AX
ADD DI,02H
MOV [DI],CH
INC DI
ADD SI,02H
REG NO:212214106291

DEC CL
JNZ L2
MOV AH,4CH
INT 21H
CODE ENDS
END

B) By using 8086 kit


MEMORY LOCATION OP CODE LABEL MNEMONIC
1000 BE 15 00 MOV SI,1500H
1003 BB 00 50 MOV BX,0050H
1006 BF 16 00 MOV DI,1600H
1009 B5 04 MOV CL,04H
100B B1 00 L2 MOV CH,00H
100D 8B 00 MOV AX,[SI+BX]
100F 2B 04 ADD AX,[SI]
1011 73 04 JNC L1(1015)
1013 FE C5 INC CH
1015 F7 D8 L1 MOV [DI],AX
1017 89 05 ADD DI,02H
1019 83 C7 02 MOV [DI],CH
101C 88 2D INT DI
101E 47 ADD SI,02H
101F 83 C6 02 DEC CL
1022 FE C9 JNC L2(100B)
1024 F4 HLT
REG NO:212214106291

FLOWCHART:
REG NO:212214106291

OUTPUT FOR ADDITION OF TWO N*N MATRICES


BY USING MASM SOFTWARE:

BY USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA
REG NO:212214106291

B) SUBTRACTION OF TWO N*N MATRICES

ALGORITHM:

Step I : Initialize the pointer to memory for data and result.


Step II :Load CL with count.
Step III :subtractiontwo matrices by each element.
Step IV : Process continues until CL is 0.
Step V : Store the result into Memory.

PROGRAM
A) By using MASM

CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,1500H
MOV BX,0050H
MOV DI,1600H
MOV CL,04H
L2:MOV CH,00H
MOV AX,[SI+BX]
SUB AX,[SI]
JNC L1
INC CH
L1:MOV [DI],AX
ADD DI,02H
MOV [DI],CH
INC DI
ADD SI,02H
DEC CL
JNZ L2
MOV AH,4CH
INT 21H
CODE ENDS
END

B) By using 8086 kit


MEMORY LOCATION OP CODE LABEL MNEMONIC
1000 BE 15 00 MOV SI,1500H
1003 BB 00 50 MOV BX,0050H
1006 BF 16 00 MOV DI,1600H
REG NO:212214106291

1009 B5 04 MOV CL,04H


100B B1 00 L2 MOV CH,00H
100D 8B 00 MOV AX,[SI+BX]
100F 2B 04 SUB AX,[SI]
1011 73 04 JNC L1(1017)
1013 FE C1 INC CH
1015 89 05 L1 MOV [DI],AX
1017 83 C7 02 ADD DI,02H
101A 88 2D MOV [DI],CH
101C 49 INC DI
101D 83 C6 02 ADD SI,02H
1021 FE C9 DEC CL
1023 73 E5 JNC L2(100B)
1025 F4 HLT

OUTPUT FOR SUBTRACTION OF TWO N*N MATRICES


BY USING MASM SOFTWARE:
REG NO:212214106291

BY USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

RESULT:
REG NO:212214106291

Thus the Assembly language Program to perform arithmetic operations of two n*n matrices for
8086 microprocessor is written and executed both in MASM software and 8086 microprocessor
kit.

CODE CONVERSIONS
EX NO:

DATE:

AIM:
To write and execute Assembly language Program to code conversions for 8086
microprocessor

APPARATUS REQUIRED: 8086 microprocessor kit


Personal computer with MASM software

A)BCD TO BINARY DATA

AlGORITHM:

Step I : Store the 8bit data into the BL register.


Step II : Move the BL register data into the AL,DLregisters.
Step III : Rotate right the AL,CLregister,multiply and store the result in DH
register .
Step IV : perform addition on AL,DL registers.
Step V : Store the result into Memory.
PROGRAM
A)By using MASM
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
MOV BL,75
MOV AL,BL
MOV DL,AL
AND DL,0FH
AND AL,0F0H
MOV CL,4
ROR AL,CL
MOV DH,0AH
MUL DH
ADD AL,DL
MOV [BX+1],AL
MOV SI,1200H
REG NO:212214106291

MOV [SI],BX
MOV AH,4CH
INT 21H
CODE ENDS
END

B)By using 8086 kit

MEMORY LOCATION OP CODE LABEL MNEMONIC


1000 B3 4B MOV BL,75
1002 8A C3 MOV AL,BL
1004 8A D0 MOV DL,AL
1006 24 0F AND AL,OFH
1008 24 F0 MOV CL,4
100A B1 04 ROR AL,CL
100C D2 C8 MOV DH,0AH
100E B6 0A MUL DH
1010 F6 E6 ADD AL,DL
1012 02 C2 MOV [ BX +1],AL
1014 88 47 01 MOV SI,1200H
1017 BE 12 00 MOV[SI],BX
101A F4 HLT

OUTPUT FOR BCD TO BINARY:


USING MASM SOFTWARE:
REG NO:212214106291

USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

B)PACKEDBCD TO UNPACKED BCD

AlGORITHM:

Step I : Store the 16bit data into the AX register.


Step II : Move the AL register data into the AH,registers.
Step III : Shift right the Ah,CL register.
Step IV : perform and operation on AX,0F0FH.
Step V : Store the result into Memory.

PROGRAM
A)By using MASM
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV AX,45H
MOV AH,AL
MOV CL,4H
SHR AH,CL
AND AX,0F0FH
MOV SI,1200H
MOV [SI],AX
MOV AH,4CH
INT 21H
CODE ENDS
END
REG NO:212214106291

B)By using 8086 kit

MEMORY LOCATION OP CODE LABEL MNEMONIC


1000 B8 0045 MOV AX,45H
1003 8A E0 MOV AH,AL
1005 B1 04 MOV CL,4H
1007 D2 EC SHR AH,CL
1009 25 0F0F AND AX,0F0FH
100C BE 1200 MOV SI,1200H
100F 89 04 MOV [SI],AX
1011 F4 HLT

OUTPUT FOR PACKED BCD TO UNPACKED BCD


USING MASM SOFTWARE:

USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA
REG NO:212214106291

RESULT:

Thus the Assembly language Program to perform code conversions for 8086 microprocessor is
written and executed both in MASM software and 8086 microprocessor kit.

SORTING AN ARRAY FOR 8086 MICROPROCESSOR


EX NO:

DATE:

AIM:
To write and execute Assembly language Program to sort the given numbers in ascending
and descending order for 8086 microprocessor

APPARATUS REQUIRED:
8086 microprocessor kit
Personal computer with MASM software

ALGORITHM: (ASCENDING ORDER)

Step I : Initialize the number of elements counter.


Step II : Initialize the number of comparisons counter.
Step III : Compare the elements. If first element < second element goto
step VIII else go to step V.
Step IV : Swap the elements.
Step V : Decrement the comparison counter.
Step VI : Is count = 0 ?if yes go to step VIII else go to step IV.
Step VII : Insert the number in proper position
Step VIII : Increment the number of elements counter.
Step IX : Is count = N ? If yes, go to step XI else go to step II
Step X : Store the result.
Step XI : Stop.

ALGORITHM :( DESCENDING ORDER)

Step I : Initialize the number of elements counter.


Step II : Initialize the number of comparisons counter.
Step III : Compare the elements. If first element > second element goto
step VIII else goto step V.
Step IV : Swap the elements.
Step V : Decrement the comparison counter.
Step VI : Is count = 0 ? If yes, goto step VIII else goto step IV.
Step VII : Insert the number in proper position.
REG NO:212214106291

Step VIII : Increment the elements counter.


Step IX : Is count = N ? If yes, goto step XI else goto step II.
Step X : Stop

PROGRAM (ASCENDING ORDER):


A) By using MASM
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV BL,00H
GO2:MOV SI,2000H
MOV CX.[SI]
INC SI
INC SI
DEC CX
GO1:MOV AX,[SI]
CMP AX,[SI+02H]
JC GO
XCHG AX,[SI+02H]
MOV [SI], AX
MOV BL,0H
GO: ADD SI,02H
LOOP GO1
DEC BL
JZ GO2
MOV AH,4CH
INT 21H
CODE ENDS
END

B) By using 8086 kit

MEMORY
OP CODE LABEL MNEMONIC
LOCATION
1000 B3 00 MOV BL,00H
1002 BE 2000 GO2 MOV SI,2000H
1005 8B 0C MOV CX,[SI]
1007 46 INC SI
1008 46 INC SI
1009 49 DEC CX
100A 8B 04 GO1 MOV AX,[SI]
REG NO:212214106291

100C 3B 44 02 CMP AX,[SI+02H]


100F 73 07 JC GO(1018)
1011 87 44 02 XCHG AX,[SI+02H]
1014 89 04 MOV [SI], AX
1016 B3 00 MOV BL,01H
1018 83 C6 02 GO ADD SI,02H
101B E2 ED LOOP GO1(100A)
101D FE CB DEC BL
101F 74 E1 JZ GO2(1002)
1021 F4 HLT

PROGRAM (DESCENDING ORDER):


A) By using MASM
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV BL,OOH
GO2:MOV SI,2000H
MOV CX.[SI]
INC SI
INC SI
DEC CX
GO1:MOV AX,[SI]
CMP AX,[SI+02H]
JNC GO
XCHG AX,[SI+02H]
MOV [SI], AX
MOV BL,0H
GO: ADD SI,02H
LOOP GO1
DEC BL
JZ GO2
MOV AH,4CH
INT 21H
CODE ENDS
END
REG NO:212214106291

B) By using 8086 kit

MEMORY
OP CODE LABEL MNEMONIC
LOCATION
1000 B3 00 MOV BL,00H
1002 BE 2000 GO2 MOV SI,2000H
1005 8B 0C MOV CX,[SI]
1007 46 INC SI
1008 46 INC SI
1009 49 DEC CX
100A 8B 04 GO1 MOV AX,[SI]
100C 3B 44 02 CMP AX,[SI+02H]
100F 73 07 JNC GO(1018)
1011 87 44 02 XCHG AX,[SI+02H]
1014 89 04 MOV [SI], AX
1016 B3 00 MOV BL,01H
1018 83 C6 02 GO ADD SI,02H
101B E2 ED LOOP GO1(100A)
101D FE CB DEC BL
101F 74 E1 JZ GO2(1002)
1021 F4 HLT
REG NO:212214106291

FLOWCHART:
ASCENDING ORDER:
REG NO:212214106291

DESCENDING ORDER:
REG NO:212214106291

OUTPUT FOR ASCENDING ORDER


BY USING MASM SOFTWARE:

BY USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA
REG NO:212214106291

OUTPUT FOR DESCENDING ORDER


BY USING MASM SOFTWARE:

OUTPUT FOR DESCENDING ORDER (BY USING 8086 KIT):

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA
REG NO:212214106291

RESULT :
Thus the Assembly language Program to sort the given numbers in ascending and descending
order for 8086 microprocessor is written and executed both in MASM software and 8086
microprocessor kit.
SEARCHING FOR A NUMBER OR CHARACTER IN A STRING FOR
8086 MICROPROCESSOR
EX NO:

DATE:

AIM:
To write and execute Assembly language Program to search a number or character from a
string for 8086 Microprocessor

APPARATUS REQUIRED: 8086 microprocessor kit


Personal computer with MASM software

ALGORITHM:

Step I : Allocate some spaces to enter the total elements, search


element and the no of times it is present
Step II : Input the values in the array
Step III : End of data segment.
Step IV : In first module get the size of array as input and set the
counter register
Step V : In second module push CX in stack and get all the elements
in the array and the number to be searched as input from the
user and store them in array.
Step VI : In top of the stack, compare the values and if present jump to
count and display, Otherwise search in the next location.
Step VII : Then display the result as true position of the number.
Step VIII : Terminate the program.
REG NO:212214106291

PROGRAM
A) By using MASM
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,2000H
MOV DI,2100H
MOV DL,[DI]
MOV BL,01H
MOV AL,[SI]
GO1:CMP AL,DL
JZ GO
INC SI
INC BL
MOV AL,[SI]
CMP AL,DL
JNZ GO1
GO:MOV [DI+01H],BL
MOV [DI+02H],SI
MOV AH,4CH
INT 21H
CODE ENDS
END
B) By using 8086 kit

MEMORY LOCATION OP CODE LABEL MNEMONIC


1003 BF 2100 MOV SI,2000H
1006 8A 15 MOV DI,2100H
1008 B3 01 MOV DL,[DI]
100A 8A 04 MOV BL,01H
100C 3A C2 MOV AL,[SI]
100E 74 15 GO1 CMP AL,DL
1010 46 JZ GO(1027)
1011 FE C3 INC SI
1013 8A 04 INC BL
1015 3C 14 MOV AL,[SI]
1017 75 F3 CMP AL,DL
1019 B9 0000 JNZ GO1(100E)
REG NO:212214106291

1027 89 75 03 GO MOV [DI+01H],BL


102A 89 75 03 MOV [DI+02H],SI
102E F4 HLT

FLOWCHART:
REG NO:212214106291

OUTPUT FOR SEARCHING A NUMBER


BY USING MASM SOFTWARE:

BY USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

RESULT :
REG NO:212214106291

Thus the Assembly language Program to searching for a number or character in a string for 8086
microprocessor is written and executed both in MASM software and 8086 microprocessor kit.

STRING MANIPULATION USING 8086 MICROPROCESSOR


EX NO:

DATE:

AIM:
To write and execute Assembly language Program for string manipulation using 8086
Microprocessor

APPARATUS REQUIRED: 8086 microprocessor kit


Personal computer with MASM software

ALGORITHM:

Step : Load the source and destination index register with starting
and the ending address respectively
Step II : Initialize the counter with the total number of words to be
copied.
Step III : Clear the direction flag for auto incrementing mode of
transfer.
Step IV : Use the string manipulation instruction SCASW with the
prefix REP to search a word from string.
Step V : If a match is found (z=1), display 01 in destination address.
Otherwise, display 00 in destination address

PROGRAM
A) By using MASM
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV AH,09H
MOV DX,1200H
INT 21H
MOV AH,4CH
INT 21H
ORG 1200H
REG NO:212214106291

DB “MICROPROCESSOR$”
CODE ENDS
END

B) By using 8086 kit

MEMORY LOCATION OP CODE LABEL MNEMONIC


1000 B4 09 MOV AH,09H
1002 BA 1200 MOV DX,1200H
1005 CD 21 INT 21H
1007 B4 4C MOV AH,4CH
1009 CD 21 INT 21H
1200 ORG 1200H
1200 4D 49 43 52 4F 50 DB “MICROPROCESSOR$”
52 4F 43 45 53 53
4F 52 24
120F F4 HLT

Flowchart:

Move count to cx register

Move input address to DI register

Move the that to AX register

Clear directional flag

Store byte string


REG NO:212214106291

OUTPUT FOR STRING MANIPULATION

BY USING MASM SOFTWARE:

BY USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA
REG NO:212214106291

RESULT :
Thus the Assembly language Program to perform string manipulation using 8086
Microprocessor is written and executed both in MASM software and 8086 microprocessor kit.

MOVING BLOCK OF DATA FOR 8086 MICROPROCESSOR


EX NO:

DATE:

AIM:

To write and execute Assembly language Program to implement moving block of data
for 8086 microprocessor

APPARATUS REQUIRED: 8086 microprocessor kit


Personal computer with MASM software

ALGORITHM :

Step I : Initialize the pointer to the memory where Data to be transferred.


Step II : Load the AL register with the data from memory.
Step III : Initialize destination pointer to the memory Wheredata to be stored
Step IV : Store data from AL register

PROGRAM
A) By using MASM

CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,1400H
MOV CL,[SI]
MOV SI,1500H
MOV DI,1600H
LI: MOV AX,[SI]
MOV [DI] ,AX
ADD SI,02H
ADD DI,02H
DEC CL
JNZ LI
MOV AH,4CH
INT 21H
CODE ENDS
REG NO:212214106291

END

B) By using 8086 kit

MEMORY LOCATION OP CODE LABEL MNEMONIC


1000 BE 1400 MOV SI,1400H
1003 8A 0C MOV CL,[SI]
1005 BF 1500 MOV SI,1500H
1008 BF 1600 MOV DI,1600H
100B 8B 04 L1 MOV AX,[SI]
100D 89 05 MOV[DI],AX
100F 83 C6 02 ADD SI,02H
1012 83 C7 02 ADD DI,02H
1015 FE C9 DEC CL
1017 75 F2 JNZ L1(100B)
1019 F4 HLT
REG NO:212214106291

FLOWCHART:
REG NO:212214106291

OUTPUT FORMOVING BLOCK OF DATA


BY USING MASM SOFTWARE:

BY USING 8086 KIT:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA
REG NO:212214106291

RESULT:

Thus the Assembly language Program to implement moving block of data for 8086
microprocessor is written and executed both in MASM software and 8086 microprocessor kit.

INTERFACING ANALOG TO DIGITAL CONVERTER AND


DIGITAL TO ANALOG CONVERTER

EX NO:

DATE:

ANALOG TO DIGITAL CONVERTER:

AIM:

To write an assembly language program to convert an analog signal into a digital signal using an
ADC interfacing.

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 1

2. Power Supply +5 V dc,+12 V dc 1

3. ADC Interface board - 1

PROBLEM STATEMENT:

The program is executed for various values of analog voltage which are set with the help of
a potentiometer. The LED display is verified with the digital value that is stored in a
memory location.

THEORY:
REG NO:212214106291

An ADC usually has two additional control lines: the SOC input to tell the ADC when to
start the conversion and the EOC output to announce when the conversion is complete. The
following program initiates the conversion process, checks the EOC pin of ADC 0809 as to
whether the conversion is over and then inputs the data to the processor. It also instructs
the processor to store the converted digital data at RAM location.

ALGORITHM:

Step I : Select the channel and latch the address.

Step II : Send the start conversion pulse.

Step III : Read EOC signal.

Step IV : If EOC = 1 continue else go to step (iii)

Step V : Read the digital output.

Step VI :Store it in a memory location.

FLOW CHART:

NO

YES
REG NO:212214106291

Output

ANALOG DIGITAL DATA ON LED HEX CODE IN MEMORY


VOLTAGE DISPLAY LOCATION

PROGRAM TABLE

MEMORY OPCODE PROGRAM COMMENTS

LOCATION

1000 C6 C0 10 MOV AL,10H Load accumulator with value for


ALE high
1003 E6 C8 OUT 0C8H,AL Send through output port
1005 C6 C0 18 MOV AL,18H Load accumulator with value for
ALE low
1008 E6 C8 OUT 0C8H,AL Send through output port
100A C6 C0 09 MOV AL,9H Store the value to make SOC high in
the accumulator
REG NO:212214106291

100D E6 D0 OUT 0D0H,AL Send through output port


100F C6 C0 00 MOV AL,00H Introduce delay
1012 E6 D0 OUT 0D0H,AL Send through output port
1014 E4 D8 LOOP: IN AL, 0D8H
1016 80 E0 01 AND AL,01H Read the EOC signal from port &
check for end of conversion
1019 80 F8 01 CMP AL,01H
101C 75 F6 JNZ LOOP If the conversion is not yet
completed, read EOC signal
from port again
101E E4 C0 IN AL,0C0H Read data from port
1020 C7 C3 00 11 MOV BX,1100H Initialize the memory location to
store data
1024 88 07 MOV [BX],AL Store the data
1026 F4 HLT Stop
REG NO:212214106291

RESULT:

Thus the ADC was interfaced with 8086 and the given analog inputs were converted into its
digital equivalent.

DIGITAL TO ANALOG CONVERTER

AIM :

1. To write an assembly language program for digital to analog conversion


2. To convert digital inputs into analog outputs & To generate different waveforms

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 Vi Microsystems 1

2. Power Supply +5 V, dc,+12 V dc 1

3. DAC Interface board - 1

PROBLEM STATEMENT:

The program is executed for various digital values and equivalent analog voltages
are measured and also the waveforms are measured at the output ports using CRO.

THEORY:

Since DAC 0800 is an 8 bit DAC and the output voltage variation is between –5v and
+5v. The output voltage varies in steps of 10/256 = 0.04 (approximately). The digital data input
and the corresponding output voltages are presented in the table. The basic idea behind the
generation of waveforms is the continuous generation of analog output of DAC. With 00 (Hex)
as input to DAC2 the analog output is –5v. Similarly with FF H as input, the output is +5v.
Outputting digital data 00 and FF at regular intervals, to DAC2, results in a square wave of
REG NO:212214106291

amplitude 5v.Output digital data from 00 to FF in constant steps of 01 to DAC2. Repeat this
sequence again and again. As a result a saw-tooth wave will be generated at DAC2 output.
Output digital data from 00 to FF in constant steps of 01 to DAC2.Output digital data from FF to
00 in constant steps of 01 to DAC2. Repeat this sequence again and again. As a result a
triangular wave will be generated at DAC2 output.

ALGORITHM:
Measurement of analog voltage:

Step I : Send the digital value of DAC.

Step II : Read the corresponding analog value of its output.

Waveform generation:

Square Waveform:

Step I : Send low value (00) to the DAC.

Step II : Introduce suitable delay.

Step III : Send high value to DAC.

Step IV : Introduce delay.

Step V : Repeat the above procedure.

Saw-tooth waveform:

Step I : Load low value (00) to accumulator.

Step II : Send this value to DAC.

Step III : Increment the accumulator.

Step IV : Repeat step (ii) and (iii) until accumulator value reaches FF.

Step V : Repeat the above procedure from step 1.


REG NO:212214106291

FLOWCHART:

SQUARE WAVE FORM:


REG NO:212214106291

SAWTOOTH WAVEFORM

YES
NO

PROGRAM TABLE: Square Wave

MEMORY OPCODE PROGRAM COMMENTS

LOCATION

1000 C6 C0 36 MOV AL,36H Load 36 in accumulator


1003 E6 CC OUT 0CCH,AL Send through output port
1005 C6 00 0A MOV AL,10AH Load 10 in accumulator
REG NO:212214106291

1008 E6 C8 OUT 0C8H,AL Send through output port


100A C6 C0 00 MOV AL,00H Load count value in AL register
100D E6 C8 OUT 0C8H,AL Send through output port
100F F4 HLT Stop

PROGRAM TABLE: Saw tooth Wave

MEMORY OPCODE PROGRAM COMMENTS

LOCATION

1000 C6 C0 00 START: MOV AL,00H Load 00 in accumulator


1003 E6 C8 LOOP : OUT 0C8H,AL Send through output port
1005 FE C0 INC AL Increment contents of
accumulator
1007 73 FA JNC LOOP Send through output port
1009 E9 F4 FF JMP START Go to starting location

OUTPUT:

WAVEFORM GENERATION:

WAVEFORMS AMPLITUDE TIMEPERIOD

Square Waveform

Saw-tooth waveform
REG NO:212214106291

MODEL GRAPH:

Square Waveform Saw-tooth waveform


REG NO:212214106291

RESULT:

Thus the DAC was interfaced with 8086 and different waveforms have been generated.

STEPPER MOTOR INTERFACING

EX NO:

DATE:

AIM:

To write an assembly language program in 8086 to rotate the motor at different speeds.

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 1

2. Power Supply +5 V, dc,+12 V dc 1

3. Stepper Motor Interface board - 1

4. Stepper Motor - 1

PROBLEM STATEMENT:

Write a code for achieving a specific angle of rotation in a given time and particular
number of rotations in a specific time.

THEORY:

A motor in which the rotor is able to assume only discrete stationary angular position is a
stepper motor. The rotary motion occurs in a stepwise manner from one equilibrium position to
REG NO:212214106291

the next. Two-phase scheme: Any two adjacent stator windings are energized. There are two
magnetic fields active in quadrature and none of the rotor pole faces can be in direct alignment
with the stator poles. A partial but symmetric alignment of the rotor poles is of course possible.

ALGORITHM:

For running stepper motor clockwise and anticlockwise directions

Step I : Get the first data from the lookup table.

Step II : Initialize the counter and move data into accumulator.

Step III : Drive the stepper motor circuitry and introduce delay
Step IV : Decrement the counter is not zero repeat from step(iii)
Step V : Repeat the above procedure both for backward and forward directions.

SWITCHING SEQUENCE OF STEPPER MOTOR:

MEMORY A1 A2 B1 B2 HEX
LOCA CO
TION DE

4500 1 0 0 0 09 H

4501 0 1 0 1 05 H

4502 0 1 1 0 06 H

4503 1 0 1 0 0A H
REG NO:212214106291

FLOWCHART:

YES

NO
REG NO:212214106291

PROGRAM TABLE

MEMORY OPCODE PROGRAM COMMENTS


LOCATION

1000 C7 C7 00 12 START : MOV DI, 1200H Initialize memory


location to store
the array of
number

1004 C7 C1 04 00 MOV CX, 0004H Initialize array size

1008 8A 05 LOOP 1 : MOV AL,[DI] Copy the first data in


AL

100A E6 C0 OUT 0C0,AL Send it through port


address

100C C7 C2 10 10 MOV DX, 1010H

1010 4A L1 : DEC DX Introduce delay

1011 75 FD JNZ L1

1013 47 INC DI Go to next memory


location

1014 E2 F2 LOOP LOOP1 Loop until all the


data’s have been
sent

1016 E9 E7 FF JMP START Go to start location


for continuous
rotation

1019 F4 HLT stop


1200 09,05,06,0A Array of datas
REG NO:212214106291

RESULT:

Thus the assembly language program for rotating stepper motor in both clockwise and
anticlockwise directions is written and verified
REG NO:212214106291

INTERFACING PROGRAMMABLE TIMER-8253

AND INTERFACING USART 8251


EX NO:

DATE:

INTERFACING PROGRAMMABLE TIMER 8253

AIM :

To study different modes of operation of programmable timer 8253

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 Vi Microsystems 1

2. Power Supply +5V dc 1

3. 8253 interfacing kit - 1

4. CRO - 1

THEORY:

The main features of the timer are,

i. Three independent 16-bit counters


ii. Input clock from DC to 2 MHz
iii. Programmable counter modes
iv. Count binary or BCD
The control signals with which the 8253 interfaces with the CPU are CS, RD, WR, A1,
A2.The basic operations performed by 8253 are determined by these control
signals. It has six different modes of operation, viz, mode 0 to mode 5.
REG NO:212214106291

MODE 3 – SQUARE WAVE GENERATOR


It is similar to mode 2, except that the output will remain high until one half for even
number count, If the count is odd, the output will be high for (count+1)/2 counts and low
for (count-1)/2 counts

ALGORITHM:

Mode 2-

Step I : Initialize channel 0 in mode 2

Step II : Initialize the LSB of the count.

Step III : Initialize the MSB of the count.

Step IV : Trigger the count

Step V : Read the corresponding output in CRO.

Mode 3-

Step I :Initialize channel 0 in mode 3

Step II : Initialize the LSB of the count.

Step III : Initialize the MSB of the count.

Step IV : Trigger the count

Step V : Read the corresponding output in CRO.

PORT ADDRESS :

1. CONTROL REGISTER –
2. COUNTER OF CHANNEL 0 -
3. COUNTER OF CHANNEL 1 -
4. COUNTER OF CHANNEL 2 -
5. O/P PORT OF CHANNEL 0 -
6. O/P PORT OF CHANNEL 1 -
7. O/P PORT OF CHANNEL 2 -
REG NO:212214106291

CONTROL WORD FORMAT:

D7 D6 D5 D4 D3 D2 D1 D0

SC1 SC0 RL1 RL0 M2 M1 M0 BCD

0 0 1 1 0 1 0 0
Mode 2 = 34 H

0 0 1 1 0 1 1 0
Mode 3 = 36 H

SC1 SC0 CHANNEL SELECT RL1 RL0 READ/LOAD

0 0 CHANNEL 0 0 0 LATCH

0 1 CHANNEL 1 0 1 LSB

1 0 CHANNEL 2 1 0 MSB

1 1 ----- 1 1 LSB FIRST, MSB NEXT

BCD --0 –BINARY COUNTER 1 --BCD COUNTER

M2 M1 M0 MODE

0 0 0 MODE 0

0 0 1 MODE 1

0 1 0 MODE 2

0 1 1 MODE 3
REG NO:212214106291

1 0 0 MODE 4

1 0 1 MODE 5

PORT PIN ARRANGEMENT DEBOUNCE CIRCUIT CONNECTION


1 CLK 0
* * *

2 CLK 1

3 CLK 2

4 OUT 0

5 OUT 1

6 OUT 2

7 GATE 0

8 GATE 1

9 GATE 2

10 GND
REG NO:212214106291

MODE 3 – SQUARE WAVE GENERATOR:

MEMORY OPCODE PROGRAM COMMENTS


LOCATION
1000 C6 C0 36 MOV AL, 36H Store the control word in
accumulator
1003 E6 CE OUT CE,AL Send through output port
1005 C6 C0 0A MOV AL, 0AH Copy lower order count value
in accumulator
1008 E6 C8 OUT 0C8H,AL Send through output port
100A C6 C0 00 MOV AL, 00H Copy higher order count value
in accumulator
100D E6 C8 OUT 0C8H,AL Send through output port
100F F4 HLT Stop
REG NO:212214106291

MODEL GRAPH:

SQUARE WAVE GENERATOR

FLOW CHART

INITIALIZE ACCUMULATOR
WITH MODE SET WORD

INITIALIZE LSB OF COUNT

TRIGGER THE COUNT

RESULT:
Thus an ALP for square wave generator are written and executed.
REG NO:212214106291

INTERFACING USART 8251


AIM:
To study interfacing technique of 8251 (USART) with microprocessor 8086 and write an
8086 ALP to transmit and receive data between two serial ports with RS232 cable.

APPARATUS REQUIRED:
8086 kit (2 Nos), RS232 cable.

THEORY:
The 8251 is used as a peripheral device for serial communication and is programmed by
the CPU to operate using virtually any serial data transmission technique. The USART accepts
data characters from the CPU in parallel format and then converts them into a continuous serial
data stream for transmission. Simultaneously, it can receive serial data streams and convert them
into parallel data characters for the CPU. The CPU can read the status of the USART at any time.
These include data transmission errors and control signals. The control signals define the
complete functional definition of the 8251. Control words should be written into the control
register of 8251.These control words are split into two formats: 1) Mode instruction word & 2)
Command instruction word. Status word format is used to examine the error during functional
operation.

1...transmit enable
1...data terminal ready
1... receive enable
1... send break character
1.... reset error flags (pe,oe,fe)
1..... request to send (rts)
1...... internal reset
1....... enter hunt mode (enable search for sync characters)
REG NO:212214106291

1 ransmitter ready
1. receiver ready
1.. transmitter empty
1... parity error (pe)
1.... overrun error (oe)
1..... framing error (fe), async only
1...... sync detect, sync only
1....... data set ready (dsr)
REG NO:212214106291

ALGORITHM:

Step I : Initialize 8253 and 8251 to check the transmission and reception of a character
Step II : Initialize8253 to give an output of 150Khz at channel 0 which will give a 9600
baud rate of 8251.
Step III:The command word and mode word is written to the 8251 to set up for subsequent
operations

Step IV : The status word is read from the 8251 on completion of a serial I/O operation, or when
the host CPU is checking the status of the device before starting the next I/O operation

FLOW CHART:
REG NO:212214106291

PROGRAM: TRANSMITTER END

MEMORYLOCATION OPCODE PROGRAM COMMENTS


1000 C6 C0 36 MOV AL,36 Initialize 8253 in mode 3
square wave generator
1003 E6 CE OUT CE,AL Send through port address
1005 C6 C0 10 MOV AL,10 Initialize AL with lower value
of count (clock frequency
150KHz)
1008 E6 C8 OUT C8,AL Send through port address
100A C6 C0 00 MOV AL,00 Initialize AL with higher value
of count
100D E6 C8 OUT C8,AL Send through port address
100F C6 C0 4E MOV AL,4E Set mode for 8251(8bit data,
No parity, baud rate
factor 16x & 1 stop bit)
1012 E6 C2 OUT C2,AL Send through port address
1014 C6 C0 37 MOV AL,37 Set command
instruction(enables
transmit enable & receive
enable bits)
1017 E6 C2 OUT C2,AL Send through port address
1017 C6 C0 41 MOV AL,41 Set the data as 41
101C E6 C0 OUT C0,AL Send through port address
101E CD 02 INT 2 Restart the system
REG NO:212214106291

RECEIVER END

MEMORY OPCODE PROGRAM COMMENTS


LOCATION
1200 E4 C0 IN AL,C0 If it is ready, get the data
1202 C7 C3 00 15 MOV BX,1500 Initialize BX register with
memory location to
store the data
1206 88 07 MOV [BX],AL Store the data in the memory
location
1208 CD 02 INT 2 Restart the system

RESULT:

Thus ALP for serial data communication using USART 8251 is written and the equivalent ASCII
41 for character ‘A’ is been transmitted & received.
REG NO:212214106291

INTERFACING PPI 8255


EX NO:

DATE:

AIM:

To write ALP by interfacing 8255 with 8086 in mode 0.

APPARATUS REQUIRED:
8086 kit, 8255 interface kit.

ALGORITHM:

Mode 0

Step I : Initialize accumulator to hold control word


Step II : store control word in control word register
Step III : Read data port A.

Step IV : Store data from port A in memory


Step V : Place contents in port B
REG NO:212214106291

FLOWCHART
Mode 0

MODE 0

MEMOR OPCODE PROGRAM COMMENTS


LOCATION
1000 C6 C0 90 MOV AL,90H Set the control word
1003 E6 C6 OUT C6,AL Send it to control port
1005 E4 C0 IN AL,C0 Get the contents of port A in AL
1007 E6 C2 OUT C2,AL Send the contents of port B to port
address
1009 F4 HLT Stop

BSR mode
Bit set/reset, applicable to PC only. One bit is S/R at a time. Control word:
D7 D6 D5 D4 D3 D2 D1 D0

0 (0=BSR) X X X B2 B1 B0 S/R (1=S,0=R)


REG NO:212214106291

Bit select: (Taking Don't care's as 0)


B2 B1 B0 PC bit Control word (Set) Control word (reset)

0 0 0 0 0000 0001 = 01h 0000 0000 = 00h

0 0 1 1 0000 0011 = 03h 0000 0010 = 02h

0 1 0 2 0000 0101 = 05h 0000 0100 = 04h

0 1 1 3 0000 0111 = 07h 0000 0110 = 06h

1 0 0 4 0000 1001 = 09h 0000 1000 = 08h

1 0 1 5 0000 1011 = 0Bh 0000 1010 = 0Ah

1 1 0 6 0000 1101 = 0Dh 0000 1100 = 0Ch

1 1 1 7 0000 1111 = 0Fh 0000 1110 = 0Eh

I/O mode
D7 D6 D5 D4 D3 D2 D1 D0

1 (1=I/O) GA mode select PA PCU GB mode select PB PCL

 D6, D5: GA mode select:


o 00 = mode0

o 01 = mode1

o 1X = mode2

 D4(PA), D3(PCU): 1=input 0=output


 D2: GB mode select: 0=mode0, 1=mode1
 D1(PB), D0(PCL): 1=input 0=output

Mode 0

Input Output
REG NO:212214106291

RESULT:

The programs for interfacing 8255 with 8086 are executed & the output is obtained for modes 0.
REG NO:212214106291

STUDY OF TRAFFIC LIGHT CONTROLLER

EX NO:

DATE:

AIM:

To write an assembly language program in 8086 to Interface Traffic light controller.

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 1

2. Power Supply +5 V, dc,+12 V dc 1

3. Traffic light Interface board - 1

ALGORITHM:

Step I : Get the first data from the lookup table.

Step II : Initialize the counter and move data into accumulator.

Step III : Assign port Address


Step IV : Decrement the counter is not zero repeat from step(ii)
Step V : Provide the respective input.
REG NO:212214106291

PROGRAM

CONTROL EQU 026H


PORTA EQU 020H
PORTB EQU 022H
PORTC EQU 024H

MEMORY OPCODE LABEL MNEMONICS


LOCATION
1000 C6 C0 80 START MOV AL,80H
1003 E6 26 OUT CNTRL,AL
1005 C7 C3 73 10 REPEAT MOV BX,LOOKUP
1009 C7 C6 7F 10 MOV SI,LABEL
100D E8 33 00 CALL OUT
1010 8A 04 MOV AL,[SI]
1012 E6 20 OUT PORTA,AL
1014 E8 4D 00 CALL DELAY1
1017 46 INC SI
1018 43 INC BX
1019 E8 27 00 CALL OUT
101C 8A 04 MOV AL,[SI]
101E E6 22 OUT PORTB,AL
1020 E8 41 00 CALL DELAY1
1023 46 INC SI
1024 43 INC BX
1025 E8 1B 00 CALL OUT
1028 8A 04 MOV AL,[SI]
102A E6 24 OUT PORTC,AL
102C E8 35 00 CALL DELAY1
102F 46 INC SI
1030 43 INC BX
1031 E8 0F 00 CALL OUT
1034 8A 04 MOV AL,[SI]
1036 E6 24 OUT PORTC,AL
1038 46 INC SI
1039 8A 04 MOV AL,[SI]
103B E6 20 OUT PORTA,AL
103D E8 24 00 CALL DELAY1
1040 E9 C2 FF JMP REPEAT
1043 8A 07 OUT MOV AL,[BX]
1045 E6 24 OUT PORTC,AL
1047 43 INC BX
REG NO:212214106291

1048 8A 07 MOV AL,[BX]


104A E6 22 OT PORTB,AL
104C 43 INC BX
104D 8A 07 MOV AL,[SI]
104F E6 20 OUT PORTA,AL
1051 E8 01 00 CALL DELAY
1054 C3 RET
1055 C7 C7 40 00 DELAY MOV DI,00040H
1059 C7 C2 FF FF A MOV DX,0FFFFH
105D 4A A1 DEC DX
105E 75 4D JNZ A1
1060 4F DEC D1
1061 75 FD JNZ A
1063 C3 RET
1064 C7 C7 15 00 DELAY1 M0V DI,00015H
1068 C7 C2 FF FF B MOV DX,0FFFFH
106C 4A B1 DEC DX
106D 75 FD JNZ B1
106F 4F DEC D1
1070 75 F6 JNZ B
1072 C3 RET
1073 12 27 44 10 LOOK UP DB 12H,27H,44H,10H
1077 2B 92 10 9D DB 2BH,92H,10H,9BH
107B 84 48 2E 84 DB 84H,48H,2EH,84H
107F 48 4B 20 49 DB 48H,4BH,20H,49H
1083 04 LABEL 04H
107C END

RESULT:
Thus the program for Interfacing Traffic Light controller is written and successfully executed.
REG NO:212214106291

DIGITAL CLOCK INTERFACING


EX NO:

DATE:

AIM:

To write an assembly language programming for 8086 to interface digital clock

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 1

2. Power Supply +5 V, dc,+12 V dc 1

3. Digital clock interface board - 1

ALGORITHM:

Step I : Get the first data from the lookup table.

Step II : Initialize the counter and move data into accumulator.

Step III : Assign port Address


Step IV : Decrement the counter is not zero repeat from step(ii)
Step V : Provide the respective input.

PROCEDURE:

Enter the current time in the following memory locatiom

1310 seconds LSB

1311 seconds MSB

1312 minutes LSB

1313 minutes MSB

1314 hours LSB


REG NO:212214106291

1315 hours MSB

PROGRAM:

MEMORY OPCODE LABEL MNEMONICS


LOCATION
1000 C6 C0 05 MOV AL,05H
1003 E6 DE OUT 0DEH,AL
1005 C6 C0 04 MOV AL,04H
1008 E6 DE OUT 0DEH,AL
100A C7 C6 1013 MOV SI,1310H
100E 8A 04 MOV AL,[SI]
1010 E6 C0 OUT 0C0H,AL
1012 46 INC SI
1013 8A 04 MOV AL,[SI]
1015 E6 D0 OUT 0D0H,AL
1017 46 INC SI
1018 8A 04 MOV AL,[SI]
101A E6 C2 OUT 0C2H,AL
101C 46 INC SI
101D 8A 04 MOV AL,[SI]
101F E6 D2 OUT 0D2H,AL
1021 46 INC SI
1022 8A 04 MOV AL,[SI]
1024 E6 C4 OUT 0C4H,AL
1026 46 INC SI
1027 8A 04 MOV AL,[SI]
1029 E6 D4 OUT 0D4H,AL
102B C7 C6 2013 L1 MOV SI,1320H
102F E4 D4 IN AL,0D4H
1031 80 E0 0F AND AL,0FH
1034 88 04 MOV [SI],AL
1036 E4 C4 IN AL,0C4H
1038 80 E0 0F AND AL,0FH
103B 46 INC SI
103C 88 04 MOV [SI],AL
103E E4 D2 IN AL,0D2H
1040 80 E0 0F AND AL,0FH
1043 46 INC SI
1044 88 04 MOV [SI],AL
1046 E4 C2 IN AL,0C2H
1048 80 E0 0F AND AL,0FH
104B 46 INC SI
104C 88 04 MOV [SI],AL
104E E4 D0 IN AL,0D0H
REG NO:212214106291

1050 80 E0 0F AND AL,0FH


1053 46 INC SI
1054 88 04 MOV [SI],AL
1056 E4 C0 IN AL,0C0H
1058 80 E0 0F AND AL,0FH
105B 46 INC SI
105C 88 04 MOV [SI],AL
105E C7 C6 2013 MOV SI,1320H
1062 8A 04 MOV AL,[SI]
1064 E6 E0 OUT 0E0H,AL
1066 46 INC SI
1067 8A 04 MOV AL,[SI]
1069 E6 F0 OUT 0F0H,AL
106B 46 INC SI
106C 8A 04 MOV AL,[SI]
106E E6 E2 OUT E2H,AL
1070 46 INC SI
1071 8A 04 MOV AL,[SI]
1073 E6 F2 OUT 0F2H,AL
1075 46 INC SI
1076 8A 04 MOV AL,[SI]
1078 E6 E4 OUT 0E4H,AL
107A 46 INC SI
107B 8A 04 MOV AL,[SI]
107D E6 F4 OUT 0F4H,AL
107F E9 A9 FF JMP L1
1083 FFFF4 HHHLT

RESULT:

Thus the program for interfacing digital clock is written and successfully executed
REG NO:212214106291

ARITHMETIC OPERATIONS USING 8051 MICROCONTROLLER


EX NO:

DATE:

AIM:

To write a assembly language program to perform arithmetic operations using 8051


microcontroller.

APPARATUS REQUIRED: 8051 microcontroller kit

A)ADDITION

ALGORITHM

Step I :Clear Program Status Word.


Step II :Select Register bank by giving proper values to RS1 & RS0 of PSW.
Step III :Load accumulator A with any desired 8-bit data.
Step IV :Load the register R 0 with the second 8- bit data.
Step V :Add these two 8-bit numbers.
Step VI :Store the result.
Step VII :Stop the program.

PROGRAM :

A) By using8051 KIT

ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS


CO
DE

4100 CLR C C3 Clear CY Flag

4101 MOV A, data1 74,data1 Get the data1 in


Accumulator

4103 ADD A, # data 2 24,data2 Add the data1 with


data2
REG NO:212214106291

4105 MOV DPTR, # 90,45,00 Initialize the memory


4500H location

4108 MOVX @ DPTR, A F0 Store the result in


memory location

4109 HERE SJMP HERE 80,FE Stop the program

B)BY USING KEIL SOFTWARE

MOV A,P0
MOV R0,P1
MOV B,R0
ADD A,B
MOV P2,A
END
FLOW CHART:

Clear PSW

Select Register
Bank

Load A and R0 with


8- bit data

Add A & R 0

Store the sum


REG NO:212214106291

OUTPUT

BY USING 8051 KIT

INPUT OUTPUT

MEMORY LOCATION DATA MEMORY LOCATION DATA

4500 4502

4501 4503

BY USING KEIL SOFTWARE

B)SUBTRACTION

ALGORITHM:

Step I :Clear the carry flag.


Step II :Initialize the register for borrow.
Step III :Get the first operand into the accumulator.
Step IV :Subtract the second operand from the accumulator.
Step V :If a borrow results increment the carry register.
Step VI :Store the result in memory.
REG NO:212214106291

PROGRAM

A)By using 8051 kit

ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS


CO
DE

4100 CLR C C3 Clear CY flag

4101 MOV A, # data1 74, data1 Store data1 in


accumulator

4103 SUBB A, # data2 94,data2 Subtract data2 from


data1

4105 MOV DPTR, # 4500 90,45,00 Initialize memory


location

4108 MOVX @ DPTR, A F0 Store the difference


in memory
location

4109 HERE SJMP HERE 80,FE Stop

B)BY USING KEIL SOFTWARE

MOV A,P0
MOV R0,P1
MOV B,R0
ADD A,B
MOV P2,A
END
REG NO:212214106291

FLOWCHART:

CLEAR CARRY
FLAG

GET I’ST
OPERAN
D IN
ACCR

SUBTRACT THE 2’ND


OPERAND
FROM
ACCR

INCREMENT THE
BORRO
W
REGISTE
R

STORE RESULT IN
MEMOR
Y

OUTPUT

BY USING KEIL SOFTWARE


REG NO:212214106291

BY USING 8051 KIT

INPUT OUTPUT

MEMORY LOCATION DATA MEMORY LOCATION DATA

C)MULTIPLICATION

ALGORITHM:

Step I :Get the multiplier in the accumulator.


Step II :Get the multiplicand in the B register.
Step III :Multiply A with B.
Step IV :Store the product in memory.

PROGRAM

A)By using 8051 kit:

ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS


CO
DE

4100 MOV A ,#data1 74, data1 Store data1 in


accumulator

4102 MOV B, #data2 75,data2 Store data2 in B reg


REG NO:212214106291

4104 MUL AB F5,F0 Multiply both

4106 MOV DPTR, # 90,45,00 Initialize memory


4500H location

4109 MOVX @ DPTR, A F0 Store lower order


result

401A INC DPTR A3 Go to next memory


location

410B MOV A,B E5,F0

Store higher order


result
410D MOV @ DPTR, A F0

410E HERE SJMP HERE 80,FE Stop

PROGRAM:

B)BY USING KEIL SOFTWARE

MOV A,P0
MOV R0,P1
MOV B,R0
MUL AB
MOV P2,A
END
REG NO:212214106291

FLOWCHART:

GET MULTIPLIER
IN ACCR

GET MULTIPLICAND
IN B REG

MULTIPLY A WITH B

STORE RESULT IN
MEMOR
Y

OUTPUT

BY USING KEIL SOFTWARE


REG NO:212214106291

BY USING 8051 KIT

INPUT OUTPUT

MEMORY LOCATION DATA MEMORY LOCATION DATA

D)DIVISION:

ALGORITHM:

Step I :Get the Dividend in the accumulator.

Step II :Get the Divisor in the B register.

Step III :Divide A by B.

Step IV:Store the Quotient and Remainder in memory.

PROGRAM

A) BY Using 8051 Kit

ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS


C
O
DE

4100 MOV A, # data1 74,data1 Store data1 in


accumulator

4102 MOV B, # data2 75,data2 Store data2 in B reg


REG NO:212214106291

4104 DIV AB 84 Divide

4015 MOV DPTR, # 4500H 90,45,00 Initialize memory


location

4018 MOVX @ DPTR, A F0 Store remainder

4109 INC DPTR A3 Go to next memory


location

410A MOV A,B E5,F0

Store quotient

410C MOV @ DPTR, A F0

410D STOP SJMP STOP 80,FE Stop

PROGRAM:

B)BY USING KEIL SOFTWARE

MOV A,P0
MOV R0,P1
MOV B,R0
DIV AB
MOV P2,A
END
REG NO:212214106291

FLOWCHART:

GET DIVIDEND IN
ACCR

GET DIVISOR IN B
REG

DIVIDE A BY B

STORE QUOTIENT
&
REMAIN
DER IN
MEMOR
Y

OUTPUT

BY USING KEIL SOFTWARE


REG NO:212214106291

OUTPUT

BY USING 8051 KIT

INPUT OUTPUT

MEMORY LOCATION DATA MEMORY LOCATION DATA

RESULT:

Thus Arithmetic Operations using 8051 microcontroller was performed and output is verified
successfully.
REG NO:212214106291

SQUARE,CUBE,2’S COMPLEMENT OF A NUMBER USING 8051


MICROCONTROLLER
EX NO:

DATE:

AIM:

To write a assembly language program to square,cube,2’s complement a number using


8051 microcontroller.

APPARATUS REQUIRED: 8051 microcontroller kit

SQUARE A NUMBER:

ALGORITHM:

Step I:Get the multiplier in the accumulator.


Step II:Get the multiplicand in the B register.
Step III:Multiply A with B.
Step IV:Store the product in memory.

PROGRAM :

A) By using 8051 KIT

ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS


CO
DE

4100 MOV A ,#data1 74, data1 Store data1 in


accumulator

4102 MOV B, A 75,A Store A in B reg

4104 MUL AB F5,F0 Multiply both

4106 MOV DPTR, # 90,45,00 Initialize memory


REG NO:212214106291

4500H location

4109 MOVX @ DPTR, A F0 Store lower order


result

401A INC DPTR A3 Go to next memory


location

410B MOV AB E5,F0

Store higher order


result
410D MOV @ DPTR, A F0

410E HERE SJMP HERE 80,FE Stop

PROGRAM:

B)BY USING KEIL SOFTWARE

MOV A,P0
MOV R0,A
MOV B,R0
MUL AB
MOV P2,A
END
OUTPUT

BY USING KEIL SOFTWARE:


REG NO:212214106291

BY USING 8051 KIT:

INPUT OUTPUT

MEMORY LOCATION DATA MEMORY LOCATION DATA

CUBE A NUMBER:

ALGORITHM:

Step 1: Load DPTR with input address

Step 2: load the first data tgo accumulator and move to another register

Step 3: Load the second data to accumulator

Step 4: Multiply thrice for cube of a number

Step 5: Store the result to a memory location

PROGRAM :

A) By using 8051 KIT

ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS


CO
DE

4100 MOV DPTR,#6100 90,61,00 Initialize memory


REG NO:212214106291

location

4103 MOVX A,@DPTR F0 Store higher order


result

4104 MOV B,A 75,A Store A in B reg

4106 MOVX A,@DPTR F0 Store higher order


result

4107 MUL AB F5,F0 Multiply both

4109 MOV B,A 75,A Store A in B reg

410B MOVX A,@DPTR F0 Store higher order


result

410C MUL AB F5,F0 Multiply both

410E INC DPTR A3 Go to next memory


location

410F MOVX @DPTR,A F0 Store higher order


result

4110 L1 SJMP L1 80,FE stop

PROGRAM:

B)BY USING KEIL SOFTWARE

MOV A,P0
MOV R0,A
MOV B,R0
REG NO:212214106291

MUL AB
MOV B,R0
MUL AB
MOV P2,A
END
OUTPUT

BY USING KEIL SOFTWARE:

2’S COMPLEMENT OF A NUMBER:

ALGORITHM:

Step 1: Load DPTR with input address

Step 2: load the data with accumulator

Step 3: complement the accumulator

Step 4:Add 01H to the complemented content

Step 5:Store the result to a memory location

PROGRAM :

A) By using 8051 KIT

ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS


CO
DE

4100 MOV A,#FF 90,61,00 Store the data in the


accumulator

4103 CPL A F0 Complement the


REG NO:212214106291

accumulator

4104 MOV DPTR,#6100 75,A Initialize memory


location

4106 MOVX @DPTR,A F0 Store higher order


result

4107 INC A F5,F0 Go to the memory


location

4109 INC DPTR 75,A Go to the memory


location

410B MOVX @DPTR,A F0 Store higher order


result

410C RET F4 Stop

PROGRAM:

B)BY USING KEIL SOFTWARE

MOV A,P0
CPL A
ADD A,01
MOV P1,A
END
OUTPUT :(BY USING KEIL SOFTWARE)

RESULT:

Thus square,cube,2’s complement a number are performed using assembly language program in
8051 microcontroller and output is verified successfully.
REG NO:212214106291

LOGICAL OPERATIONS USING 8051 MICROCONTROLLER


EX NO:

DATE:

AIM: To write a assembly language program to perform arithmetic operations using 8051
microcontroller.

APPARATUS REQUIRED:8051 microcontroller kit

A)OR:

ALGORITHM

Step I :Clear Program Status Word.


Step II :Select Register bank by giving proper values to RS1 & RS0 of PSW.
Step III :Load accumulator A with any desired 8-bit data.
Step IV :Load the register R 0 with the second 8- bit data.
Step V :OR these two 8-bit numbers.
Step VI :Store the result.
Step VII :Stop the program.

PROGRAM :

A) By using8051 KIT

ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS


CO
DE

4100 CLR C C3 Clear CY Flag

4101 MOV A, data1 74,data1 Get the data1 in


Accumulator

4103 ORL A, # data 2 24,data2 OR the data1 with


data2

4105 MOV DPTR, # 90,45,00 Initialize the memory


4500H location
REG NO:212214106291

4108 MOVX @ DPTR, A F0 Store the result in


memory location

4109 HERE SJMP HERE 80,FE Stop the program

B)BY USING KEIL SOFTWARE

MOV A,P0
MOV R0,P1
MOV B,R0
ORL A,B
MOV P2,A
END
FLOW CHART:

Clear PSW

Select Register
Bank

Load A and R0 with


8- bit data

OR A & R 0

Store the sum


REG NO:212214106291

OUTPUT

BY USING 8051 KIT

INPUT OUTPUT

MEMORY LOCATION DATA MEMORY LOCATION DATA

4500 4502

4501 4503

BY USING KEIL SOFTWARE

B)AND:

ALGORITHM

Step I :Clear Program Status Word.


Step II :Select Register bank by giving proper values to RS1 & RS0 of PSW.
Step III :Load accumulator A with any desired 8-bit data.
Step IV :Load the register R 0 with the second 8- bit data.
Step V :AND these two 8-bit numbers.
Step VI :Store the result.
Step VII :Stop the program.
REG NO:212214106291

PROGRAM :

A) By using8051 KIT

ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS


CO
DE

4100 CLR C C3 Clear CY Flag

4101 MOV A, data1 74,data1 Get the data1 in


Accumulator

4103 ANL A, # data 2 24,data2 AND the data1 with


data2

4105 MOV DPTR, # 90,45,00 Initialize the memory


4500H location

4108 MOVX @ DPTR, A F0 Store the result in


memory location

4109 HERE SJMP HERE 80,FE Stop the program

B)BY USING KEIL SOFTWARE

MOV A,P0
MOV R0,P1
MOV B,R0
ANL A,B
MOV P2,A
END
REG NO:212214106291

FLOW CHART:

Clear PSW

Select Register
Bank

Load A and R0 with


8- bit data

AND A & R 0

Store the sum

OUTPUT

BY USING 8051 KIT

INPUT OUTPUT

MEMORY LOCATION DATA MEMORY LOCATION DATA

4500 4502

4501 4503
REG NO:212214106291

BY USING KEIL SOFTWARE

C)EX-OR:

ALGORITHM

Step I :Clear Program Status Word.


Step II :Select Register bank by giving proper values to RS1 & RS0 of PSW.
Step III :Load accumulator A with any desired 8-bit data.
Step IV :Load the register R 0 with the second 8- bit data.
Step V :EXOR these two 8-bit numbers.
Step VI :Store the result.
Step VII :Stop the program.

PROGRAM :

A) By using8051 KIT

ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS


CO
DE

4100 CLR C C3 Clear CY Flag

4101 MOV A, data1 74,data1 Get the data1 in


Accumulator

4103 XRL A, # data 2 24,data2 EXOR the data1 with


data2
REG NO:212214106291

4105 MOV DPTR, # 90,45,00 Initialize the memory


4500H location

4108 MOVX @ DPTR, A F0 Store the result in


memory location

4109 HERE SJMP HERE 80,FE Stop the program

B)BY USING KEIL SOFTWARE

MOV A,P0
MOV R0,P1
MOV B,R0
XRL A,B
MOV P2,A
END
FLOW CHART:

Clear PSW

Select Register
Bank

Load A and R0 with


8- bit data

EXOR A & R 0

Store the sum


REG NO:212214106291

OUTPUT

BY USING 8051 KIT

INPUT OUTPUT

MEMORY LOCATION DATA MEMORY LOCATION DATA

4500 4502

4501 4503

BY USING KEIL SOFTWARE

RESULT:

Thus Logical Operations using 8051 microcontroller was performed and output is verified
successfully.
REG NO:212214106291

UNPACKED BCD TO ASCII


EX NO:

DATE:

AIM: To write a program to convert unpacked BCD to ASCII

ALGORITHM:

Step 1: Initilaize DPTR with input address

Step 2: Load the data to the accumulator

Step 3: Mask MSB nibbles , perform OR operation with 30h and store the result

Step 4: Mask LSB nibbles,rotate,perform, OR operation with 30H

Step 5: Store the result

PROGRAM:

MOV DPTR,#6100

MOVX A,DPTR

MOV R1,A

MOV A,#00

MOV R0,#0A

LOOP:ADD A,R1

DJNZ R0,LOOP

MOV R1,A

INC DPTR

MOVX A,@DPTR

ADD A,.R1

CJNE A,#0A,LOOP1

LOOP1:JC LOOP2

ADD A,07H

LOOP2:ADD A,#30
REG NO:212214106291

INC DPTR

MOVX @DPTR,A

STOP: SJMP STOP

OUTPUT

BY USING 8051 KIT:

INPUT OUTPUT

MEMORY LOCATION DATA MEMORY LOCATION DATA

RESULT:

Thus the conversion of unpacked BCD to ASCII is programmed and executed.

You might also like