Download as pdf or txt
Download as pdf or txt
You are on page 1of 77

NATIONAL INSTITUTE OF TECHNOLOGY

DURGAPUR

LAB REPORT
Subject: Microprocessor & Microcontroller Laboratory

Subject code: EC652


SUBMITTED BY:

P. Tharun Kalyan
Jitmohan Raj
Santosh Anand
Sidharth J Unni
Akash Sinha

(12/EC/01)
(12/EC/02)
(12/EC/03)
(12/EC/04)
(12/EC/05)

EXPERIMENT NO. 1
1. Write an ALP for 8085 to find the sum of two decimal numbers (34)10 & (59)10.
Store the result in memory location say XXXXH.
SOLUTION
ORG 0000H
MVI A,34H
MVI B,59H
ADD B
DAA
STA 2000H
HLT 2000H
RESULT- CONTENTS OF REGISTERS AFFECTED

FLAG REGISTERS (FR): 94 H


MEMORY CONTENT: 93H
A-93 H
B-59 H
SPH: EF H
SPL: FF H
PCH: 80 H
PCL: 09 H
I: 0F H

2. Write an ALP for 8085 to find the subtraction of two decimal numbers (74)10 & (37)10. Store

the result in memory location say XXXXH.


SOLUTION
ORG 0000H
MVI A, 99H
MVI B, 74H
MVI C, 37H
SUB C
INR A
ADD B
DAA
STA 2001H
HLT
RESULT- CONTENTS OF REGISTERS AFFECTED

FLAG REGISTERS (FR): 01 H


MEMORY CONTENT: 37 H
A-37 H
B-74 H
C-37 H
SPH: EF H
SPL: FF H
PCH: 80 H
PCL: 0E H
I: 0F H
H: 1E H

3. Write an ALP for 8085 to find the sum of 1st 100 natural numbers. Store the 16-bit
sum in two successive memory locations XXXXH & (XXXX+1)H respectively where
the LSB of the sum should be in XXXXH.
SOLUTION
ORG 8000H
LXI B, 0001H
LXI H, 0000H
LXI D, 64H
REPET: DAD B
INX B
DCR D
JNZ REPET
SHLD 8040HH
HLT
RESULT- CONTENTS OF REGISTERS AFFECTED

HL: 13BA H
DE: 0000 H
MEMORY CONTENT: 8040H -BA H
8041H -13 H

SPH: EF H
SPL: FF H
PCH: 80 H
PCL: 12 H
1: 0FH

4. Write an ALP for 8085 to find the no of negative, zero & positive elements from a
given set of data where the length of the data is in memory location (XXXX+3) H and
the data itself starts from memory location (XXXX+4)H. Store the no of negative, zero &
positive elements in memory location starting from XXXXH.
SOLUTION
ORG 2040H
SUB A
MOV C, A
MOV D, A
MOV E, A
LXI H, 2003H
MOV B, M
START: INX H
MOV A, M
ADI 00H
JZ FZERO
JP FPOSE
INR E
REPET: DCR B
JNZ START
LXI H, 2000H
MOV M, D
INX H
MOV M, E
RST 5
FZER0: INR C

JMP
REPET
INR D
JNP
REPET
END

ORG 2003 H
.DB 05H;
.DB 00H,02H,2H,0FFH,-3H; END

RESULT- CONTENTS OF REGISTERS AFFECTED

C: 02
D: 06
E: 02
F: 54 H
I: 07H
H: 20H
L: 02 H
MEMORY CONTENT: 2020H:01H 2021H: 01H 2022H:03H

5. Write an ALP for 8085 to find the checksum of a series of numbers where the
length of the series is in memory location (XXXX+1)H and the numbers start from
memory location (XXXX+2)H. Store the checksum in memory location say XXXXH.
SOLUTION
ORG 0000H
LXI H,2501H
MOV C,M INX H
MOV A,M DCR
C
START: INX H XRA M
DCR C JNZ
START STA
2500H HLT
ORG 2501H
.DB 05H,58H,25H,0FFH,0D4H,62H;
RESULTCONTENTS OF REGISTERS AFFECTED:
A:34H
C:00H
FR:6EH
MEMORY CONTENT- 2500H-34H

6. Write an ALP for 8085 to find the number of 1s in an 8 bit data in memory location
say (XXXX+1)H. Store the number of 1s in memory location say XXXXH.
SOLUTION
ORG 0000H
LDA 1001H
MVI D,00H
MVI B,08H
REPET: RRC
MOV C,A
ANI 80H

NONE:

JZ NONE
INR D
MOV A,C
DCR B JNZ
REPET

MOV A,D;NO OF
ONES STA 1000H
HLT
ORG 1001H
.DB 55H
RESULT- CONTENTS OF REGISTERS AFFECTED:
A-04H B-00H C-55H D-04H
MEMORY CONTENT: 1000H-04H

7. Write an ALP for 8085 to find the unsigned largest/smallest number from a given
series of numbers. The length of the series is in memory location say (XXXX+1)H and
the numbers start from memory location (XXXX+2)H. Store the largest/smallest 8 bit
unsigned number in memory location XXXXH.
SOLUTION: LARGEST NOORG 0000H
LXI
H,2701H
MOV C,M
INX H MOV
A,M DCR C
START: INX H
CMP M
JC SKIP,(GREATEST NO) OR JNC SKIP,(SMALLEST
NO) BACK: DCR C
JNZ START
STA
2700H HLT
ORG 2701H
.DB 05H,45H,62H,17H,45H,00H
SKIP: MOV A,M

JMP BACK
RESULT
CONTENTS OF REGISTERS AFFECTED:
A-62H(LARGEST)/00H(SMALLEST)
HL-2706H
MEMORY CONTENT: 2700H-62H

