0% found this document useful (0 votes)
67 views

PROGRAM

This document contains instructions for experiments on programming microprocessors and microcontrollers. It includes examples of 8-bit and 16-bit arithmetic operations like addition, subtraction, multiplication, and division using microprocessor instructions and registers. It also describes interfacing experiments and applications using microprocessors and microcontrollers.

Uploaded by

samkous
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

PROGRAM

This document contains instructions for experiments on programming microprocessors and microcontrollers. It includes examples of 8-bit and 16-bit arithmetic operations like addition, subtraction, multiplication, and division using microprocessor instructions and registers. It also describes interfacing experiments and applications using microprocessors and microcontrollers.

Uploaded by

samkous
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

EE8681 MICROPROCESSORS AND MICROCONTROLLERS LAB LTPC

0042
OBJECTIVES:
 To provide training on programming of microprocessors and microcontrollers and
understand the interface requirements.
 To simulate various microprocessors and microcontrollers using KEIL or Equivalent
simulator.

LIST OF EXPERIMENTS

1 Simple arithmetic operations: addition / subtraction / multiplication / division.


2 Programming with control instructions:
(i) Ascending / Descending order, Maximum / Minimum of numbers.
(ii) Programs using Rotate instructions.
(iii) Hex / ASCII / BCD code conversions.
3 Interface Experiments: with 8085
(i) A/D Interfacing. & D/A Interfacing.
4 Traffic light controller.
5 I/O Port / Serial communication
6 Programming Practices with Simulators/Emulators/open source
7 Read a key ,interface display
8 Demonstration of basic instructions with 8051 Micro controller execution, including:
(i) Conditional jumps & looping
(ii) Calling subroutines.
9 Programming I/O Port and timer of 8051
(i) study on interface with A/D & D/A
(ii) Study on interface with DC & AC motors
10 Application hardware development using embedded processors.
1 Simple arithmetic operation: addition / subtraction / multiplication / division. (8 bit / 16 bit)
8 Bit Addition
Label Mnemonic Comments
ORG 8000H Origin
MVI C,00H 00 moved to c register
MVI A,30H 8 bit data moved to accumulator
ADI 20H 8 bit directly added and stored
JNC LOOP Jump if No carry to loop
INR C Increment c
LOOP: STA OFE73H Store the content of A in 0FE73H
MOV A,C Move c to accumulator
STA OFE74H Store the content of A in 0FE74H
CALL 056CH Call the subroutine
HLT Stop the program

8 Bit Subtraction
Label Mnemonic Comments
ORG 8000H Origin
MVI C,00H 00 moved to c register
MVI A,94H 8 bit data moved to accumulator
ADI 88H 8 bit directly subtract and stored
JNC LOOP Jump if No carry to loop
INR C Increment c
LOOP: STA OFE73H Store the content of A in 0FE73H
MOV A,C Move c to accumulator
STA OFE74H Store the content of A in 0FE74H
CALL 056CH Call the subroutine
HLT Stop the program
8 Bit Multiplication
Label Mnemonic Comments
ORG 8000H Origin
MVI C,00H 00 moved to c register
MVI A,00H 00 is moved to accumulator
MVI B,30H 8 bit data moved to register B
MVI D,60H 8 bit data moved to register D
LOOP1: ADD B Add content of B with accumulator.
JNC LOOP2 Jump if no carry to loop2
INR C Increment C
LOOP2: DCR D Decrement D
STA OFE73H Store content of A in OFE73H
MOV A,C Move C to accumulatore
STA OFE74H Store content of A in OFE74H
CALL 056CH Call the sub-routine
HLT Stop the program

8 Bit Division
Label Mnemonic Comments
ORG 8000H Assemble the program starting at 8000H
MVI C,00H 00 moved to C register with 00H
MVI A,49H Load register A with 8 bit data
MVI B,07H Load register B with 8 bit data
LOOP1: SUB B Subtract contents of B from accumulator
JC LOOP2 Jump no carry to Loop 2
INC C Increment register content C
JMP LOOP 1 Jump on Loop 1
LOOP2: ADD B Add content of B to Accumulator
STA OFE73H Store content of A to memory OFE73H
MOV A,C Move contents of C to Accumulator
STA OFE74H Store content of A to memory OFE74H
CALL 056CH Call the sub-routine at 056CH
HLT Stop the program

16 Bit Addition (without DAD)


