Microprocessor Alp (Repaired)
Microprocessor Alp (Repaired)
Any 14 Experiments
Microprocessor 8085
1. Program for multibyte hexadecimal addition/subtraction
2. Program for multibyte decimal addition/subtraction. .
3. 1’s and 2’s complements in an array
4. Shift left and right 8 bit number by one bit.
5. Find largest / smallest numbers in a list.
6. Arrange in ascending /descending order.
7. Code conversion ASCII to Decimal and vice versa, Decimal to Binary and Binary to
Decimal.
8. Block of data transfer.
9. Rolling display.
10. Making an 8 bit DAC.
11. Making an 8-bit ADC (LED, RAM).
12. Wave form generation (sine, square, triangular) 8253.
13. Stepper motor interface.
14. Traffic light interface.
15. Digital clock.
16. Solid state relay interface.
17. Study of PPI 8255.
Microcontroller 8051
18. Program for addition and subtraction in 8 bits
19. Program for multiplication and division in 8 bits.
20. Sum of N numbers
21. Block of data transfer
22. Binary to decimal conversion vice –versa
Aim: Write an 8085 ALP to add two 8 –bits hexadecimal number in 4150H and 4151H
and store the sum 16-bits in 4152H and 4153H.
Flow chart:
Start
Is
Yes No No
carr
y? Increment the C register by one
Stop
Addition of Two 8-bits number
Sum-16 bits
Input 1 Output
Input 2 Output
Address Data
4501 85
4502 69
4503 39
Input:
Address Data
4500 03
4501 73
4502 21
4503 67
4551 88
4552 51
4553 27
PROGRAM FOR MULTIBYTE HEXA DECIMAL ADDITION
Aim: Write an 8085 ALP for multi-byte Hexadecimal addition stored in memory
location 4151H (Starting address of the First multi-byte number) and 4251H (Starting
address of the second multi-byte number) and stores the result in the First multi–byte
number address.
Flow chart:
Start
No Yes
Is
count=0
?
Stop
ADDRESS OPCODE LABEL MNEMONICS COMMENT
4100 21 50 41 LXI H 4150 Address of byte count in H L pair
4103 4E MOV C,M Byte count in register C
4104 23 INX H Address of the 1st byte of the 1st number
4105 11 51 42 LXI D,4251 Address of the 1st byte of the 2nd number
4108 AF XRA A Clear carry
4109 1A REPEAT LDAX,D get byte of 2nd number in accumulator
410A 8E ADC,M Byte of 2nd number+byte of 1st number +carry
410B 77 MOV M,A Store sum in memory addressed by H-L pair
410C 23 INX H Increment the address pointed by H-L pair
410D 13 INX D Increment the address pointed by D-E pair
410E 0D DCR C Decrement the count
410F C2 09 41 JNZ REPEAT Is count=0? No jump to REPEAT
4112 76 HLT Halt the program
PROGRAM FOR MULTIBYTE DECIMAL ADDITION
Aim: Write an 8085 ALP for multi-byte Decimal addition stored in memory location
4151H (Starting address of the First multi-byte number) and 4251H (Starting address of
the second multi-byte number) and stores the result in the First multi–byte number
address.
Flow chart:
Start
No Yes
Is
count=0
?
Stop
PROGRAM FOR MULTIBYTE DECIMAL ADDITION
ADDRESS OPCODE LABEL MNEMONICS COMMENT
4100 21 50 41 LXI H 4150 Address of byte count in H L pair
4103 4E MOV C,M Byte count in register C
4104 23 INX H Address of the 1st byte of the 1st number
4105 11 51 42 LXI D,4251 Address of the 1st byte of the 2nd number
4108 AF XRA A Clear carry
4109 1A REPEAT LDAX,D get byte of 2nd number in accumulator
410A 8E ADC,M Byte of 2nd number+byte of 1st number +carry
410B 27 DAA Decimal adjust accumulator
410c 77 MOV M,A Store sum in memory addressed by H-L pair
410D 23 INX H Increment the address pointed by H-L pair
410E 13 INX D Increment the address pointed by D-E pair
410F 0D DCR C Decrement the count
4110 C2 09 41 JNZ REPEAT Is count=0? No jump to REPEAT
4113 76 HLT Halt the program
PROGRAM FOR MULTIBYTE HEXA DECIMAL SUBTRACTION
Aim: Write an 8085 ALP for multi-byte Hexadecimal subtraction stored in memory
location 4151H (Starting address of the First multi-byte number) and 4251H (Starting
address of the second multi-byte number) and stores the result in the First multi–byte
number address.
Flow chart:
Start
No Yes
Is
count
=0?
Stop
PROGRAM FOR MULTIBYTE HEXA DECIMAL SUBTRACTION
ADDRESS OPCODE LABEL MNEMONICS COMMENT
4100 21 50 41 LXI H 4150 Address of byte count in H L pair
4103 4E MOV C,M Byte count in register C
4104 23 INX H Address of the 1st byte of the 1st number
4105 11 51 42 LXI D,4251 Address of the 1st byte of the 2nd number
4108 AF XRA A Clear accumulator
4109 1A REPEAT LDAX,D get byte of 2nd number in accumulator
Subtract Byte of 2nd number from byte of 1st number with
410A 9E SBB,M borrow
410B 77 MOV M,A Store difference in memory addressed by H-L pair
410C 23 INX H Increment the address pointed by H-L pair
410D 13 INX D Increment the address pointed by D-E pair
410E 0D DCR C Decrement the count
410F C2 09 41 JNZ REPEAT Is count=0? No jump to REPEAT
4112 76 HLT Halt the program
Input:
PROGRAM FOR SUM OF N NUMBERS
Aim:
Write an 8085 ALP program for sum of a series of 8-bits number and store the result in
XX50H (Hexa-decimal)
Flow- Chart:
Star
t
INTIALISE H-L PAIR
NO
IS
CARRY?
YES
NO
Is
count=0
?
YES
Stop
SUM OF A SERIES OF 8-BITS NUMBERS (HEXA DECIMAL)
ADDRESS OPCODE LABEL MNEMONICS COMMENT
4100 21 00 42 LXI H 4200H Address of the count in H-L pair
4103 4E MOV C,M Count in Register C
4104 3E 00 MVI A 00H LSB of the sum=00
4106 47 MOV B,A MSB of the sum = 00
4107 23 LOOP INX H Address of next data in H-L pair
4108 86 ADD M Previous sum + next number
4109 D2 0D 41 JNC AHEAD Is carry? No, go to AHEAD
410C 04 INR B Yes add carry to MSBs of sum
410D 0D AHEAD DCR C Decrement count
410E C2 07 41 JNZ LOOP Is count =0? No, jump to LOOP
4111 23 INX H Get the address to store LSB of sum
4112 77 MOV M,A Store the LSB of sum
4113 23 INX H Get the address to store MSB of sum
4114 70 MOV M,B Store the MSB of sum
4115 76 HLT Terminate the program
Aim:
Write an 8085 ALP program for sum of a series of 8-bits number and store the result in
XX50H (Hexa-decimal)
Flow- Chart:
Star
t
NO
IS
CARRY?
YES
MSB OF SUM =PREVIOUS VALUE +1
Is
NO count=0
?
YES
Stop
Sum of series of 8 –bits Decimal numbers
AIM:
Write an 8085 ALP to find the 1’s complement of numbers in an array.
FLOW –CHART;
Start
No Yes
Is
count
=0?
Stop
1’S COMPLEMENT OF NUMBERS IN AN ARRAY
ADDRESS OPCODE LABEL MNEMONICS COMMENT
4100 21 00 42 LXI H 4200H Address of the count in H-L pair
4103 4E MOV C,M Count in Register C
4104 23 INX H Get the address where the result is stored
4105 11 51 42 LXI D 4251 Get the address of the number
4108 1A LOOP LDAX D Get the data to accumulator addressed by DE pair
4109 2F CMA 1’s complement of the number
410A 77 MOV M,A Store the result addressed by HL pair
410B 23 INX H Get the next address to store the result
410C 13 INX D Get the address of the 2nd number
410D 0D DCR C Decrement count
410E C2 07 41 JNZ LOOP Is count =0? No, jump to LOOP
4111 76 HLT Terminate the program
2’S COMPLEMENT OF NUMBERS IN AN ARRAY
AIM:
Write an 8085 ALP to find the 2’s complement of numbers in an array.
FLOW –CHART;
Start
No Yes
Is
count
=0?
Stop
2’S COMPLEMENT OF NUMBERS IN AN ARRAY
ADDRESS OPCODE LABEL MNEMONICS COMMENT
4100 21 00 42 LXI H 4200H Address of the count in H-L pair
4103 4E MOV C,M Count in Register C
4104 23 INX H Get the address where the result is stored
4105 11 51 42 LXI D 4251 Get the address of the number
4108 1A LOOP LDAX D Get the data to accumulator addressed by DE pair
4109 2F CMA 1’s complement of the number
410A 3C INR A Add 1 to the accumulator
410B 77 MOV M,A Store the result in the memory addressed by HL pair
410C 23 INX H Get the next address to store the result
410D 13 INX D Get the address of the 2nd number
410E 0D DCR C Decrement count
410F C2 08 41 JNZ LOOP Is count =0? No, jump to LOOP
4112 76 HLT Terminate the program
LARGEST AND SMALLEST NUMBER FROM AN ARRAY
AIM:
Write an 8085 ALP to find the largest number from an array.
FLOW-CHART: (Largest)
START
INITIALISE HL PAIR
YES
Is number in
Acc. A > next
number
NO
GET THE LARGER NUMBER IN ACCUMULATOR
DECREMENT COUNT
NO IS
COUNT
=0?
YES
STORE RESULT
STOP
LARGEST NUMBER FROM AN ARRAY
ADDRESS OPCODE LABEL MNEMONICS COMMENT
4100 21 00 42 LXI H 4200H Address of the count in H-L pair
4103 4E MOV C,M Count in Register C
4104 23 INX H Address of the first number in HL pair
4105 7E MOV A,M 1st number in accumulator
4106 0D DCR C Get the address of the number
4107 23 LOOP INX H Get the data to accumulator addressed by DE pair
4108 BE CMP M 1’s complement of the number
4109 D2 0D 41 JNC AHEAD Add 1 to the accumulator
410C 7E MOV A,M Store the result in the memory addressed by HL pair
410D 0D AHEAD DCR C Decrement count
410E C2 07 41 JNZ LOOP Is count =0? No, jump to LOOP
4111 32 50 42 STA 4250 Store the largest number in 4250H
4114 76 HLT Terminate the program
FLOW-CHART: (Smallest)
START
INITIALISE HL PAIR
YES
Is number in
Acc. A < next
number
NO
GET THE LARGER NUMBER IN ACCUMULATOR
DECREMENT COUNT
NO IS
COUNT
=0?
YES
STORE RESULT
STOP
SMALLEST NUMBER FROM AN ARRAY
ADDRESS OPCODE LABEL MNEMONICS COMMENT
4100 21 00 42 LXI H 4200H Address of the count in H-L pair
4103 4E MOV C,M Count in Register C
4104 23 INX H Address of the first number in HL pair
4105 7E MOV A,M 1st number in accumulator
4106 0D DCR C Get the address of the number
4107 23 LOOP INX H Get the data to accumulator addressed by DE pair
4108 BE CMP M 1’s complement of the number
4109 D2 0D 41 JC AHEAD Add 1 to the accumulator
410C 7E MOV A,M Store the result in the memory addressed by HL pair
410D 0D AHEAD DCR C Decrement count
410E C2 07 41 JNZ LOOP Is count =0? No, jump to LOOP
4111 32 50 42 STA 4250 Store the largest number in 4250H
4114 76 HLT Terminate the program
Code Conversion
ASCII to Decimal
Aim:
To convert the given ASCII number value to its decimal equivalent value.
Flow chart:
STAR
T
DATA=DATA-30H
YES NO
IS
DATA
>09H
RESULT=FFH RESULT=DATA
STOP
ASCII TO DECIMAL
ADDRESS OPCODE LABEL MNEMONICS COMMENT
4100 21 00 42 LXI H 4200H Address of the count in H-L pair
4103 7E MOV A,M Data is in Reg. A (Accumulator)
4104 DE 30 SUI 30 Subtract 30 from accumulator
4106 FE 0A CPI 0A Compare the accumulator content with 0A
4108 DA 0D 41 JC LOOP If A<0A store the result
410B 3E FF MVI A, FF No make the Result = FF
410D 23 LOOP INX H Memory address is incremented by 1
410E 77 MOVM,A Accumulator content is in 4201H
410F 76 HLT Halt
ASCII to Hexa- Decimal
Aim:
To convert the given ASCII number value to its Hexa-decimal equivalent value.
Flow chart:
STAR
T
DATA=DATA-30H
NO YES
IS
DATA
<0AH
STOP
ASCII TO HEXA-DECIMAL
ADDRESS OPCODE LABEL MNEMONICS COMMENT
4100 21 00 42 LXI H 4200H Address of the count in H-L pair
4103 7E MOV A,M Data is in Reg. A (Accumulator)
4104 DE 30 SUI 30 Subtract 30 from accumulator
4106 FE 0A CPI 0A Compare the accumulator content with 0A
4108 DA 0D 41 JC LOOP If A<0A store the result
410B D6 07 SUI, 07 Subtract 07 from Accumulator
410D 23 LOOP INX H Memory address is incremented by 1
410E 77 MOVM,A Accumulator content is in 4201H
410F 76 HLT Halt
Hexa- Decimal to ASCII
Aim:
Flow chart:
STAR
T
YES NO
IS
DATA
<0AH
Add 07 with Acc. A
STOP
HEXA-DECIMAL TO ASCII
ADDRESS OPCODE LABEL MNEMONICS COMMENT
4100 21 00 42 LXI H 4200H Address of the count in H-L pair
4103 7E MOV A,M Data is in Reg. A (Accumulator)
4104 FE 0A CPI 0A Compare the accumulator content with 0A
4108 DA 0D 41 JC LOOP If A<0A store the result
410B C6 07 ADI, 07 Subtract 07 from Accumulator
410D C6 30 LOOP ADI 30 Memory address is incremented by 1
23 INX H memory address is increased by 1 to store result
410E 77 MOVM,A Accumulator content is in 4201H
410F 76 HLT Halt
Decimal to ASCII
Aim:
To convert the given Decimal number value to its ASCII equivalent value.
Flow chart:
STAR
T
YES IS NO
Accumulator
<0AH
Move FF H to Accumulator
Add 30H to Accumulator A
STOP
Decimal to ASCII
ADDRESS OPCODE LABEL MNEMONICS COMMENT
4100 21 00 42 LXI H 4200H Address of the count in H-L pair
4103 7E MOV A,M Data is in Reg. A (Accumulator)
4104 FE 0A CPI 0A Subtract 30 from accumulator
4106 DA 0D 41 JC LOOP If A<0A store the result
4109 3E FF MVI A FF Move FF to Accumulator
410B C3 10 41 JMP L2 Jump to the instruction labeled as L2
410E C6 30 LOOP ADI, 30H Subtract 07 from Accumulator
4110 23 L2 INX H Memory address is incremented by 1
4111 77 MOVM,A Accumulator content is in 4201H
4112 76 HLT Halt
INX H
CMP M
MOV M,B
SKIP: DCR D
INX H
CMP M
MOV M,B
SKIP: DCR D
4100 21 50 41 START: LXI H, 4150H Setup HL pair as a pointer for source memory.
410C 0F RRC
410D 0F RRC
410E 0F RRC
Flow-chart:
Sta
rt
Move it to Register D
Move it to register C
Move 0A to register E
Decrement register E by 1
NO YES
Is E=0?
Stop
Flow-chart:
Sta
rt
Move it to Register A
Move 0A to register B
Stop
Address Hex codes Label Mnemonic Comment
4100 21 50 41 START: LXI H, 4150H Set up HL pair as a pointer for source memory.
4100 21 50 41 START: LXI H, 4150H Set up HL pair as a pointer for source memory.
Input: 4150 -------- 24 - 0010 0100 output: 4151---------0100 1000 (48) RRC
4150---------24-0010 0100 Output: 4151----------0001 0010 (12) RLC
Ripple counter generation using 8255
Aim: To use port B of 8255 as a ripple counter.
DAC
1 SQUARE WAVE
Aim:
To generate square wave using DAC interface
FLOW-CHART
Sta
rt
2 SAW-TOOTH WAVE
Aim: To generate saw-tooth wave using DAC interface
FLOW-CHART
Sta
rt
Increment A by 1
Call procedure
YES power ten
IS A is not 0?
NO
3 TRIANGULAR WAVE
Aim: To generate triangular wave using DAC interface.
FLOW-CHART
Sta
rt
Output the current state of saw –tooth wave to DAC through Port
Increment A by 1
Call procedure
YES power ten
IS A is not 0?
NO
Output the current state of saw –tooth wave to DAC through Port
Decrement A by 1
Call procedure
power ten
YES
IS A is not 0?
NO
STUDY OF 8253 COUNTER
Aim: To study the operation of rate generator, divide by “n” Binary/BCD counter using IC 8253
Control Word Register:
D7 D6 D5 D4 D3 D2 D1 D0
SC1 SC0 RL1 RL0 M2 M1 M0 BCD
Rate generator: Use 8253 in Mode 2 to act as a divide by –N counter. N=16 decimal =10 in
Hexa- decimal
Control Word Register---- 94
D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 1 0 1 0 0
Address Hex codes Label Mnemonic Comment
94 is the CW for Mode 2 operation for binary counting. 13 –address for control
12 for counter 2
For N=10H=16 Decimal. The output remains high for 8 clock cycles and then low for next 8
clock cycles.
BCD
N=10. For the first 5 clock output is high and then low for next 5 clock cycles.
Rolling message program –8085 microprocessor
D7 D6 D5 D4 D3 D2 D1 D0
A3 A2 A1 A0 B3 B2 B1 B0
d c b a dp g f e
0 for active 1 in active
1The following program select channel 0 and start analog to digital conversion by using
ALE signal.
ORG 4100H
4100 3E 10 START: MVI A, 10H Select Channel 0 and Make
4102 D3 C8 OUT 0C8H ALE Low
4104 3E 18 MVI A, 18H Make ALE High
4106 D3 C8 OUT 0C8H
4108 3E 10 MVI A, 10H Make ALE Low
410A D3 C8 OUT 0C8H
410C 76 HLT
PROCEDURE
1. Place jumper J2 in C position.
2. Place jumper J5 in A position.
3. Enter and execute the program.
4. Vary the analog input (using trimpot) and view the corresponding digital value in
the led display.
PROCEDURE
1. Place jumper J2 in A position.
2. Place jumper J5 in A position.
3. Enter and execute the program.
4. Vary the analog input (using trimpot) and view the corresponding digital value in the
LED display.
3 In a real time application, input of data and processing of data are indispensable.
The following programs initiate the conversion process, checks the EOC pin of ADC
0809 as to whether the conversion is over and then inputs the data to the processor. It
also instructs the processor to store the converted digital data at RAM location 4150
(Hex).
ORG 4100H
4100 3E 10 START: MVI A, 10 Select Channel 0 and Make
4102 D3 C8 OUT 0C8H ALE Low
4104 3E 18 MVI A, 18 MAKE ALE HIGH
4106 D3 C8 OUT 0C8H
4108 3E 01 MVI A, 01 SOC Signal High
410A D3 D0 OUT 0D0H
410C AF XRA A Delay
410D AF XRA A
410E AF XRA A
410F 3E 00 MVI A, 00 SOC Signal Low
4111 D3 D0 OUT 0D0H
4113 DB D8 LOP: IN 0D8H Check for EOC
4115 E6 01 ANI 01
4117 FE 01 CPI 01
4119 C2 13 41 JNZ LOP
411C DB C0 IN 0C0H Read Data from ADC
411E 32 50 41 STA 4150H
4121 76 HLT
PROCEDURE
1. Place jumper J2 in A position.
2. Place jumper J5 in A position.
3. Enter and execute the program.
4. Vary the analog input (using trimpot) and verify the digital data displayed with that
data stored in memory location 4150h.
KEYBORD INTERFACE
The following program waits for a key to be pressed in the keyboard, reads the same and stores it
in the location 4200.
PROGRAM:
Reading from 8279
ORG 4100H
4150 DB C2 LOOP: IN CNT FIFO Status
4152 E6 07 ANI 07 Check for a key
4154 CA 50 41 JZ LOOP closure
4157 3E 40 MVI A, 40H set 8279 for a
4159 D3 C2 OUT CNT read of FIFO RAM
415B DB C0 IN DAT
415D 32 00 42 STA 4200 Key code at 4200
4160 76 HLT
When you press the Key 0, the data entered at the FIFO RAM is C0.
ROLLING DISPLAY:
To display the rolling message 'HELP US' in the display.
The initialization of 8279 is same as that of Example-1. Then, the data is fetched from address
412CH and displayed in the first digit of the display. The next data is displayed in the second digit
of the display, since in the command word for 'write display RAM' the Auto Increment flag is set.
A time delay is given between successive digits for a lively display.
Rolling Display with 8279 Int. Board
ORG 4100H
CNT EQU 0C2H
DAT EQU 0C0H
POINTER EQU 412CH
4100 21 2C 41 START: LXI H, POINTER Set pointer = 412CH
4103 16 0F MVI D, 0FH Initialize counter
4105 3E 10 MVI A, 10H
4107 D3 C2 OUT CNT Set mode and display
4109 3E CC MVI A, 0CCH Clear Display
410B D3 C2 OUT CNT
410D 3E 90 MVI A, 90H Write display
410F D3 C2 OUT CNT
4111 7E LOP: MOV A, M
4112 D3 C0 OUT DAT
4114 CD 1F 41 CALL DELAY
4117 23 INX H Increment the pointer
4118 15 DCR D Decrement the counter
4119 C2 11 41 JNZ LOP Jump if non-zero to
411C C3 00 41 JMP START display the next chr.
411F 06 A0 DELAY: MVI B,0A0H
4121 0E FF LOP1: MVI C,0FFH
4123 0D LOP2: DCR C
4124 C2 23 41 JNZ LOP 2
4127 05 DCR B
4128 C2 21 41 JNZ LOP1
412B C9 RET
412C FF FF FF FF
4130 FF FF FF FF
4134 98 68 7C C8
4138 1C 29 FF FF