EXPERIMENT NO . 2
Disassemble the assembly language instruction codes for the following three programs for 8085
microprocessor and generate/write the mnemonics i.e. the assembly language programs for 8085
microprocessor. Then identify the functions of each of these programs. From the known T- sates of
each mnemonics (for this you may consult the opcode list containing the T-states for each
instruction for 8085 microprocessor) find the total execution time for the following three programs
assuming the clock frequency of 8085 microprocessor to be equal to 3 MHz. Hand assemble the
above three programs in the respective microprocessor kits provided to you and execute and verify
the results of the following three programs.

PROGRAM -1
PROGRAM-2
Memory Address
Instruction Code Memory Address Instruction Code Memory
Address
9000H
21H
9020H
21H
9040H
9001H
45H
9021H
01H
9041H
9002H
23H
9022H
90H
9042H
9003H
EBH
9023H
46H
9043H
9004H
21H
9024H
97H
9044H
9005H
67H
9025H
23H
9045H
9006H
45H
9026H
AEH
9046H
9007H
19H
9027H
05H
9047H
9008H
22H
9028H
C2H
9048H
9009H
10H
9029H
25H
9049H
900AH
90H
902AH
90H
904AH
900BH
CFH
902BH
32H
902CH
50H
902DH
90H
902EH
CFH
SOLUTION:
2.A)

PROGRAM-3
Instruction Code
AFH
3AH
00H
90H
47H
1FH
A8H
32H
01H
90H
CFH

ORG 0000H
LXI H,2345H
XCHG
LXI H,4567H
DAD D
SHLD 9010H;
HLT
This program adds 2 16bit numbers 2345h and 4567h and stores the value in 9010 n 9011h. It takes 55T states
MEMORY CONTENT- 9010H-ACH 9011H-68H

2.B)

ORG 0000H
CXI H, 9001H
MOV B, M
SUB A
START: INX H
XRA M
DCR B

JNZ START
STA 9050H
HLT
ORG 9001H
.DB 05H
.DB 25H, 45H, 65H, 75H, 85H

2.C)

ORG 0000H
XRA A
LDA 9000H
MOV B,A
RAR
XRA B
STA 9000H
HLT
ORG 9000H
DB 54H

This program is a GRAY TO BINARY conversion programs which converts the value stored in 9000h i.e. 54h to its gray
code 7eh and stores it back to 9000h

EXPERIMENT NO. 3
Assignments using 8085 Simulator Ide
1. Write an ALP for 8085 Microprocessor to transfer a block of 05 data from memory
location 3000H to 4000H.
SOLUTION
ORG 0000H
LXI H,3000H
LXI D,4000H
MVI C,05H
START: MOV A,M
STAX D
INX H
INX D
DCR C JNZ
START HLT
ORG 3000H
.DB 10H,11H,12H,0FEH,34H
RESULT-

MEMORYCONTENTS

4000H-10H 4001H-11H 4002H-12H 4003H FEH 4004H-34H

2. Alp for 8085 to generate continuous square wave at sod pin of 8085
SOLUTION
ORG 0000H
START: MVI A,0C0H
SIM
CALL DELAY
MVI A,40H
SIM
CALL DELAY
JMP START
HLT
DELAY:LXI D,00FFH
DELAY1:DCX D
MOV A,D
ORA E
JNZ DELAY1
RET
END
RESULT-

3. Alp for 8085 to generate 5 cycles of square wave at sod pin of 8085

SOLUTION
ORG 0000H
MVI B,05H
START: MVI A,0C0H
SIM
CALL DELAY
MVI A,40H

SIM
CALL DELAY
DCR B
JNZ START
HLT
DELAY:LXI D,00ffH
DELAY1:DCX D
MOV A,D
ORA E
JNZ DELAY1
RET
RESULT-

4. ALP for 8085 for converting 8-bit parallel data into serial output data at SOD pin using
SIM Instruction.
SOLUTION
ORG 0000H
MVI A,0AEH
MVI B,08H
LOOP: RRC
MOV C,A
ORI 40H
SIM
MOV A,C
DCR B
JNZ LOOP
HLT
RESULTHere use step by step rate simulation we will have serial output of the parallel data bitwise in SOD pin. This is a case of
parallel in serial out.

5. ALP for 8085 for converting Serial input data applied at SID input of 8085
microprocessor and converting it into parallel output data using RIM Instruction data
into serial output data at SOD pin using SIM Instruction.
SOLUTION
ORG 0000H
MVI B,08H
MVI C,00H
LOOP: RIM
ANI 80H
ORA C
MOV C,A
DCR B
JZ ENDL
RRC
MOV C,A
JMP LOOP
ENDL: MOV A,C
STA 0020H
HLT
RESULTThis is a program of serial in parallal out where the user provides bitwise input via SID pin (lsb first) 8 times and the finally
the 8bit value is stored in 2000h.
Via SID pin 1(L.S.B)-0-0-1-0-0-0-1(M.S.B.).
THUS 89H WILL BE STORED IN 0020H

6. Write an ALP for 8085 Microprocessor to read 10 successive data from input port of
address 20H and store this 10 data in memory location starting from 0040H. Use
8085 Simulator IDE.
SOLUTION:
ORG 0000H
MVI B,0AH
LXI H,0040H
LOOP: IN 20H
MOV M,A
INX H
DCR B
JNZ LOOP
HLT
RESULTVIA INPUT PORT HAVING ADDRESS 20H01h,02,03h,04h,05h,06h,07h,08h,09h,10h MEMORY CONTENT:
0040H onwards:01h,02,03h,04h,05h,06h,07h,08h,09h,10h

7. Write an ALP for 8085 microprocessor to display a message WELCOME TO ECE


DEPARTMENT successively at the output port of address 20H. The Message characters are
stored in memory location starting from 0041H, where the count of message is stored in memory
location 0040H. (Verify the above program by executing it in 8085 Simulator IDE).
SOLUTION:
ORG 0000H
MVI C,05H
LOOP1: LXI H,0040H
MOV B,M
LOOP: INX H
MOV A,M
OUT 20H
DCR B JNZ
LOOP DCR
C JNZ
LOOP1
HLT
ORG 0040H
.DB 26 ORG
0041H