Label Mnemonic Comments
ORG 8000H Assemble the program starting at 8000H
STC Set Carry
CMC Complement carry
MVI D,00H 00 is moved to D
LXI H,1624H Setup HL as pointer for source memory
LXI B,2416H Setup DE as destination pointer
MOV A,L Move L to Accumulator
ADD C Add content of C to A register
MOV L,A Move the content of register H to A
MOV A,H Move H to Accumulator
ADC B Jump no carry to loop
MOV H,A Move the contents of A to H register
JNC LOOP Jump if no carry to LOOP
INR D Increment D
LOOP: SHLD OFE73H Store H and L with register direct
MOV A,D Move D to accumulatore
STA OFE75H Store the content of A in OFE75H
CALL 0578H Call subroutine at 0578H
CALL 056CH Call subroutine at 056CH
HLT Stop the program
16 Bit Addition (with DAD)
Label Mnemonic Comments
ORG 8000H Assemble the program starting at 8000H
STC Set Carry
CMC Complement carry
MVI D,00H 00 is moved to D register
LXI H,4658H Setup HL as pointer for source memory
LXI B,4658H Setup DE as destination pointer
DAD B Add register pair to H and L register
JNC LOOP Jump if no carry to LOOP
INR D Increment D
LOOP: SHLD OFE73H Store H and L with register direct
MOV A,D Move D to accumulator
STA OFE75H Store the content of A is OFE75H
Call 0578H Call subroutine of 0578H
CALL 056CH Call subroutine of 056CH
HLT Stop the program

16 Bit Subtraction (without DSUB)


Label Mnemonic Comments
ORG 8000H Assemble the program starting at 8000H
STC Set Carry
CMC Complement carry
MVI D,00H 00 is moved to D
LXI H,4507H Setup HL as pointer for source memory
LXI B,3412H Setup BC as destination pointer
MOV A,L Move L to Accumulator
SUB C Subtract the contents of register C from contents of A to L
MOV L,A Move the content of register A to L
MOV A,H Move H to Accumulator
SUB B Subtract register from A with borrow
MOV H,A Move the contents of A to H register
JNC LOOP Jump if no carry to LOOP
INR D Increment D
LOOP: SHLD OFE73H Store H and L with register direct
MOV A,D Move D to accumulator
STA OFE75H Store the content of A in OFE75H
CALL 0578H Call subroutine at 0578H
CALL 056CH Call subroutine at 056CH
HLT Stop the program

16 Bit Subtraction (with DSUB)


Label Mnemonic Comments
ORG 8000H Assemble the program starting at 8000H
STC Set Carry
CMC Complement carry
MVI D,00H 00 is moved to D
LXI H,8879H Setup HL as pointer for source memory
LXI B,4586H Setup BC as destination pointer
DSUB B No operation in B
JNC LOOP Jump if no carry to LOOP
INR D Increment D
LOOP: SHLD OFE73H Store H and L with register direct
MOV A,D Move D to accumulator
STA OFE75H Store the content of A in OFE75H
CALL 0578H Call subroutine at 0578H
CALL 056CH Call subroutine at 056CH
HLT Stop the program
16 Bit Multiplication
Label Mnemonic Comments
ORG 8000H Assemble the program starting at 8000H
LXI D,0000H Load 0000H in D register pair HL
LXI H,0000H Load 0000H in register pair HL
LXI SP, 8598H Load 16 bit data in stack pointer register
LXI B, 5486H Load 16 bit data in register pair BC
LOOP1: DAD SP Add contents of stack pointer to HL register
JNC LOOP2 Jump on no carry to LOOP2
INX D Increment the content of register DE by 1
LOOP2: DCX B Decrement the register BC by 1
MOV A,C Move the contents of register C to A
ORA B Contents of A are logically O real with B
JNZ LOOP1 Jump on no zero to LOOP1
SHLD 8850H Store H and L registers direct
XCHG Exchange H and L with D and E
SHLD 8852H Store the H and L register direct
HLT End of program

