Professional Documents
Culture Documents
Ex. No.1a
AIM:
To write an Assembly Language Program (ALP) for performing the addition operations of 8-bit
numbers with and without carry.
APPARATUS REQUIRED:
Microprocessor kit, Power supply.
PROBLEM STATEMENT:
Write an ALP in 8085 P to add two 8-bit binary numbers stored in the memory location 5500H
and 5501H and store the result in the memory location 5502H.Also provide an instruction in the above
program to consider the carry also and store the carry in the memory location 5503H.
ALGORITHM:
PROGRAM:
ADDRESS LABEL MNEMONICS HEX CODE
4100 MV1 C,00
4106
LDA 5501
4109
ADD B
410A
JNC L1
410D
INR C
410E
L1 STA 5502
4111
MOV A,C
4112
STA 5503
4115
HLT
RESULT:
AIM:
To write an Assembly Language Program (ALP) for performing the subtraction operations of 8-
bit numbers with and without carry.
APPARATUS REQUIRED:
Microprocessor kit, Power supply.
PROBLEM STATEMENT:
Write an ALP in 8085 P to subtract two 8-bit binary numbers stored in the memory location
5500H and 5501H and store the result in the memory location 5502H.Also provide an instruction in the
above program to consider the carry also and store the carry in the memory location 5503H.
ALGORITHM:
PROGRAM:
4105
MOV B,A
4106
LDA 5501
4109
SUB B
410A
JNC L1
410D
INR C
410E
L1 STA 5502
4111
MOV A,C
4112
STA 5503
4115
HLT
RESULT:
AIM:
To write an Assembly Language Program (ALP) for performing the addition operations of 16-bit
numbers with and without carry.
APPARATUS REQUIRED:
Microprocessor kit, Power supply.
PROBLEM STATEMENT:
Write an ALP in 8085 P to add two 16-bit binary numbers stored in the memory location
5500H and 5503H (in the order of lower byte in the first location, higher byte in the second location) and
store the result in the memory location 5504H and 5505H.Also provide an instruction in the above
program to consider the carry also and store the carry in the memory location 5506H.
ALGORITHM:
1. Clear the contents of B register
2. Load HL pair with the first 16 bit number,
3. Move this number to the DE pair using Exchange instruction
4. Load the HL Pair with second 16 bit number
5. Add the content of DE pair with contents of HL pair and store the result in HL pair
6. If a carry occurs increment the value of B register
7. Store the sum in memory
PROGRAM:
RESULT:
Ex.No.1d
AIM:
To write an Assembly Language Program (ALP) for performing the subtraction operations of 16-
bit numbers with and without carry.
APPARATUS REQUIRED:
Microprocessor kit, Power supply.
PROBLEM STATEMENT:
Write an ALP in 8085 P to subtract two 16-bit binary numbers stored in the memory location
5500H and 5503H (in the order of lower byte in the first location, higher byte in the second location) and
store the result in the memory location 5504H and 5505H.Also provide an instruction in the above
program to consider the carry also and store the carry in the memory location 5506H.
ALGORITHM:
1. Initialize the MSBs of difference to 0
2. Get the first low byte of data-1in the accumulator.
3. Subtract the low byte of data-2 from that of data-1.
4. Store the low byte of the result.
5. Get the high byte of data-1 in the accumulator
6. Subtract the high byte of data-2 and also the carry from the high byte of data-1.
7. Store the high byte of the result.
8. If there is any carry, increment the contents MSBs by 1.
9. Store MSBs of result.
PROGRAM:
RESULT:
VIVA QUESTIONS:
1.What is an Opcode?
The part of the instruction that specifies the operation to be performed is called the operation
code or opcode.
2.What is an Operand?
The data on which the operation is to be performed is called as an Operand.
3.List out the five categories of the 8085 instructions. Give examples of the
instructions for each group.
• Data transfer group – MOV, MVI, LXI.
• Arithmetic group – ADD, SUB, INR.
• Logical group –ANA, XRA, CMP.
• Branch group – JMP, JNZ, CALL.
• Stack I/O and Machine control group – PUSH, POP, IN, HLT.
8.Subtraction concept:
Any 8-bit number, or the contents of a register, or the contents of a memory location can be
subtracted from the contents of the accumulator and the results stored in the accumulator. The
subtraction is performed in 2's compliment, and the results if negative, are expressed in 2's complement.
No two other registers can be subtracted directly.
AIM:
To write an Assembly Language Program (ALP) for performing the multiplication operation of
8-bit numbers.
APPARATUS REQUIRED:
Microprocessor kit, Power supply.
PROBLEM STATEMENT:
Write an ALP in 8085 P to multiply two 8-bit binary numbers stored in the registers B and C
and store the result in the memory location 5502H.
ALGORITHM:
1. Get the multiplier.
2. Get the multiplicand
3. Initialize the product to 0.
4. Product = product + multiplier
5. Decrement the multiplicand by 1
6. If multiplicand is not equal to 0, repeat from step (d) otherwise store the product.
PROGRAM:
ADDRESS LABEL MNEMONICS HEX CODE
4100
MV1 D,00
4102
LDA 5500
4105
MOV B,A
4106
LDA 5501
4109
MOV C,A
410A
XRA A
410B L2
ADD B
410C
JNC L1
410F
INR D
4110 L1
DCR C
4111
JNZ L2
4114
STA 5502
4117
MOV A,D
4118
STA 5503
411B
HLT
OUTPUT:
RESULT:
Ex.No.2b
AIM:
To write an Assembly Language Program (ALP) for performing the division operation of 8-bit
numbers.
APPARATUS REQUIRED:
Microprocessor kit, Power supply.
PROBLEM STATEMENT:
Write an ALP in 8085 P to multiply two 8-bit binary numbers stored in the registers B and C
and store the result in the memory location 5502H.
ALGORITHM:
1. Get the dividend
2. Get the divisor
3. Initialize the quotient to 0.
4. Dividend = dividend – divisor
5. If the divisor is greater, store the quotient.
6. If dividend is greater, quotient = quotient + 1. Repeat from step (d)
PROGRAM:
ADDRESS LABEL MNEMONICS HEX CODE
4100 MV1 D,00
4102
LDA 5500
4105
MOV B,A
4106
LDA 5501
4109 L1
SUB B
410A
INR D
410B L2
JNC L1
410E
ADD B
410F
DCR D
4110
STA 5502
4113
MOV A,D
4114
STA 5503
4117
HLT
OUTPUT:
RESULT:
Ex.No.2c
AIM:
To write an Assembly Language Program (ALP) for performing the multiplication operation of
16-bit numbers.
APPARATUS REQUIRED:
Microprocessor kit, Power supply.
PROBLEM STATEMENT:
Write an ALP in 8085 P to multiply two 16-bit binary numbers stored in the register pairs BC
and DE and store the result in the memory location 5504H & 5506H.
ALGORITHM:
1. Get the multiplier.
2. Get the multiplicand
3. Initialize the MSBs and LSBs of product to 0.
4. LSBs of Product = LSBs of product + multiplier
5. If there is a carry, increment MSBs of product.
6. Decrement the multiplicand by 1
7. If multiplicand is not equal to 0, repeat from step (d) otherwise store the LSBs MSBs of product.
PROGRAM
RESULT:
Ex.No.2d
AIM:
To write an Assembly Language Program (ALP) for performing the division operation of 16-bit
numbers .
APPARATUS REQUIRED:
Microprocessor kit, Power supply.
PROBLEM STATEMENT:
Write an ALP in 8085 P to divide two 16-bit binary numbers stored in the register pairs BC and
DE and store the result in the memory location 5506H & 5508H.
ALGORITHM:
PROGRAM
ADDRESS LABEL MNEMONICS HEX CODE
4100 LHLD 5500
4103
XCHG
4104
LHLD 5502
4107
LXI B,0000
410A L2
MOV A,L
410B
SUB E
410C
MOV L,A
410D
MOV A.H
410E
SBB D
410F
MOV H,A
4110
JC L1
4113
INX B
4114
JMP L2
4117 L1
MOV A,L
4118
ADD E
4119
MOV L,A
411A MOV A,H
411B ADC D
411C MOV H,A
411D SHLD 5506
4120 MOV L,C
4121 MOV H,B
4122 SHLD 5508
4125
HLT
OUTPUT:
RESULT:
VIVA QUESTIONS:
1. Multiplication is repeated addition & division is repeated subtraction.
Ex.No.3a
AIM:
To write an Assembly Language Program (ALP) for finding the smallest & largest number in a
given array.
APPARATUS REQUIRED:
Microprocessor kit, Power supply.
ALGORITHM:
PROGRAM(Smallest):
4107
DCR B
4108
MOV C,M
4109 L1
INX H
410A
MOV A,M
410B
CMP C
410C
JZ L2
410F
JNC L2
4112
MOV C,A
4113 L2
DCR B
4114
JNZ L1
4117
MOV A,C
4118
STA 6000
411B
HLT
PROGRAM(LARGEST):
RESULT:
SORTING ‘n ‘NUMBERS
Ex. No.3b
AIM:
To write an Assembly Language Program (ALP) to sort a given array in ascending and
descending order.
APPARATUS REQUIRED:
Microprocessor kit, Power supply.
PROBLEM STATEMENT:
An array of length n is given from the location starting from 5200.Sort it into ascending order
and descending order and store the result starting from 5200H.
ALGORITHM:
PROGRAM(ASCENDING):
PROGRAM (DESCENDING):
RESULT:
VIVA QUESTIONS:
1. What is the use of Label?
A label is any sequence of alphabetic or numeric characters starting with an alphabetic. A label is
permitted on any line except a line where the opcode is IF, ELSE, or ENDIF. The label is
assigned the value of the assembly program counter before any of the rest of the line is
processed except when the opcode is EQU, ORG, PAGE, or SET.
CMP is a compare instruction. Used to compare register with that of the accumulator
AIM:
APPARATUS REQUIRED:
8085 microprocessor kit. Power supply.
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
AIM:
APPARATUS REQUIRED:
8085 microprocessor kit. Power supply.
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Ex.No.4c
AIM:
APPARATUS REQUIRED:
8085 microprocessor kit. Power supply.
ALGORITHM:
1. Load the data in A-register and then to B-register
2. Mask the upper nibble of the hexadecimal number in A register.
3. Call subroutine to get ASCII of lower nibble.
4. Store it in memory.
5. Move B to A and mask the lower nibble.
6. Rotate the value
7. Call subroutine to get ASCII of upper nibble.
8. Store it in memory
PROGRAM:
SUBROUTINE SUB:
ADDRESS LABEL MNEMONICS HEX CODE
801A CPI 0AH FE ,0A
801C JC L1 DA,21,42
801F ADI 07H C6,07
8021 L1 ADI 30H C6,30
8023 RET C9
OUTPUT:
RESULT:
Ex.No.4d
AIM:
APPARATUS REQUIRED:
8085 microprocessor kit. Power supply.
ALGORITHM:
1. Load the data in A-register.
2. Subtract 30H from A register.
3. Compare the content of A register with 0AH.
4. If A<0A H, jump to step 6. Else proceed to next step.
5. Subtract 07H from A register
6. Store it in memory
PROGRAM:
OUTPUT:
RESULT:
VIVA QUESTIONS:
1. Explain the difference between a JMP instruction and CALL instruction.
A JMP instruction permanently changes the program counter. A CALL
instruction leaves information on the stack so that the original program execution
sequence can be resumed.
2. What is the difference between the shift and rotate instructions?
A rotate instruction is a closed loop instruction. That is, the data moved
out at one end is put back in at the other end. The shift instruction loses the data
that is moved out of the last bit locations.
3. Explain LDA, STA and DAA instructions
LDA copies the data byte into accumulator from the memory location
specified by the 16-bit address. STA copies the data byte from the accumulator in
the memory location specified by 16-bit address. DAA changes the contents of
the accumulator from binary to 4-bit BCD digits.
4. Why is ANI used?
It is ANDed immediately. Here it is used to clear the accumulator (ie) ANI 0f
2 X 2 MATRIX MULTIPLICATION
Ex.No.5
AIM:
APPARATUS REQUIRED:
8085 microprocessor kit. Power supply.
ALGORITHM:
1. Load the 2 input matrices in the separate address and initialize the HL and the DE register pair
with the starting address respectively.
2. Call a subroutine for performing the multiplication of one element of a matrix with the other
element of the other matrix.
3. Call a subroutine to store the resultant values in a separate matrix.
PROGRAM:
OUTPUT
RESULT
VIVA QUESTIONS:
1. Why CPI used?
CPI- Compare with immediate data. Compare with the given data to check whether all
elements are multiplied.
2. What is a subroutine?
Ex.No.6a
AIM:
To add/ subtract two 16 bit numbers residing in memory and to store the result in memory.
APPARATUS REQUIRED:
8086 microprocessor kit. Power supply.
PROBLEM STATEMENT:
The program is to start from memory location 1000 H onwards. Input is to be stored
from 1200 H and output is to be stored from 1400 H onwards.
ALGORITHM:
The add instruction requires either the addend or the augend to be in a register, unless the source operand
is immediate since the addressing modes permitted for the source and destination are register-register,
memory to register, register to memory, register to immediate, and finally memory to immediate.
Hence one of the operands is initially moved to AX. Then using the add instruction, 16- bit addition is
performed.
The next arithmetic primitive is SUB. As discussed in ADD it permits the same modes of addressing.
Hence moving the minuend to a register pair is necessary. Then the result is moved to a location in
memory.
ADDITION
PROGRAM COMMENTS
SUBTRACTION
PROGRAM COMMENTS
OUTPUT:
RESULT:
16 BIT MULTIPLICATION/DIVISION
Ex.No.6b
AIM:
To multiply two 16 bit numbers in memory and store the result in memory and to perform
division of a 16 bit number by a 16 bit number and to store quotient and remainder in memory.
APPARATUS REQUIRED:
8086 Microprocessor kit, Power supply.
ALGORITHAM:
(i)16 BIT MULTIPLICATION:
1.Start the program.
2.Get the multiplicand and multiplier.
3.Find the product.
4.Store the result.
5.Terminate the program.
The 8086 Processor provides both signed and unsigned multiply in their instruction set to overcome the
loss of efficiency in performing the repeated addition.
The MUL instruction can have both 16 and 8 bit operands and the multiplicand is AX or AL, accordingly
the result for a byte multiply is a 16 bit number in AX while that for a word multiply is a 32 bit number,
the lower word of which is in AX and the higher word in DX.
MULTIPLICATION
PROGRAM COMMENTS
DIVISION
PROGRAM COMMENTS
OUTPUT:
RESULT:
VIVA QUESTIONS:
1.8086 Registers:
AX (= AH + AL)
BX (= BH + BL)
CX (= CH + CL)
DX (= DH + DL)
SI (source index)
DI (destination index)
SP (stack pointer)
BP (base pointer)
There are two forms of the multiply instruction: an unsigned multiplication (mul) and a signed
multiplication (imul). Unlike addition and subtraction, you need separate instructions for these two
operations.
Unsigned Multiplication:
mul reg
mul mem
imul reg
imul mem
imul reg, reg, immediate (2)
imul reg, mem, immediate (2)
imul reg, immediate (2)
imul reg, reg (3)
imul reg, mem (3)
AAM Instruction - ASCII adjust after Multiplication
The 80x86 divide instructions perform a 64/32 division (80386 and later only), a 32/16 division or
a 16/8 division. These instructions take the form:
STRING MANIPULATION
Ex.No.7
AIM:
To write 8086 program
5A) To copy a string of data words from one location to the other.
5B) To search a word from a string.
5C) To find and replace a word from a string.
APPARATUS REQUIRED:
8086 Microprocessor kit, power supply.
ALGORITHM:
5A)Copying a String
1.Initialise DS, S1, DS, ES.
2.Move the length of the strin in CX register.
3.Move the byte from DS to ES till CX =0.
5B)Search
1.Initialise ES and DI.
2. Move the no. Of characters in the string to CX.
3. Move the byte to be searched to AL.
4. Store the ASCII code of character in BL.
5. Scan for the byte in ES. If the byte is not found ZF ≠ 1 and repeat scanning.
6. If the byte is found ZF=1,display 01 in destination address. Otherwise, display 00 in destination
address.
COPYING A STRING
PROGRAM COMMENTS
HLT Stop
HLT Stop
OUTPUT:
RESULT:
AIM:
To display a message on the CRT screen of a microcomputer using DOS calls.
ALGORITHM:
1. Initialize the data segment and the message to be displayed.
2. Set function value for display.
3. Point to the message and run the interrupt to display the message in the CRT.
PROGRAM:
RESULT:
AIM:
To open a file using DOS calls.
ALGORITHM:
1. Initialize the data segment, file name and the message to be displayed.
2. Set the file attribute to create a file using a DOS call.
3. If the file is unable t o create a file display the message
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
FILENAME DB “SAMPLE.DAT”, “$”
MSG DB 0DH, 0AH, “FILE NOT CREATED”, ODH, OAH, “$”
DATA ENDS
CODE SEGMENT
START:MOV AX, DATA
MOV DS, AX
MOV DX, OFFSET FILENAME
MOV CX, 00H
MOV AH, 3CH
INT 21H
JNC LOOP1
MOV AX, DATA
MOV DS, AX
MOV DX, OFFSET MSG
MOV AH, 09H
INT 21H
LOOP1 MOV AH, 4CH
INT 21H
CODE ENDS
END START
RESULT:
AIM:
To display the disk information.
ALGORITHM:
1. Initialize the data segment and the message to be displayed.
2. Set function value for disk information.
3. Point to the message and run the interrupt to display the message in the CRT.
PROGRAM:
RESULT:
Ex.No.9a
AIM:
To initialize port A as i/p and to i/p the data set by SPDT switches through port A and store the data. The
avove is done in mode 0, 1, 2 of 8255.
APPARATUS REQUIRED:
Microprocessor kit, power supply, 8255 interface board.
THEORY:
The 8255 is called as a PPI (Programmable Peripheral Interface), which is used as a
mediator between processor and input/output devices. It has three 8-bit port i.e.
Port A (PA) and Port B (PB) & Port C (PC). Port C can be configure in two 4-bit port
i.e. Pcupper & Pclower. It has different controlling signals ie. RD, WR, CS are low-
level active signals and A0, A1 & Reset are high-level active signal.
MODES OF OPERATION OF 8255
These are two basic modes of operation of 8255.
I/O mode and Bit Set-Reset mode (BSR).
In I/O mode, the 8255 ports work as programmable I/O ports, while in BSR mode only port C
(PC0-PC7) can be used to set or reset its individual port bits.
Under the I/O mode of operation, further there are three modes of operation of 8255, so as to
support different types of applications, mode 0, mode 1 and mode 2.
Two 8-bit ports ( port A and port B )and two 4-bit ports (port C upper and lower ) are available.
The two 4-bit ports can be combined used as a third 8-bit port.
Any port can be used as an input or output port.
Output ports are latched. Input ports are not latched.
A maximum of four ports are available so that overall 16 I/O configurations are possible.
All these modes can be selected by programming a register internal to 8255 known as CWR.
The control word register has two formats. The first format is valid for I/O modes of operation,
i.e. modes 0, mode 1 and mode 2 while the second format is valid for bit
set/reset (BSR) mode of operation.
These formats are shown in following fig.
I/O MODES:
Control Word:
MODE 0
PROGRAM COMMENTS
MOV DX, CNT1(106) Initialize DX reg with port address for control word
MOV AL,90H Control word
OUT DX,AL Send it to control port
MOV DX, Set DX reg with port A address
PORTA(100)
IN AL,DX Get the contents of port A in AL
MOV DX, Set DX reg with port A address
PORTB(102)
OUT DX,AL Send the contents of port B to port address
HLT Stop
MODE 1
PROGRAM COMMENTS
MOV DX, CNT1 Initialize DX reg with port address for control word
MOV AL,0B0H Control word
OUT DX,AL Send it to control port
MOV AL,09H Control for BSR mode
OUT DX,AL Send it to control port
MOV DX,PORTC(104) Set DX reg with port C address
L1 : IN AL,DX Get the contents of port C in AL
AND AL,20H Mask RST 6.5
JZ L1 Check whether it is enabled
MOV DX, PORTA Set DX reg with port A address
IN AL,DX Get the contents of port A in AL
MOV DX,PORTB Set DX reg with port B address
OUT DX,AL Send the contents of AL to port B address
HLT Stop
MODE 2
PROGRAM COMMENTS
MOV DX, CNT1 Initialize DX reg with port address for control word
MOV AL,0C0H Control word
OUT DX,AL Send it to control port
MOV AL,09H Control for BSR mode
OUT DX,AL Send it to control port
MOV DX,PORTC Set DX reg with port C address
L1 : IN AL,DX Get the contents of port C in AL
AND AL,20H Mask RST 6.5
OUTPUT:
RESULT:
VIVA QUESTIONS:
4. What are the signals used in input control signal & output control signal?
Input control signal
STB (Strobe input)
IBF (Input buffer full)
INTR(Interrupt request)
Output control signal
OBF (Output buffer full)
ACK (Acknowledge input)
INTR(Interrupt request)
Ex.No.9b
AIM:
To display rolling message “CAROLINE” in the display (or) to accept a key and display it.
APPARATUS REQUIRED:
8086 microprocessor key, power supply of interfacing board.
PROBLEM STATEMENT:
The program starts from memory location 4100H. The input data is displayed at 8279 interfacing kit.
ALGORITHM:
Display:
1. Initialise the count.
2. Set 8279 for 8 digit character display, right entry.
3. Set 8279 for clearing to display.
4. Write the command to display.
5. Load the character into display and accumulator kit.
6. Introduce the delay.
7. Repeat from step 1.
0 0 0 1 0 0 0 0
0 0 0 D D K K K
DD
00- 8Bit character display left entry
01- 16Bit character display left entry
10- 8Bit character display right entry
11- 16Bit character display right entry
KKK- Key Board Mode
000-2Key lockout.
1 1 0 1 1 1 0 0
1 1 0 CD CD CD CF CA
Auto increment = 1, the row address selected will be incremented after each of read and write
operation of the display RAM.
PROGRAM TABLE
PROGRAM COMMENTS
START : MOV SI,1200H Initialize array
MOV CX,000FH Initialize array size
MOV AL,10 Store the control word for display mode
OUT C2,AL Send through output port
MOV AL,CC Store the control word to clear display
OUT C2,AL Send through output port
MOV AL,90 Store the control word to write display
OUT C2,AL Send through output port
L1 : MOV AL,[SI] Get the first data
OUT C0,AL Send through output port
CALL DELAY Give delay
INC SI Go & get next data
LOOP L1 Loop until all the data’s have been taken
JMP START Go to starting location
DELAY : MOV DX,0A0FFH Store 16bit count value
LOOP1 : DEC DX Decrement count value
JNZ LOOP1 Loop until count values becomes zero
RET Return to main program
LOOK-UP TABLE:
1200 98 68 7C C8
1204 FF 1C 29 FF
RESULT:
OUTPUT:
RESULT:
VIVA QUESTIONS:
Ex.No.10a
AIM:
To Interface 8253 with 8085 and to verify the operation of 8253 in different modes.
APPARATUS REQUIRED:
Microprocessor Kit, Powersupply, 8253 Interfaceing kit, CRO
PROBLEM STATEMENT:
The program starts from memory location 4100H onwards. Output waveform can be observed by
properly connecting CRO at the output port.
PROGRAM:
It is observed in CRO that the output of Channel 0 is initially LOW. After giving six clock pulses, the
output goes HIGH.
Example:
The following program initializes channel 0 of 8253 in Mode 1 and also initiates triggering of Gate 0.
OUT 0 goes low, as clock pulse after triggering the goes back to high level after 5 clock pulses. Execute
the program, give clock pulses through the debounce logic and verify using CRO.
from one output pulse to the next equals the number of input counts in the count register. If the count
register is reloaded between output pulses the present period will not be affected but the subsequent
Example:
Using Mode 2, Let us divide the clock present at Channel 1 by 10. Connect the CLK1 to
PCLK.In CRO observe simultaneously the input clock to channel 1 and the output at Out1.
other half for even number count. If the count is odd, the output will be high for (count + 1)/2 counts.
Example:
Vary the frequency by varying the count. Here the maximum count is FFFF H. So, the square
wave will remain high for 7FFF H counts and remain low for 7FFF H counts. Thus with the input clock
frequency of 1.5 MHz, which corresponds to a period of 0.067 microseconds, the resulting square wave
has an ON time of 0.02184 microseconds and an OFF time of 0.02184 microseconds.
To increase the time period of square wave, set the jumpers such that CLK2 of 8253 is
connected to OUT 0. Using the above-mentioned program, output a square wave of frequency 150 KHz
at channel 0. Now this is the clock to channel 2.
Example:
Connect OUT 0 to CLK 2 (jumper J1). Execute the program and observe the output OUT 2.
Counter 2 will generate a pulse after 1 second.
RESULT:
VIVA QUESTIONS:
CS 2259 MICROPROCESSORS LAB (CSE)
P a g e | 68
2.. What are the different types of write operations used in 8253?
There are two types of write operations in 8253
(1) Writing a control word register
(2) Writing a count value into a count register
The control word register accepts data from the data buffer and initializes
the counters, as required. The control word register contents are used for
(a) Initializing the operating modes (mode 0-mode4)
(b) Selection of counters (counter 0- counter 2)
(c) Choosing binary /BCD counters
(d) Loading of the counter registers.
The mode control register is a write only register and the CPU cannot read
its contents.
Ex.No.10b
AIM :
To study interfacing technique of 8251(USART) with microprocessor 8085 and write an 8085 ALP to
transmit and receive data between two serial ports with Rs 232 cable.
APPARATUS REQUIRED:
8085 Kit, Rs232 cable
ALGORITHM:
1. Initialise 8253 and 8251 to check the transmission and reception of character
2. Initialise 8253 to give output of 150 Khz at channel 0 which give 9600 baud rate of 8251.
3. The command word and mode word is written to the 8251 to set up for subsequent operations
4. The staus 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.
THEORY:
The 8251 is a USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data
communication. As a peripheral device of a microcomputer system, the 8251 receives parallel data from
the CPU and transmits serial data after conversion. This device also receives serial data from the outside
and transmits parallel data to the CPU after conversion.
Control Words There are two types of control word.
1) Mode Instruction
Mode instruction is used for setting the function of the 8251. Mode instruction will be in "wait for write"
at either internal reset or external reset. That is, the writing of a control word after resetting will be
recognized as a "mode instruction."
Items set by mode instruction are as follows:
• Synchronous/asynchronous mode
• Stop bit length (asynchronous mode)
• Character length
• Parity bit
• Baud rate factor (asynchronous mode)
• Internal/external synchronization (synchronous mode)
• Number of synchronous characters (Synchronous mode)
2) Command
Command is used for setting the operation of the 8251. It is possible to write a command whenever
necessary after writing a mode instruction and sync characters.
Items to be set by command are as follows:
• Transmit Enable/Disable
• Receive Enable/Disable
• DTR, RTS Output of data.
• Resetting of error flag.
• Sending to break characters
• Internal resetting
• Hunt mode (synchronous mode)
COMMAND WORD
MODE WORD
STATUS WORD
PROGRAM (Transmitter):
PROGRAM (Receiver):
OUTPUT:
RESULT:
VIVA QUESTIONS:
1.What is an USART?
USART stands for universal synchronous/Asynchronous Receiver/
Transmitter. It is a programmable communication interface that can communicate by
using either synchronous or asynchronous serial data.
The receiver tests the state of the incoming signal on each clock pulse, looking for the
beginning of the start bit. If the apparent start bit lasts at least one-half of the bit time, it is valid
and signals the start of a new character. If not, the spurious pulse is ignored. After waiting a
further bit time, the state of the line is again sampled and the resulting level clocked into a shift
register.
Transmitter
Transmission operation is simpler since it is under the control of the transmitting system. As
soon as data is deposited in the shift register after completion of the previous character, the
USART hardware generates a start bit, shifts the required number of data bits out to the line,
generates and appends the parity bit (if used), and appends the stop bits. Since transmission of a
single character may take a long time relative to CPU speeds, the USART will maintain a flag
showing busy status so that the host system does not deposit a new character for transmission
until the previous one has been completed; this may also be done with an interrupt. Since full-
duplex operation requires characters to be sent and received at the same time, practical USARTs
use two different shift registers for transmitted characters and received characters.
8051 PROGRAMS
8 BIT ADDITION/SUBTRACTION
Ex.No.11a
AIM:
To write an ALP to perform 8 bit addition/subtraction in 8051.
Apparatus required:
8051 microcontroller kit, power supply.
ALGORITHM:
8 bit addition:
1. Clear the program status word.
2. Load the first number in the accumulator.
3. Load the second reg. in the register R0.
4. Load the destination address in the DPTR.
5. Add te 2 numbers.
6. Store the sum and carry in the destination address.
7. Terminate the program.
8 bit subtraction:
1. Clear PSW.
2. Select the register by giving proper values.
3. Lolad the accumulator with 1st data & reg with 2nd data.
4. Subtract 2nd data from 1st data.
5. Store the diff and borrow and terminate the program.
4109 L1 SJMP L1
4109 L1 SJMP L1
OUTPUT:
RESULT:
Ex.No.11b
AIM:
To write a program for 8 bit multiplication & 8 bit division using 8051 microcontroller.
Apparatus required:
8051 microcontroller kit, power supply.
ALGORITHM:
8 bit multiplication:
1. Clear PSW.
2. Select register bank by giving proper values.
3. Load accumulator A with any derived 8 bit data.
4. Load registers B with 2nd data.
5. Multiply there 2 nods.
6. Store the result
7. Terminate the program.
8 BIT DIVISION:
1. Clear PSW.
2. Select register bank by giving proper values.
3. Load A with 1st data dividend.
4. Load B wit 8 bit divisor.
5. Divide A/B.
6. Store the quotient & remainder.
7. Terminate the program.
8 Bit Multiplication
ADDRESS LABEL OPCODE OPERAND HEX CODE
4100 MOV A ,#data1
8 Bit Division
ADDRESS LABEL OPCODE OPERAND HEX CODE
4100 MOV A, # data1
OUTPUT:
RESULT:
Ex.No:12a
AIM:
To write an ALP in 8051 to rotate the motor at different speeds in clockwise and in anticlockwise
directions with delay.
APPARATUS REQUIRED:
1. Microcontroller kit
2. Power supply
3. Stepper motor interface board
PROBLEM STATEMENT
The Program starts from memory location 4100H.The input data should be available at 4300H.
The output is sent through ports to run the stepper motor.
THEORY
A motor in which a 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 the next.The
stepper motor windings A1,B1,A2,B2 can be cyclically excited with a DC current to run the motor in a
clockwise direction.By reversing the phase sequence A1,B2,A2,B1, we can obtain anticlockwise
stepping.
ALGORITHM
1. Get the first data from the look-up table.
2. Initialize the counter and move data into accumulator.
3. Drive the stepper motor circuitry and introduce delay
4. Decrement the counter
5. Repeat the above procedure both for backward and forward directions.
PROGRAM :
ORG
4103 MOV
4105 LOOP: MOVX
4106 PUSH
4108 PUSH
410A MOV
410D MOVX
410E MOV
4110 DELAY: MOV
4112 DELAY1: DJNZ
4114 DJNZ
4116 POP
4118 POP
411A INC
411B DJNZ
411D SJMP
411F TABLE: DB
PROCEDURE:
Enter the above program starting from location 4100.and execute the same. The stepper motor rotates.
Varying the count at R4 and R5 can vary the speed. Entering the data in the look-up TABLE in the
reverse order can vary direction of rotation.
CLOCKWISE DIRECTION
Memory Location A1 A2 B1 B2 Hex Code
ANTICLOCKWISE DIRECTION
RESULT:
Ex.No.12b
AIM: -
To Interface Analog-to-Digital converter to 8051 and write Assembly Language Program to read Digital
value from ADC.
APPARATUS:-
Microprocessor trainer kit, ADC kit, power supply, data cable etc
THEORY:
ANALOG TO DIGITAL CONVERTER
Resolution 8 bits
1. Conversion time 100 micro sec.
2. Single supply 5V
3. 8 channel multiplexed with latched control logic
4. easy interface to all microprocessor
5. 0 to 5V analog input voltage range with single 5V supply
6. low power consumption 15mW
7. latched tristate output
WORKING:-
ADC interface consists of a NAND gate oscillator witch feeds 50 KHz as the input clock to ADC, input
to channel is given through terminal blocks provided on the card. Channel selection is done using port
lines PC0, PC1 & PC2, START OF CONVERSION and ALE is controlled by port line PC7. Converted
digital output is read by ADC through PORTA lines by enabling OE.
In this method of interfacing microprocessor is continuously monitoring EOC line (which is connected
to port line PA7). When this goes high, make OE (PC6) high & then low, this will put the digital
equivalent of analog voltage of the given channel on data lines of ADC. Read the digital data through
port lines PA0 to PA7 and display the same data.
PROGRAM
CH0 10 18
CH1 11 19
CH2 12 1A
CH3 13 1B
CH4 14 1C
CH5 15 1D
CH6 16 1E
CH7 17 1F
OUTPUT:
RESULT:
DIGITAL-TO-ANALOG CONVERTER
Ex.No.12c
AIM:
To write an ALP for digital-to analog converter to generate different types of waveforms at DAC
output
APPARATUS REQUIRED:
1. Microcontroller kit
2. Power supply
3. AC interface board
PROBLEM STATEMENT
The program starts from 4100H location. The input is given in the memory locations 4100H and 4108H.
The output is sent to the output ports. The waveforms are measured at the output port using CRO.
THEORY
Since DAC 0800 is an 8-bit DAC and the output voltage variation is between -5v and +5v.The
basic idea behind the generation of waveforms is the continuous generation of analog output of DAC.
With 00H as input to DAC, the analog output is -5V.Similarly with FFH as input, the output is +5V.
ALGORITHM
WAVEFORM GENERATION
SQUARE WAVEFORM
1. Send low value(00) to DAC
4. Introduce delay
SAW-TOOTH WAVEFORM
1. Load low value(00) to accumulator
TRIANGULAR WAVEFORM
1. Load low value(00) to accumulator
4. Repeat step 2 and 3 until accumulator value reaches FF, decrement the accumulator and
send this value to DAC
5. Repeat the above procedure from step1
SQUAREWAVE:
SAW-TOOTH WAVEFORM
TRIANGULAR WAVEFORM
OUTPUT:
RESULT:
VIVA QUESTIONS:
1.Features of 8051microcontroller.
2. State the functions of RS1 and RS0 bit in the flag register
It is used to select the register banks
RS1 RS0 Bank selection
0 0 00 H – 07 H BANK 0
0 1 08 H - 0F H BANK 1
1 0 10 H – 17 H BANK 2
1 1 18 H – 1F H BANK 3
ABSTRACT:
Personal Safes are revolutionary locking storage cases that open with just the touch of your finger. These
products are designed as secure storage for medications; jewelry, weapons, documents, and other
valuable or potentially harmful items. These utilize fingerprint recognition technology to allow access to
only those whose fingerprints you choose. It contains all the necessary electronics to allow you to store,
delete, and verify fingerprints with just the touch of a button. Stored fingerprints are retained even in the
event of complete power failure or battery drain. These eliminates the need for keeping track of keys or
remembering a combination password, or PIN. It can only be opened when an authorized user is present,
since there are no keys or combinations to be copied or stolen, or locks that can be picked. In this project
the fingerprint module from Miaxis Biometrics is used. It can store up to 750 finger prints on its own
memory. It can be controlled through its serial port. The microcontroller AT89S52 interacts with the
module. You can add a fingerprint, Delete a fingerprint and identify the fingerprint. To add a fingerprint,
just show the finger on the module and press the ADD key. Now the microcontroller will send the ADD
command to the module and the module will add it into the memory. To identify the finger, press the
Identify button and if the finger matches then the Relay is complemented. Also the fingerprint ID is
displayed over the LCD display.
SYSTEM REQUIREMENTS:
Microcontroller AT89S52
Transistors
Resistors
LCD
Buzzer
CIRCUIT DIAGRAM:
SOURCE CODE:
; ***SYSTEM INSTRUCTIONS***
COUNTER: DS 1
BYTE: DS 10
TEMP: DS 1
TEMPS: DS 1
USER_COUNT: DS 1
ERROR_COUNT: DS 1
;*****************************************************************************
*******************************************************************************
CSEG ; Code begins here
; ---------==========----------==========---------=========---------
; Main routine. Program execution starts here.
; ---------==========----------==========---------=========---------
ORG 00H ; Reset
AJMP MAIN
ORG 23H
JMP SERIAL
; ---------==========----------==========---------=========---------
MAIN:
MOV PSW,#RB0 ; Select register bank 0
MOV SP,#60h
MOV A,PCON
SETB ACC.7
MOV PCON,A
MOV TMOD,#20H
MOV TH1,#0FFH
MOV SCON,#50H
SETB ES
SETB EA
SETB TR1
SETB ADDS
SETB SEARCH
CLR LOAD
CLR ALARM
MOV ERROR_COUNT,#00H
CALL RESETLCD4
TOPS: CALL DISPLAY
TOP:
JNB ADDS,ADD_USERS
JNB SEARCH,SEARCH_USERS
JNB DELETE,DELETE_USER
AJMP TOP
SEARCH_USERS:
AJMP SEARCH_USER
ADD_USERS:
AJMP ADD_USER
DELETE_USER:
JNB DELETE,$
CALL DISPLAY_DEL
CLR RECEIVED
MOV DPTR,#SEARCH_USER_DATA
CALL SEND_SERIAL
CALL DELAYS
MOV A, BYTE+4
CJNE A, #39H, NOT_MATCHS
CALL FIN_MATCHED
MOV TEMP, BYTE+6
CALL DELAYS
CALL DELAYS
MOV DPTR, #DEL_USER_DATA
MOV TEMPS, #00H
CALL SEND_SERIAL
MOV SBUF, TEMP
CALL TRANSDELAY
MOV A, TEMPS
ADD A, TEMP
MOV SBUF, A
CALL TRANSDELAY
CALL DELAYS
MOV A, BYTE+4
CJNE A, #31H, NOT_MATCHES
CALL FIN_DELETED
CALL DELAYS
CALL DELAYS
AJMP TOPS
NOT_MATCHES:
CALL NOT_DELETED
CALL DELAYS
CALL DELAYS
AJMP TOPS
NOT_MATCHS:
CALL NOT_MATCHED
CALL DELAYS
CALL DELAYS
AJMP TOPS
ADD_USER:
CALL DISPLAY1
CALL DELAYS
JNB ADDS,$
CLR RECEIVED
MOV DPTR,#SEARCH_USER_DATA
CALL SEND_SERIAL
CALL DELAYS
MOV A,BYTE+4
CJNE A,#39H,NOT_MATCHSS
CALL ALREADY_EXIT
CALL DELAYS
CALL DELAYS
AJMP TOPS
NOT_MATCHSS:
CLR RECEIVED
MOV DPTR,#READ_FLASH ;LOAD USER COUNT FROM
FLASH MEMORY
CALL SEND_SERIAL
CALL DELAY
MOV A, BYTE+4
MOV USER_COUNT,A
CJNE A,#16,USER_NOT_FULL
CALL USER_FULL_DISPLAY
CALL DELAYS
CALL DELAYS
AJMP TOPS
USER_NOT_FULL:
CLR RECEIVED
MOV DPTR,#ADD_USER_DATA
MOV TEMPS, #00H
CALL SEND_SERIAL
MOV SBUF, USER_COUNT
CALL TRANSDELAY
MOV A, TEMPS
ADD A, USER_COUNT
MOV SBUF,A
CALL TRANSDELAY
NEXT:
CALL DELAYS
CALL DELAYS
JNB RECEIVED,$
MOV A,BYTE+4
CJNE A,#31H,NOT_SAVED
CALL DISPLAY_SUCESS
CALL DELAYS
CALL DELAYS
CLR RECEIVED
MOV DPTR,#STORE_FLASH
MOV TEMPS,#00H
CALL SEND_SERIAL
INC USER_COUNT
MOV SBUF, USER_COUNT
CALL TRANSDELAY
MOV A, TEMPS
ADD A, USER_COUNT
MOV SBUF,A
CALL TRANSDELAY
CLR RECEIVED
AJMP TOPS
NOT_SAVED:
CALL DISPLAY_NOTSUCESS
CALL DELAYS
CALL DELAYS
CLR RECEIVED
AJMP TOPS
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
SEND_SERIAL:
CLR A
MOVC A,@A+DPTR
CJNE A,#0FFH,SEND_D
RET
SEND_D:
MOV SBUF,A
ADD A, TEMPS
MOV TEMPS,A
CALL TRANSDELAY
INC DPTR
AJMP SEND_SERIAL
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
SEARCH_USER:
JNB SEARCH,$
CALL DISPLAY2
CLR RECEIVED
MOV DPTR,#SEARCH_USER_DATA
CALL SEND_SERIAL
CALL DELAYS
MOV A, BYTE+4
CJNE A,#39H,NOT_MATCH
CPL LOAD
CLR ALARM
MOV ERROR_COUNT,#00H
CALL MATCHED
MOV TEMP, BYTE+6
CALL SPLITDISP
CALL DELAYS
CALL DELAYS
AJMP TOPS
NOT_MATCH:
INC ERROR_COUNT
MOV A,ERROR_COUNT
CJNE A,#04H,ALARM_ON
SETB ALARM
ALARM_ON:
CALL NOT_MATCHED
CALL DELAYS
CALL DELAYS
AJMP TOPS
SPLITDISP:
MOV A,TEMP
MOV TEMP, A
ANL A, #0F0H
SWAP A
ADD A, #30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV A, TEMP
ANL A, #0FH
ADD A, #30H
MOV R4, A
CALL WRLCDDATA
CALL MDELAY
MOV R4, #' '
CALL WRLCDDATA
CALL MDELAY
RET
;---------==========----------==========---------=========---------
ADD_USER_DATA:
DB 4DH, 58H, 10H, 03H, 40H, 00H, 0FFH
DB 4DH, 58H, 10H, 03H, 40H, 00H, 01H, 0F9H, 0FFH
;ADDRESS--------------------------^
SEARCH_USER_DATA:
DB 04DH, 58H, 10H, 05H, 44H, 00H, 00H, 00H, 0FEH, 0FCH, 0FFH
STORE_FLASH:
DB 4DH, 58H, 10H, 05H, 64H, 00H, 00H, 01H, 0FFH
DB 4DH, 58H, 10H, 05H, 64H, 00H, 00H, 01H, 00H, 1FH, 0FFH
READ_FLASH:
DB 4DH, 58H, 10H, 04H, 62H, 00H, 00H, 01H, 1CH, 0FFH
;ADDRESS--------------------------^
;COUNT---------------------------------^
DEL_USER_DATA:
DB 4DH, 58H, 10H, 03H, 42H, 00H, 0FFH
;---------==========----------==========---------=========---------
SERIAL:
PUSH PSW ; save current register set
MOV PSW,#RB1
PUSH ACC
JB TI,TRANSD
MOV A,SBUF
CJNE A,#4DH,DOWN2
MOV COUNTER,#01H
JMP DDWN
TRANSD: AJMP TRANS
DOWN2:
MOV R1,COUNTER
CJNE R1,#01H,YH1
MOV BYTE,A
JMP DOWN1
YH1: CJNE R1,#02H,YH2
MOV BYTE+1,A
JMP DOWN1
YH2: CJNE R1,#03H,YH3
MOV BYTE+2,A
MOV TEMP,A
JMP DOWN1
YH3: CJNE R1,#04H,YH4
MOV BYTE+3,A
DEC TEMP
MOV A,TEMP
CJNE A,#00H,DOWN1
SETB RECEIVED
JMP DOWN1
YH4: CJNE R1,#05H,YH5
MOV BYTE+4,A
DEC TEMP
MOV A,TEMP
CJNE A,#00H,DOWN1
SETB RECEIVED
JMP DOWN1
YH5: CJNE R1,#06H,YH6
MOV BYTE+5,A
DEC TEMP
MOV A,TEMP
CJNE A,#00H,DOWN1
SETB RECEIVED
JMP DOWN1
YH6: CJNE R1,#07H,YH7
MOV BYTE+6,A
DEC TEMP
MOV A,TEMP
CJNE A,#00H,DOWN1
SETB RECEIVED
JMP DOWN1
YH7: CJNE R1,#08H,DOWN1
MOV BYTE+7,A
DEC TEMP
MOV A,TEMP
CJNE A,#00H,DOWN1
SETB RECEIVED
JMP DOWN1
DOWN1: INC COUNTER
DDWN: CLR RI
POP ACC
POP PSW
RETI
TRANS: CLR TI
POP ACC
POP PSW
RETI
;**********************************************************
;**********************************************************
TRANSDELAY:
MOV R7,#5FH
DJNZ R7,$
RET
;**************************************************************************
;##########################################################
; DISPLAY ROUTINES
;##########################################################
DISPLAY:
MOV DPTR,#MSAG1
CALL LCD_MSG
RET
MSAG1:
DB 1H,80H,'Fingerprint Based',0C0H,'Security System',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DISPLAY1:
MOV DPTR,#MSAG2
CALL LCD_MSG
RET
MSAG2:
DB 1H,83H,'Show your',0C0H,'Finger to ADD..',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DISPLAY2:
MOV DPTR,#MSAG3
CALL LCD_MSG
RET
MSAG3:
DB 1H,83H,'Show your',0C3H,'Finger....',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
USER_FULL_DISPLAY:
MOV DPTR,#MSAG4
CALL LCD_MSG
RET
MSAG4:
DB 1H,83H,'User memory',0C3H,'## FULL ##',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DISPLAY_SUCESS:
MOV DPTR,#MSAG5
CALL LCD_MSG
RET
MSAG5:
DB 1H,83H,'User Added',0C3H,'Sucessfully',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DISPLAY_NOTSUCESS:
MOV DPTR,#MSAG6
CALL LCD_MSG
RET
MSAG6:
DB 1H,83H,'User Added',0C2H,'## Failed ##',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MATCHED:
MOV DPTR,#MSAG7
CALL LCD_MSG
RET
MSAG7:
DB 1H,83H,'Fingerprint',0C1H,'Matched ID:',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NOT_MATCHED:
MOV DPTR,#MSAG8
CALL LCD_MSG
RET
MSAG8:
DB 1H,83H,'Fingerprint',0C2H,'NOT Matched',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DISPLAY_DEL:
MOV DPTR,#MSAG9
CALL LCD_MSG
RET
MSAG9:
DB 1H,83H,'Show your',0C0H,'Finger to DELETE',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FIN_MATCHED:
MOV DPTR,#MSAG10
CALL LCD_MSG
RET
MSAG10:
DB 1H,83H,'Fingerprint',0C4H,'Matched',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FIN_DELETED:
MOV DPTR,#MSAG11
CALL LCD_MSG
RET
MSAG11:
DB 1H,83H,'Fingerprint',0C1H,'## Deleted ##',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NOT_DELETED:
MOV DPTR,#MSAG12
CALL LCD_MSG
RET
MSAG12:
DB 1H,83H,'Fingerprint',0C2H,'NOT Deleted',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ALREADY_EXIT:
MOV DPTR,#MSAG13
CALL LCD_MSG
RET
MSAG13:
DB 1H,83H,'Fingerprint',0C1H,'Already Exits',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DELAY:
MOV R1,#0FFH
RE1: MOV R2,#0FFH
RE: NOP
DJNZ R2,RE
DJNZ R1,RE1
RET
;**********************************************************
DELAYS: ;One second delay routine
MOV R0,#05H
RS3: MOV R1,#0FFH
RA1: MOV R2,#0FFH
RS2: NOP
DJNZ R2,RS2
DJNZ R1,RA1
DJNZ R0,RS3
RET
;**********************************************************
DELAYSS: ;One second delay routine
MOV R0,#03H
RE3: MOV R1,#0FFH
RZ1: MOV R2,#0FFH
RE2: NOP
DJNZ R2,RE2
DJNZ R1,RZ1
DJNZ R0,RE3
RET
;**********************************************************
; INITIALIZE THE LCD 4-BIT MODE
;**********************************************************
INITLCD4:
CLR LCD_RS ; LCD REGISTER SELECT LINE
; **********************************************************
; SUB RECEIVES A COMMAND WORD TO THE LCD
; COMMAND MUST BE PLACED IN R4 BY CALLING PROGRAM
; **********************************************************
WRLCDCOM4:
CLR LCD_E
CLR LCD_RS ; SELECT READ COMMAND
PUSH ACC ; SAVE ACCUMULATOR
MOV A, R4 ; PUT DATA BYTE IN ACC
MOV C, ACC.4 ; LOAD HIGH NIBBLE ON DATA BUS
MOV LCD_DB4, C ; ONE BIT AT A TIME USING...
MOV C, ACC.5 ; BIT MOVE OPERATOINS
MOV LCD_DB5, C
MOV C, ACC.6
MOV LCD_DB6, C
MOV C, ACC.7
MOV LCD_DB7, C
SETB LCD_E ; PULSE THE ENABLE LINE
CLR LCD_E
MOV C, ACC.0 ; SIMILARLY, LOAD LOW NIBBLE
MOV LCD_DB4, C
MOV C, ACC.1
MOV LCD_DB5, C
MOV C, ACC.2
MOV LCD_DB6, C
MOV C, ACC.3
MOV LCD_DB7, C
CLR LCD_E
SETB LCD_E ; PULSE THE ENABLE LINE
CLR LCD_E
CALL MADELAY
POP ACC
RET
; **********************************************************
; SUB TO RECEIVE A DATA WORD TO THE LCD
; DATA MUST BE PLACED IN R4 BY CALLING PROGRAM
; **********************************************************
WRLCDDATA:
CLR LCD_E
SETB LCD_RS ; SELECT READ DATA
PUSH ACC ; SAVE ACCUMULATOR
MOV A, R4 ; PUT DATA BYTE IN ACC
MOV C, ACC.4 ; LOAD HIGH NIBBLE ON DATA BUS
MOV LCD_DB4, C ; ONE BIT AT A TIME USING...
MOV C, ACC.5 ; BIT MOVE OPERATOINS
MOV LCD_DB5, C
MOV C, ACC.6
MOV LCD_DB6, C
MOV C, ACC.7
MOV LCD_DB7, C
SETB LCD_E ; PULSE THE ENABLE LINE
CLR LCD_E
MOV C, ACC.0 ; SIMILARLY, LOAD LOW NIBBLE
MOV LCD_DB4, C
MOV C, ACC.1
MOV LCD_DB5, C
MOV C, ACC.2
MOV LCD_DB6, C
MOV C, ACC.3
MOV LCD_DB7, C
CLR LCD_E
SETB LCD_E ; PULSE THE ENABLE LINE
CLR LCD_E
NOP
NOP
POP ACC
RET
; **********************************************************
; SUB TAKES THE STRING IMMEDIATELY FOLLOWING THE CALL AND
; DISPLAYS ON THE LCD. STRING MUST BE TERMINATED WITH A
; NULL (0).
; **********************************************************
LCD_MSG:
Lcd_Msg_Data: ;
MOV R4,A
CALL WRLCDDATA ; It was data, RECEIVE it to Lcd
JMP Lcd_Msg ; Go get next byte from stringz
Lcd_Msg9:
; **********************************************************
; 1 MILLISECOND DELAY ROUTINE
; **********************************************************
MDELAY:
PUSH ACC
MOV A,#0A6H
MD_OLP:
INC A
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
JNZ MD_OLP
NOP
POP ACC
RET
MADELAY:
PUSH ACC
MOV A,#036H
MAD_OLP:
INC A
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
JNZ MAD_OLP
NOP
POP ACC
RET
END
CONCLUSION:
VIVA QUESTIONS:
1. What is Microprocessor ?
It is a program controlled semiconductor device (IC}, which fetches,
decode and executes instructions.
2. What are the basic units of a microprocessor ?
The basic units or blocks of a microprocessor are ALU, an array of
registers and control unit.
3.what is Software and Hardware?
The Software is a set of instructions or commands needed for
performing a specific task by a programmable device or a computing
machine.
The Hardware refers to the components or devices used to form
computing machine in which the software can be run and tested.
Without software the Hardware is an idle machine.
4.What is assembly language?
The language in which the mnemonics (short -hand form of
instructions) are used to write a program is called assembly language.
The manufacturers of microprocessor give the mnemonics.
5. What are machine language and assembly language programs?
The software developed using 1's and 0's are called machine language,
programs. The software developed using mnemonics are called
assembly language programs.
6.Give the power supply and frequency of the microprocessoe?
The power supply of 8085 is +5V and clock frequency in 3MHz.
7. 8085 is a 8-bit microprocesspr
10. How many operations are there in the instruction set of 8085
microprocessor?
There are 74 operations in the 8085 microprocessor.
11. What are the functions of an accumulator?
The accumulator is the register associated with the ALU operations and
CS 2259 MICROPROCESSORS LAB (CSE)
P a g e | 107
Sign flag, Zero flag, Auxillary flag, Parity flag, Carry flag.
Stack pointer is a special purpose 16-bit register in the Microprocessor, which holds the address of the
top of the stack.
Program counter holds the address of either the first byte of the next instruction to be fetched for
execution or the address of the next byte of a multi byte instruction, which has not been completely
fetched. In both the cases it gets incremented automatically one by one as the instruction bytes get
fetched. Also Program register keeps the address of the next instruction.
1.What is an Opcode?
The part of the instruction that specifies the operation to be performed is called the operation
code or opcode.
2.What is an Operand?
The data on which the operation is to be performed is called as an Operand.
3.List out the five categories of the 8085 instructions. Give examples of the
instructions for each group.
• Data transfer group – MOV, MVI, LXI.
• Arithmetic group – ADD, SUB, INR.
• Logical group –ANA, XRA, CMP.
• Branch group – JMP, JNZ, CALL.
• Stack I/O and Machine control group – PUSH, POP, IN, HLT.
4.Name 5 different addressing modes?
Immediate, Direct, Register, Register indirect, Implied addressing modes
8.Subtraction concept:
Any 8-bit number, or the contents of a register, or the contents of a memory location can be
subtracted from the contents of the accumulator and the results stored in the accumulator. The
subtraction is performed in 2's compliment, and the results if negative, are expressed in 2's complement.
No two other registers can be subtracted directly.
1.