.DB 'WELCOME'
.DB 20H
.DB 'TO'
.DB 20H
.DB 'ECE'
.DB 20H
.DB 'DEPARTMENT'
.DB 0DH
RESULT-

8. ALP for 8085 to convert the successive 8-bit binary codes (using a binary to Gray
Code conversion subroutine), where the count of binary numbers is in memory location
2000h and the binary code starts from memory locations 2001H onwards. Store the gray
equivalent of the binary codes starting from memory location 3000h onwards.
SOLUTION:
ORG 0000H
LXI H,2000H
LXI D,3000H
MOV C,M
LOOP: INX H
XRA A
MOV A,M
MOV B,A
RAR XRA
B STAX D
INX D
DCR C
JNZ
LOOP
HLT
ORG 2000H
.DB 05H
.DB 45H,28H,0FEH,39H,75H
RESULTMEMORY CONTENTS:
2001H(ONWARDS): 45H 28H FEH 39H 75H
3000H(ONWARDS): 67H 3CH 81H 25H 4FH

9. ALP for 8085 to convert the successive 8-bit Gray codes (using a Gray to Binary Code
Conversion subroutine), where the count of Gray code numbers is in memory location
2000h and the Gray code starts from memory locations 2001H onwards. Store the
binary equivalent of the Gray codes starting from memory location 3000h onwards.
SOLUTION:
ORG 0000H
LXI SP,9000H
LXI H,2000H
MOV C,M
LXI D,3000H
LOOP1: INX H
MOV B,M
MOV A,B
ANI 80H
CALL STORE
STAX D
INX D
DCR C JNZ
LOOP1
HLT
STORE: PUSH D
MVI D,07H
CALL1: RAR
XRA B
DCR D
JNZ CALL1
POP D
RET
ORG 2000H
.DB 05H
.DB 67H,3CH,81H,25H,4FH;
RESULTMEMORY CONTENTS:
2001H(ONWARDS): 67H 3CH 81H 25H 4FH
3000H(ONWARDS): 45H 28H FEH 39H 75H

10. ALP for 8085 Microprocessor to find the factorial of any number between 0 to 8.
SOLUTION:
ORG 0000H
LDA 8000H
CPI 02H JC
RESULT
MOV E,A
MVI D,00H
DCR A
MOV C,A
CALL FCTRL
XCHG
JMP FNRSLT
RESULT:LXI H,0001H
FNRSLT:SHLD 0080H
HLT
ORG 4000H
FCTRL: LXI H,0000H
MOV B,C
LOOP: DAD D
DCR B
JNZ LOOP
XCHG
DCR C

CNZ FCTRL
RET

ORG 8000H
.DB 08H
RESULTREGISTER PAIR CONTENT: HL=9D80H
MEMORY CONTENT: 0080H-80H

0081H-9DH

EXPERIMENT NO. 4
Assignments using 8085 Simulator Ide
1. Write a main program in AL for 8085 microprocessor which will find the addition of 1st 200 natural number
and store the result in memory location say 8000H and 8001H respectively. While executing this main
program activate different hardware interrupt successively by say clicking RST5.5, RST6.5, RST7.5 and
TRAP icon in 8085 simulator IDE. Write the ISS for the above four hardware interrupts of 8085 which will
perform the following functions: a) Write ISS for RST5.5 from memory location 2000H which, will input a
byte from input port of address 20H and store it in memory location say 6000H. b) Write ISS for RST 6.5
from memory location 3000H which, will output a data stored in memory location 6001H and to an output
port of address 30H. c) Write ISS for RST 7.5 from memory location 4000H which, will find the decimal
addition of two numbers 63H and 29H stored in memory location 7002H and 7003H respectively and store
the decimal sum in memory location 7000H. d) Write ISS for TRAP from memory location 5000H which,
will find the decimal subtraction of 29H stored in memory location 7003H from 63H stored in memory
location 7002H. Store the decimal subtraction in memory location 7001H.

SOLUTION:
ORG 0000H
EI
LXI SP,9000H
LXI H,0000H
LXI D,0001H
MVI C,0C8H
START: DAD D
INX D
DCR C
JNZ START
SHLD 8000H
HLT
ORG 0024H
JMP 5000H
ORG 002CH
JMP 2000H
ORG 0034H
JMP 3000H
ORG 003CH
JMP 4000H
ORG 2000H
EI
PUSH PSW
PUSH B
PUSH D
PUSH H
IN 20H
STA 6000H
POP H
POP D
POP B
POP PSW
RET
ORG 3000H
EI
PUSH B
PUSH D
PUSH H

PUSH PSW
LDA 6000H
OUT 30H
POP PSW
POP H
POP D
POP B RET

ORG 6000H
.DB 67H
ORG
4000H EI
PUSH B
PUSH D
PUSH H
PUSH PSW
LXI H,7002H
MOV A,M
INX H
ADD M
DAA
STA 7000H
POP PSW
POP H
POP D
POP B
RET

ORG 5000H
PUSH B
PUSH D
PUSH H
PUSH PSW
LXI H,7002H
MOV B,M
INX H

MVI A,99H
SUB M
INR A
ADD B
DAA
STA 7001H
POP
PSW
POP H
POP D
POP B EI
RET
ORG 7002H
.DB 65H,29H

RESULTA.

B.

C.

D.

2. Write an Alp for 8085 to find the four byte decimal addition of 23456789 stored in memory location
starting from 0300H with 36871289 stored in memory location starting from memory location
04000H. Store the decimal sum in memory location starting from 0500H.
SOLUTION:
ORG 0000h