16 Bit Division
Label Mnemonic Comments
ORG 8000H Assemble the program starting at 8000H
LXI D,0000H Load 0000H in DE register
LXI H,FF66H Load 16 bit data in register BC
LXI B, 8888H Load 16 bit data in register BC
LOOP1: DSUB B Subtract B
JC LOOP2 Jump on carry to LOOP2
INX D Increment the content of register DE by 1
JMP LOOP1 Jump to LOOP1
LOOP2: DAD B Add contents of register pair BC to HL pair
SHLD 8850H Store H and L registers direct
XCHG Exchange H and L with D and E
SHLD 8852H Store the H and L register direct
HLT End of program
2 Array operations
(i) Finding
(ii) Sorting
i (a) Smallest Number
Label Mnemonic Comments
ORG 8500H
DB 09H, 08H,
07H, 06H, 04H
ORG 8000H
MVI C, 0AH
LXI H,8500H
MOV A,M
LOOP1: INX H
CMP M
JC LOOP2
MOV A,M
LOOP2: DCR C
JNZ LOOP1
STA OFE75H
CALL 0578H
HLT

i (b) Largest Number


Label Mnemonic Comments
ORG 8500H
DB 09H, 08H,
07H, 06H, 05H
ORG 8000H
MVI C, 0AH
LXI H,8500H
MOV A,M
LOOP1: INX H
CMP M
JNC LOOP2
MOV A,M
LOOP2: DCR C
JNZ LOOP1
STA OFE75H
CALL 0578H
HLT

i (c) Ascending Order


Label Mnemonic Comments
ORG 8500H
DB 99H, 34H, 23H,
67H, 81H, 05H, 04H,
03H, 02H, 01H
ORG 8000H
MVI B, 0AH
LXI H,8500H
MVI C,09H
LOOP1: MOV A,M
INX H
CMP M
JC LOOP2
MOV D,M
MOV M,A
DCX H
MOV M,D
INX H
LOOP2: DCR C
JNZ LOOP1
DCR B
JNZ REP
HLT

i (d) Descending Order


Label Mnemonic Comments
ORG 8500H
DB 99H, 34H, 23H,
67H, 84H, 05H, 04H,
03H, 02H, 01H
ORG 8000H
MVI B, 0AH
LXI H,8500H
MVI C,09H
LOOP1: MOV A,M
INX H
CMP M
JNC LOOP2
MOV D,M
MOV M,A
DCX H
MOV M,D
INX H
LOOP2: DCR C
JNZ LOOP1
DCR B
JNZ REP
HLT
3. Code conversion:
i (a) Binary to BCD
Label Mnemonic Comments
ORG 8000H
MVI B,OFEH
MVI D,64H
CALL BCD
MOV H,C
MVI D, 0AH
CALL BCD
MOV A,C
RLC
RLC
RLC
RLC
ORA B
MOV L,A
SHLD PFE73H
CALL 056CH
HLT
BCD: MVI C,00H
MOV A,B
REP: SUB D
JC BACK
INR C
JMP REP
BACK: ADD D
MOV B,A
RET
i (b) BCD to Binary
Label Mnemonic Comments
ORG 8000H
MVI B,99H
MOV A,B
ANI OFOH
RRC
RRC
RRC
RRC
MOV D,A
MVI C,OAH
SUB A
REP: ADD D
DCR C
JNZ REP
MOV D,A
MOV A,B
ANI 0FH
ADD D
STA 0FE75H
CALL 0578H
HLT

i (c) HEX to ASCII


Label Mnemonic Comments
ORG 8000H
MVI B,45H
MOV A,B
CALL ASCII
MOV L,A
MOV A,B
RRC
RRC
RRC
RRC
CALL ASCII
MOV H,A
SHLD 0FE73H
CALL 056CH
HLT
ASCII ANI 0FH
CPI 0AH
JC CNVT
ADI 07H
CNVT: ADI 30H
RET

i (d) ASCII to HEX


Label Mnemonic Comments
ORG 8000H
MVI A,45H
CPI 40H
JC CNVT
SUI 07H
SUI 30H
STA 0FE75H
CALL 0578H
HLT
3 Interface Experiments: with 8085
(i) A/D Interfacing. & D/A Interfacing.

4 Traffic light controller.


5 I/O Port / Serial communication
6 Programming Practices with Simulators/Emulators/open source
7 Read a key ,interface display
8 Demonstration of basic instructions with 8051 Micro controller execution, including:
(i) Conditional jumps & looping
(ii) Calling subroutines.
9 Programming I/O Port and timer of 8051
(i) study on interface with A/D & D/A
(ii) Study on interface with DC & AC motors
10 Application hardware development using embedded processors.

You might also like