LXI H,0800H
LXI D,0810H
LXI B,0820H
MVI A,04H
STA 07F0H
SUB A
START: POP PSW
LDAX D
ADC M
DAA STAX
B INX H
INX D INX
B PUSH
PSW LDA
07F0H
DCR A
STA
07F0H
JNZ START
ANI 80H; TO STORE CARRY IF
ANY STAX B
HLT
ORG 0800H
.DB 89H,67H,45H,23H
ORG 0810H

.DB 89H,12H,87H,36H
RESULT:
MEMORY CONTENTS :
0820H ONWARDS: 78H 80H 32H 60H 00H

3. Write an Alp for 8085 to find the four byte decimal subtraction of 23456789 stored in memory location
starting from 0300H from 78871289 stored in memory location starting from memory location
04000H. Store the decimal difference in memory location starting from 0500H.

SOLUTION:
ORG 0000h
LXI H,0800H
LXI D,0810H
LXI B,0820H
MVI A,04H
STA 07F0H
SUB A
START: POP PSW
LDAX D
CMP M
JNC SKIP
INX H
INR M
DCX H
SKIP: LDAX D
STA 07F1H
MVI A,99H
SUB M
INR A
PUSH D
MOV E,A
LDA 07F1H
ADD E
DAA
POP D
STAX B
INX H
INX D
INX B
PUSH PSW
LDA 07F0H
DCR A
STA 07F0H
JNZ START
HLT
ORG 0800H
.DB 89H,67H,45H,23H
ORG 0810H

.DB 89H,12H,87H,78H

RESULT:
MEMORY CONTENTS :
0820H ONWARDS: 74H 38H 86H 70H

4. Write an ALP for 8085 to find the unsigned binary multiplication of 16-bit multiplicand 2678H with 8bit multiplier 56H giving a 24 bit product. Store this 24 bit product in memory location starting from
memory location 3000H onwards.
SOLUTION:
ORG 0000H
SUB A
MOV C,A
LXI H,0000h
LXI D,2678h
MVI B,56h
START: DAD D
JNC DONE
INR C
DONE: DCR B
JNZ START
SHLD 0050h
MOV A,C
STA 0052h
HLT
RESULT:
RESISTERS CONTENT:
C-0CH H-ECH
L-50H
MEMORY CONTENTS:
0050H ONWARDS- 50H ECH 0CH

5. Write an ALP for 8085 microprocessor to divide 8-bit unsigned number (Dividend) FAH by an 8-bit
unsigned number(Divisor) 13H to produce an 8-bit unsigned quotient and 8-bit unsigned remainder
using repeated subtraction. Store this 8-bit unsigned quotient and 8-bit unsigned remainder in memory
location 2000H and 2001H respectively.
SOLUTION:
ORG 0000H
MVI A,0FAH
MVI C,13H
MVI D,00H;quotient
MVI E,00H;remainder
START:
CMP C
JC LEVEL
SUB C
INR D
JMP START
LEVEL: MOV E,A
STA 2001H
MOV A,D
STA 2000H
HLT
RESULT:
REGISTERS: D: 0DH
E:03H
MEMORY CONTENTS:
2000H-0DH 2001H-03H

6. Write an ALP for 8085 microprocessor to search a data pattern say 0DH (ASCII code of carriage return
character) from 10, 8-bit data, where the count of data is stored in memory location say 2001H and 8-bit
data stored in memory location starting from 2002H, which are say 23H, 34H, 0A0H, 0DH, 45H, 65H, 93H,
0DH, 12H and 0DH. Store the no of matches in memory location 2000H.
SOLUTION:
ORG 0000H
LXI H,2001H
MOV C,M
MVI D,00H
MVI A,0DH; NUMBER TO BE
SEARCHED INX H
START: CMP M
JNZ SKIP
INR D
SKIP: INX H DCR
C JNZ
START
MOV A,D
STA 2000H
HLT
ORG 2001H
.DB 0AH,23H,34H,0A0H,0DH,45H,65H,93H,0DH,12H,0DH
RESULTREGISTER D-03H
MEMORY 2000H-03H

7. Write an ALP for 8085 microprocessor to sort 10 unsigned 8-bit data in Ascending/Descending order in
memory, where the count of data is stored in memory location say 2000H and 8-bit unsigned data are
stored in memory location 2001H onwards, which are say 0A3H, 34H, 0A0H, CDH, 45H, 65H, 93H ,06H,
12H and 0FH. Store the sorted number in the same memory locations where they reside.
SOLUTION:
DESCENDING ORDER SORTING
ORG 0000H
START: LDA 0060H

DCR A STA
0060H JZ
ENDSTR
MOV B,A
LXI H,0080H
MOV E,L
MOV D,H
INX H
SORT: LDAX D
CMP M JZ
SKIP JNC
SKIP
MOV C,M
MOV M,A
MOV A,C
STAX D
SKIP: INX H INX
D DCR B
JNZ
SORT
JMP START
ENDSTR: HLT

ORG 0060H
.DB 04H
ORG 0080H
.ORG 0000H
START: LDA 0060H

DCR A STA
0060H JZ
ENDSTR
MOV B,A
LXI H,0080H
MOV E,L
MOV D,H
INX H
SORT: LDAX D
CMP M JZ
SKIP JNC
SKIP
MOV C,M
MOV M,A
MOV A,C
STAX D
SKIP: INX H INX
D DCR B
JNZ
SORT
JMP START
ENDSTR: HLT

ORG 0060H
.DB 0AH
ORG 0080H

.DB 0A3H,34H,0A0H,0CDH,45H,65H,93H,06H,12H,0FH

RESULT- 0080H ONWARDS: CDH A3H A0H 93H 65H 45H 34H 0FH 12H 06H

EXPERIMENT NO. 06
1. Write an ALP for 8051 to find the decimal addition and subtraction of two numbers 53
and 29 i.e. find (53)10 + (29)10 and (53)10 (29)10
SOLUTION:
ADDITION
ORG 0000H;
MOV A,#53H;
ADD A,#29H;
DA A;
MOV 30H,A;
NOP;
RESULT
A- 82H
IRAM:30H-82H
SOLUTION:
B)SUBSTRACTION
ORG 0000H;
MOV A,#99H;
MOV R1,#53H;
MOV R2,#29H;
CLR C;
SUBB A,R2;
INC A;
ADD A,R1;
DA A;
MOV 30H,A;
NOP

RESULTA- 24H

IRAM:30H-82H

2. Write an ALP for 8051 to find the sum of first 200 natural numbers.
SOLUTION:
ORG 0000H;
MOV R1,#0C8H;
MOV R2,#01H;
CLR A;
MOV R3,A;
START: ADD A,R2;
JNC DONE;
INC R3;
DONE: INC R2;
DJNZ R1,START;
MOV 30H,A;
MOV 31H,R3;
NOP
RESULTA-84H
R3-4EH
IRAM : 30H: 84H 31H-4EH

R2-C9H

3. Write an ALP for 8085 to find the checksum of five numbers stored in internal RAM
from memory locations 22h and the count of data is stored in internal ram location
21h. Store the checksum in internal memory location 20h.
SOLUTION:
ORG 0000H;
MOV R1,21H;
MOV R0,#22H;
CLR A;
START: XRL A,@R0;
INC R0;
DJNZ R1,START;
MOV 20H,A;
NOP;
RESULTA-98H
IRAM : 20H(ONWARDS): 05H

4. Write an ALP for 8051 to output four successive datas 45h, 55h, 0f8h and 23h to the
four output ports p0, p1, p2 and p3 respectively and read the same data from the

respective ports and store them in registers r0, r1, r2 and r3 of register bank 3.
SOLUTION:
ORG 0000H;
MOV P0,#45H;
MOV P1,#55H;
MOV P2,#0F8H;
MOV P3,#23H;
SETB PSW.3;
SETB PSW.4;
MOV R0,P0;
MOV R1,P1;
MOV R2,P2;
MOV R3,P3;
NOP
RESULTREGISTERS: R0:45H R1:55H
IRAM:18H(ONWARDS): 45H
55H

R2:F8H
F8H
23H

R3:23H

5. Write an ALP for 8051 to load first 32 natural numbers in decimal in RAM location
starting from 20H.
SOLUTION:
ORG 0000H;
MOV R1,#20H; LOAD COUNT (32)10=20H
MOV R2,#1H;
MOV R0,#20H; POINT TO START ADDRESS OF RAM;
CLR A;
START: ADD A,R2;
DA A;
MOV @R0,A;
INC R0;
DJNZ R1,START;
NOP
RESULTIRAM: 20H(ONWARDS)-01 02 03 04 05 06 07 08 09
10 11 12 13 14 15 16 17
18 19 20 21 22 23 24 25
26 27 28 29 30 31 32

6. ALP for 8051 to multiply and divide two nos i.e. find (83)10(12)10 and (183)10(12)10.
SOLUTION:
ORG 0000H;
MOV A,#0B7H;
MOV B,#0CH;
DIV AB;
MOV 30H,A;QUOTIENT

MOV 31H,B;REMAINDER
NOP
RESULTIRAM- 30H(ONWARDS)-0FH

03H

7. Write an ALP for 8051 to move block of six data stored in memory location from 20H
(internal RAM) to 25H (internal RAM) to 40H to 45h of internal RAM.
SOLUTION:
ORG 0000H;
MOV R0,#20H;
MOV R1,#40H;
MOV R2,#06H; COUNT FOR SIX NUMBERS
START: MOV A,@R0;
MOV @R1,A;
INC R0;
INC R1;
DJNZ R2,START;

RESULTIRAM- 20H(ONWARDS)- 06H


40H(ONWARDS)- 06H 05H

05H
04H

04H
03H

03H
02H

02H 01H
01H

8. a) Write an ALP for 8051 to generate continuous square wave at all the port pins of Port-1. b)
Write an ALP for 8051 to generate 10 cycles of square wave at all the port pins of Port-1
SOLUTION:
8.A)
ORG 0000H;
START: MOV P1,#0FFH;

ACALL DELAY;
MOV P1,#00H;
ACALL DELAY;
SJMP START;
ORG 0070H;
DELAY:
MOV R1,#0FFH;
HERE: DJNZ R1,HERE;
RET;
NOP
8.B)
ORG 0000H;
MOV A,#0AH;
START: MOV P1,#0FFH;

ACALL DELAY;
MOV P1,#00H;
ACALL DELAY;

DJNZ A,START
NOP
ORG 0070H;
DELAY:MOV R1,#ffH;
HERE: DJNZ R1,
HERE: RET

9. Write an ALP for 8051 to load 35H and 67H in A reg and B register respectively, load
SP with 20h. PUSH the contents of A and B in the stack. Now clear the contents of A
and B, then POP the contents of stack into A reg and B reg respectively to retrieve
the same previous contents of A reg and B reg.
SOLUTION:
ORG 0000H;
MOV A,#35H;
MOV B,#67H;
MOV SP,#20H;
PUSH A;
PUSH B;
CLR A;
MOV B,#00H;
POP B;
POP A;
NOP

10. Write an ALP for 8051 to load A with 5fh, set CF to 1, copy CF bit to bit-7 of A reg.
Now perform AND operation between bit-7 of Areg with CF bit. Finally perform OR
operation between CF bit and complement of bit-1 of A Register. Check the results of
the above program by executing the above program in single step instruction
execution mode by observing the different results in Registers and Control Register
after execution of each instruction.
SOLUTION:
ORG 0000H;
MOV A,#5FH;
SETB C;
MOV A.7,PSW.7;
ANL C,A.7;
ORL C,A.1;
NOP
END

11. Write an ALP for 8051 microcontroller to transfer 5 successive data stored in internal
memory location starting from 20H onwards to external memory locations starting from
0030H onwards.
SOLUTION:
ORG 0000H;
MOV R0,#20H;POINTER FOR INTERNAL RAM
MOV R1,#05H; COUNT OF DATA IS 5
MOV DPTR,#0030H;
START: MOV A,@R0;
MOVX @DPTR,A;
INC DPTR;
INC R0;
DJNZ R1,START;
NOP;
RESULT:
IRAM 20H(ONWARDS)- 05H 67H
11H
XDATA MEM 0030H(ONWARDS)-05H 67H

2DH
11H

FFH
2DH FFH

12. Write ALP an for 8051 microcontroller to transfer 5 successive data stored in external
memory location starting from 2000H onwards to internal memory locations starting
from 30H onwards.
SOLUTION:
ORG 0000H;
MOV DPTR,#2000H;
MOV R0,#30H;
MOV R1,#05H;
START: MOVX A,@DPTR;
MOV @R0,A;
INC DPTR;
INC R0;
DJNZ R1,START;
NOP;
ORG 2000H;
.DB 32H,34H,54H,36H;
.DB 0FFH;
RESULT:
IRAM 30H(ONWARDS)-32 34 54 36 FF

13. Write ALP an for 8051 microcontroller to transfer 5 successive data stored in external
memory location starting from say 0020H onwards to external memory locations
starting from say 3000H onwards.
SOLUTION:
ORG 0000H;
MOV R0,#05H; LET COUNT OF DATA BE 5
MOV R4,#00H;SAVING FIRST POINTER DPTR HIGH AND LOW IN R4,R5 RESPECTIVELY
MOV R5,#40H;
MOV R6,#30H;SAVING SECOND POINTER DPTR HIGH AND LOW IN R6,R7 RESPECTIVELY
MOV R7,#00H;
START: MOV DPH,R4;RETRIEVING FIRST POINTER DPTR IN
R4,R5 MOV DPL,R5;
MOVX A,@DPTR;
INC DPTR;
MOV R4,DPH;AFTER INCREMENTING SAVING FIRST POINTER IN CORRESPONDING
REGISTERS MOV R5,DPL;
MOV DPH,R6;RETRIEVING SECOND POINTER DPTR IN
R6,R7 MOV DPL,R7;
MOVX @DPTR ,A;
INC DPTR;
MOV R6,DPH;AFTER INCREMENTING SAVING SECOND POINTER IN CORRESPONDING
REGISTERS MOV R7,DPL;
DJNZ
R0,START; NOP
ORG 0040H;
DB 43H,56H,28H,32H,98H
RESULT:
XDATA MEM 0040H(ONWARDS)-43 56 28 32 98
XDATA MEM3000H(ONWARDS)-43 56 28 32 98

EXPERIMENT NO. 7
1.a) Draw and simulate a schematic using AT89C51 to generate continuous square wave at all port pins of Port-1
of 8051 microcontroller and display it on CRO. b) Draw and simulate a schematic using AT89C51 to generate
continuous square wave at p1.3 port pins of Port-1 of 8051 microcontroller and display it on CRO

SOLUTION:
HEX LINKER PROGRAM:
(a).
ORG 0000H
LJMP INITIAL
ORG 001BH
CPL P2.5
RETI
ORG 0050H
INITIAL: MOV TMOD,#20H
MOV TH1,#1AH
MOV IE,#88H
SETB TR1;
START: MOV R1, #00H
MOV R2,#0AH
CLR A
NEXT: ADD A,R1
DA A MOV
P1,A
ACALL DELAY
ACALL DELAY
INC A
DJNZ R2,NEXT
SJMP START
DELAY: MOV R3, 0FFH
AGAIN: MOV R4,0FFH
NEXT1: DJNZ R4,NEXT1
DJNZ
R3,AGAIN RET
END

(b).

org 0000h
start: cpl p1.3
acall delay
sjmp start
org 0070h
delay: mov r1,#0ffh
delay1: mov r2,#0ffh
here: djnz r2,here
djnz r1,delay1

nop

SCHEMATIC:

C4

RXD
TXD

33p

U1
19

X1

C2

CRYSTAL

33p

18

XTAL1

XTAL2

RST

BAT1
1.5V
29
30

PSEN

P0.0/AD0
P0.1/AD1
P0.2/AD2
P0.3/AD3
P0.4/AD4
P0.5/AD5
P0.6/AD6
P0.7/AD7
P2.0/A8
P2.1/A9
P2.2/A10
P2.3/A11
P2.4/A12
P2.5/A13
P2.6/A14

8k2

37

36
35
34
33
32
21
22

23
24
25
26
27
28

ALE
EA

1
2
3
4
5
6
7

P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6

P3.0/RXD 10
P3.1/TXD 11
P3.2/INT0 12
P3.3/INT1 13
P3.4/T0 14
P3.5/T1 15
P3.6/WR 16

8 P1.7

P3.7/RD 17

P2.7/A15

R1

38

31

C3
10u

39

AT89C51

RTS
CTS

2. Draw and simulate a schematic using AT89C51 to send data A and U continuously on the virtual
terminal and receive it serially repeatedly in the accumulator and then display the same on the two
hex display device using output port p1 of 8051/89C51 microcontroller.
SOLUTION:

HEX LINKER PROGRAM:


org 0000h;
mov tmod, #20h;
mov scon, #50h;
mov th1, #0fdh;
setb tr1;
start: mov a, #'A';
acall trans;
mov a,#'U';
acall trans;
mov a, #20h;
acall trans;
mov a, #20h;
acall trans;
sjmp start

trans: mov sbuf,


a; here: jnb
ti,here; clr ti;
recv: jnb ri, recv;
mov a,sbuf
mov p1,a
clr ri
acall delay
acall delay

delay: mov r1,#0ffh;


next1: mov r2,#0ffh;
next2: djnz r2,next2
djnz
r1,next1; ret;
end

SCHEMATIC:

3. Draw and simulate a schematic using AT89C51 to generate square wave at P1.4 pin of Port-1.
Generate time delay by programming timer 0 in Mode-1 .
SOLUTION:
HEX LINKER PROGRAM:
ORG 0000H
START: MOV P1,#0FFH
ACALL DELAY
MOV P1,#00H
ACALL DELAY
SJMP START
DELAY: MOV R1,#0FFH
DELAY1:MOV R2,#0FFH
HERE: DJNZ R2,HERE
DJNZ R1,DELAY1
RET
END
SCHEMATIC:

4. Draw and simulate a schematic using AT89C51 to realize a a) Mod-9 decimal counter (Initial Count 1
and final count 9) and b) Mod-99 decimal counter (Initial count 1 and final count 99).
SOLUTION:
(a).
org 0000h
start: mov r0,#01h
mov r1,#09h
clr a
next: mov a,r0
da a mov
p1,a
acall delay
acall delay
inc r0
djnz r1,next
sjmp start
org 0050h

delay: mov r2,#01h


again: mov r3,#0fh
here: djnz r3,here
djnz r2,again
ret
end
(b).
ORG 0000H;
start: MOV R1,#63H;
MOV R2,#1H;
CLR A;
next:
ADD A,R2;
DA A; MOV
P1,A;
ACALL DELAY;
DJNZ R1,next;
SJMP start;
org 0050h

DELAY:MOV R3,#0FFH;
again: MOV R4,#0FFH;
here: DJNZ R4,here;
DJNZ
R3,again; RET;

5. Draw and simulate a schematic to transmit the message Welcome to ECE Department repeatedly
on a virtual terminal.
SOLUTION:
ORG 0000H
MOV TMOD,#20H
MOV SCON,#40H
MOV TH1,#0FDH
SETB TR1
MOV R5,#05h
START: MOV R1,#1AH
MOV DPTR,#0080H
NEXT: CLR A
MOVC A,@A+DPTR
ACALL TRANS
INC DPTR
DJNZ R1,NEXT
DJNZ R5,START
LJMP $
TRANS: MOV SBUF,A
HERE: JNB TI,HERE
CLR TI
RET
ORG 0080H
DB 'WELCOME TO ECE DEPARTMENT'
DB 0DH
END

SCHEMATIC :

C4
33p

U1
19

X1

C2

CRYSTAL

18

XTAL1

XTAL2

33p
9

RST

BAT1
29
PSEN
30
ALE
31
EA

P2.0/A8
P2.1/A9
P2.2/A10
P2.3/A11
P2.4/A12
P2.5/A13
P2.6/A14
P2.7/A15

1
P1.0
2
P1.1
3
P1.2
4
P1.3
5 P1.4
6
P1.5
7
P1.6
8
P1.7

P3.0/RXD
P3.1/TXD
P3.2/INT0
P3.3/INT1
P3.4/T0
P3.5/T1
P3.6/WR
P3.7/RD

1.5V

C3
10u

R1
8k2

P0.0/AD0
P0.1/AD1
P0.2/AD2
P0.3/AD3
P0.4/AD4
P0.5/AD5
P0.6/AD6
P0.7/AD7

AT89C51

39
38
37
36

35
34
33
32
21
22

23
24
25
26
27
28
10
11
12
13
14

15

16
17

A
B
C
D

8.a) Draw and simulate a schematic which uses an ADC0808 chip to convert different analog input voltage applied
at IN input of ADC0808 chip and display the digital equivalent of analog input in two seven segment hex
0

display device.
b) Draw and simulate a schematic which interface an ADC0808 chip with AT89C51 microcontroller to convert
different analog input voltage applied at IN input of ADC0808 chip through a Sample and Hold circuit and
0

display successively the digital equivalent of different analog input voltages in two seven segment
hex display device.
SOLUTION:
(A).
HEX LINKER PROGRAM:
ORG 0000H
mov P2,#0FFH
SETB P3.0
CLR P3.0
SETB P3.7
AGAIN: JNB P3.7,AGAIN;
SETB P3.1
MOV A,P2
MOV P1,A;
LJMP $
END

SCHEMATIC:

(B).

Problem No::-8b
Schematics to show A/D conversion using 8051 microcontroller
U1
19

XTAL1

C1
18

XTAL2

33p

X1
C2

9 RST

CRYSTAL

33p

29
PSEN
30
ALE
31
EA

BAT1

U2
P0.0/AD0
P0.1/AD1
P0.2/AD2
P0.3/AD3
P0.4/AD4
P0.5/AD5
P0.6/AD6
P0.7/AD7

100u

8k2

37

28

36
35
34
33

1
2
3
4

32

21
22
23
24
25
26
27

25
24
23
22
12
16

IN0
IN1
IN2
IN3
IN4
IN5
IN6
IN7

10

CLOCK
6
START
7
EOC

21

OUT1
20
OUT2
OUT3 19
18

ADD A
ADD B
ADD C
ALE
VREF(+)
VREF(-)

OUT4 8
OUT5

15

OUT6
14
OUT7
17
OUT8

OE

ADC0808
1 P1.0
2
P1.1
3 P1.2
4 P1.3
5 P1.4
6
P1.5
7
P1.6
8
P1.7
AT89C51
DBG_TRACE=1

R1

26
27

P2.0/A8
P2.1/A9
P2.2/A10
P2.3/A11
P2.4/A12
P2.5/A13
P2.6/A14
P2.7/A15 28

5.0V

C4

39
38

P3.0/RXD
P3.1/TXD
P3.2/INT0
P3.3/INT1
P3.4/T0
P3.5/T1
P3.6/WR
P3.7/RD

10
11
12
13
14
15

16
17

BAT3

BAT4

5.0V

5.0V

BAT2
2.00v

U2(ALE)

10. Draw and Simulate a Schematics showing A/D conversion of input Sine wave and outputting the
ADC output to DAC to reproduce the same sine wave using 8051 microcontroller in Proteus.

11. Draw and Simulate a Schematic using 8051 Microcontroller to use an external interrupt input at INTO
pin of microcontroller which when present will make an LED on connected at P1.0 pin port pin for
some time when interrupt is present at INTO pin of 8051 Microcontroller. This will be done by
executing an ISS for INT) located at 0003h.
SOLUTION:

13. Draw and simulate a Schematic using 8051 Microcontroller in Proteus to Interface LM044L LCD (a
4-line LCD Display) device and program the 8051 microcontroller to display welcome in the fourth
line of the LCD display from extreme left.
SOLUTION:
HEX LINKER PROGRAM:
ORG 0000H;
MOV A,#38H
ACALL WRTCOM
ACALL DELAY
MOV A, #0EH
ACALL WRTCOM
ACALL DELAY
MOV A,#01H
ACALL WRTCOM
ACALL DELAY
MOV A,#06H
ACALL WRTCOM
ACALL DELAY
MOV A, #86H;
ACALL WRTCOM
ACALL DELAY
MOV A, #'W'
ACALL DISPDATA
ACALL DELAY
MOV A, #'E'
ACALL DISPDATA
ACALL DELAY
MOV A, #'L'
ACALL DISPDATA
ACALL DELAY
MOV A, #'C'
ACALL DISPDATA
ACALL DELAY
MOV A, #'O'
ACALL DISPDATA
ACALL DELAY
MOV A, #'M'
ACALL DISPDATA
ACALL DELAY
MOV A, #'E'
ACALL DISPDATA
ACALL DELAY
AGAIN: SJMP AGAIN
WRTCOM: MOV P1,A
CLR P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET
DISPDATA: MOV P1,A
SETB P2.0
CLR P2.1

SETB P2.2
ACALL DELAY
CLR P2.2
RET
DELAY: MOV R3,#60H
HERE1: MOV R4, #0FFH
HERE2: DJNZ R4, HERE2
DJNZ R3, HERE1
RET
END

SCHEMATIC:
LCD1
LM044L

BAT2
RV1
5V

33p

U1
19

X1

C2

CRYSTAL

18

XTAL1

XTAL2

33p
9

RST

BAT1
1.5V
29
30
31

C3
10u

R1
8k2

1
2
3
4
5
6
7
8

PSEN
ALE
EA

P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
AT89C51

P0.0/AD0
P0.1/AD1
P0.2/AD2
P0.3/AD3
P0.4/AD4
P0.5/AD5
P0.6/AD6
P0.7/AD7
P2.0/A8
P2.1/A9
P2.2/A10
P2.3/A11
P2.4/A12
P2.5/A13
P2.6/A14
P2.7/A15
P3.0/RXD
P3.1/TXD
P3.2/INT0
P3.3/INT1
P3.4/T0
P3.5/T1
P3.6/WR
P3.7/RD

39
38
37
36
35
34
33
32
21
22
23
24
25
26
27
28
10
11
12
13
14
15
16
17

D0D1D 2D 3D4D 5D 6D7


1011121314

RSRWE
456

789

VSSVDDVEE

C4

123

POT

EXPERIMENT NO. 8
1. Write an ALP for 8086 microprocessor to load first 100 natural numbers in memory locations
starting from memory address 2000H onwards.

2. Write an ALP for 8086 microprocessor to load first 99 natural numbers in memory from memory
location 2000H onwards and then move these 99 natural numbers from memory locations 2000H
onwards to memory location 4000H onwards.

3. Write an ALP for 8086 P using DEBUG to translate the code of single digit decimal number say 5 to ASCII
in AL register using a decimal to ASCII code conversion data table whose start address is 4000h.

4. Write an Assembly Language Program for 8086 P which will read the upper case alphabet
inputted through the keyboard and convert it into the ASCII code of the lower case alphabet.

5. Write an Assembly Language Program for 8086 P which will read the lower case alphabet
inputted through the keyboard and convert it into the ASCII code of the upper case alphabet.

6. Write an ALP for 8086 P using DEBUG to multiply the two unsigned number (213) and (45)
10

10.

7. Write an ALP for 8086 P using DEBUG to multiply the two signed number (-98) and (45)
10

10.

8. Write an ALP for 8086 P using DEBUG to perform unsigned division of (2345) by (123) .
10

10

9. Write an ALP for 8086 P using DEBUG to perform signed division of (-1234) by (459) .
10

10

10. Write an ALP for 8086 Microprocessor to sort ten unsigned 8-bit numbers in memory in
Ascending/Descending order. Place the sorted numbers in the same memory locations where they
initially reside.

11. Write an ALP for 8086 Microprocessor to find the Maximum/Minimum of a given set of 8 bit-unsigned numbers
in memory. Store the Maximum and Minimum Number in any two consecutive memory locations.

12. Write an ALP for 8086 microprocessor to perform signed division of say 5 successive signed 8-bit dividend
stored in memory locations of the data segment by 5 successive signed divisors which are also stored in the
memory locations of the data segment. Store the five 8-bit signed quotient and 8-bit signed remainder in the
data segment from memory location 5000H onwards.

13. Write an ALP for 8086 to create a COM file, which will display a given set of character on the monitor screen.

21. Write a simple Macro Program say macro1.asm for 8086 MP which will perform signed multiplication of two
8-bit numbers stored in two successive memory locations of the data segment and include this Macro program
- macro1.asm using include statement in the main program and within the main program use the name of the
macro program to perform the functions defined in the macro. The main program also performs 16-bit
hexadecimal addition of two numbers 2387h and AB78h loaded in CX and DX register. Store the sum in CX
register in two consecutive memory locations 4000H and 4001H and store the 16-bit signed product obtained
by executing the macro in memory locations 4002H and 4003H respectively.

22. Write an ALP for 8086 to find unsigned multiplication by calling a subroutine.

You might also like