Escolar Documentos
Profissional Documentos
Cultura Documentos
0032
AIM: To learn the assembly language programming of 8085,8086 and 8051 and also to give a practical training of interfacing the peripheral devices with the processor.
OBJECTIVES: To implement the assembly language programming of 8085,8086 and 8051. To study the system function calls like BIOS/DOS. To experiment the interface concepts of various peripheral device with the processor. Experiments in the following: 1. Programming with 8085 2. Programming with 8086-experiments including BIOS/DOS calls: Keyboard control, Display, File Manipulation. 3. Interfacing with 8085/8086-8255,8253 4. Interfacing with 8085/8086-8279,8251 5. 8051 Microcontroller based experiments for Control Applications 6. Mini- Project TOTAL: 45 PERIODS
List of equipments/components for 30 students (two per batch) 1. 8085 Trainer Kit with onboard 8255, 8253, 8279 and 8251 15 nos. 2. TASM/MASM simulator in PC (8086 programs) 30 nos. 3. 8051 trainer kit 15 nos. 4. Interfacing with 8086 PC add-on cards with 8255, 8253, 8279 and 8251 15 nos. 5. Stepper motor interfacing module 5 nos. 6. Traffic light controller interfacing module 5 nos. 7. ADC, DAC interfacing module 5 nos. 8. CROs 5 nos.
Powered By www.technoscriptz.com
Powered By www.technoscriptz.com
[C]
00H
[HL]
4500H
[A]
[M]
[HL]
[HL]+1
[A]
[A]+[M]
NO
[C]
[C]+1
[HL]
[HL]+1
[M]
[A]
[HL]
[HL]+1
[M]
ALGORITHM: 1. 2. 3. 4. Initialize memory pointer to data location. Get the first number from memory in accumulator. Get the second number and add it to the accumulator. Store the answer at another memory location.
PROGRAM: ADDRESS OPCODE LABEL 4100 START 4101 4102 4103 4104 4105 4106 MNEMONICS OPERAND MVI C, 00 LXI H, 4500 COMMENT Clear C reg. Initialize HL reg. to 4500 Transfer first data to accumulator Increment HL reg. to point next memory Location. Add first number to acc. Content. Jump to location if result does not yield carry. Increment C reg. Increment HL reg. to point next memory Location. Transfer the result from acc. to memory. Increment HL reg. to point next memory Location. Move carry to memory Stop the program
MOV INX
A, M H
ADD JNC
M L1
INR INX
C H
410D 410E
MOV INX
M, A H
410F 4110
MOV HLT
M, C
OBSERVATION:
OUTPUT
Powered By www.technoscriptz.com
RESULT: Thus the 8 bit numbers stored at 4500 &4501 are added and the result stored at 4502 & 4503.
RESULT: Thus the 8 bit numbers stored at 4500 &4501 are subtracted and the result stored at 4502 & 4503.
Powered By www.technoscriptz.com
FLOW CHART:
START
[C]
00H
[HL]
4500H
[A]
[M]
[HL]
[HL]+1
[A]
[A]-[M]
Is there a Borrow ?
NO
YES
Complement [A] Add 01H to [A]
[C]
[C]+1
[HL]
[HL]+1
[M]
[A]
[HL]
[HL]+1
[M]
[C]
Powered By www.technoscriptz.com
STOP
PROGRAM: ADDRESS OPCODE LABEL 4100 START 4102 4102 4103 4104 4105 4106 MNEMONICS OPERAND MVI C, 00 LXI H, 4500 COMMENT Clear C reg. Initialize HL reg. to 4500 Transfer first data to accumulator Increment HL reg. to point next mem. Location. Subtract first number from acc. Content. Jump to location if result does not yield borrow. Increment C reg. Complement the Acc. content Add 01H to content of acc. Increment HL reg. to point next mem. Location. Transfer the result from acc. to memory. Increment HL reg. to point next mem. Location. Move carry to mem. Stop the program
MOV INX
A, M H
SUB JNC
M L1
01H H
4110 4111
MOV INX
M, A H
MOV HLT
M, C
OUTPUT
Powered By www.technoscriptz.com
RESULT: Thus the 8-bit multiplication was done in 8085p using repeated addition method.
Powered By www.technoscriptz.com
FLOW CHART:
START
[HL] 4500
B M
[HL] [HL]+1
A 00
C 00
NO
NO
IS B=0 YES A
Powered By www.technoscriptz.com
[HL]
[HL]+1
[M]
[A]
[HL]
[HL]+1
[M]
[C]
STOP
Powered By www.technoscriptz.com
PROGRAM: ADDRESS OPCODE LABEL 4100 START 4101 4102 4103 4104 MNEMONICS LXI OPERAND H, 4500 COMMENT Initialize HL reg. to 4500 Transfer first data to reg. B Increment HL reg. to point next mem. Location. Clear the acc. Clear C reg for carry
MOV INX
B, M H
4105 4106 4107 4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 L1
MVI MVI
A, 00H C, 00H
ADD JNC
M NEXT
Add multiplicand multiplier times. Jump to NEXT if there is no carry Increment C reg Decrement B reg Jump to L1 if B is not zero. Increment HL reg. to point next mem. Location. Transfer the result from acc. to memory. Increment HL reg. to point next mem. Location. Transfer the result from C reg. to memory. Stop the program
NEXT
C B L1
INX
4113 4114
MOV INX
M, A H
MOV HLT
M, C
OUTPUT
Powered By www.technoscriptz.com
RESULT: Thus an ALP was written for 8-bit division using repeated subtraction method and executed using 8085 p kits
Powered By www.technoscriptz.com
FLOWCHART:
START
B 00
[HL] 4500
A M
[B] [B] +1 NO
IS A<0 YES A A+ M
B B-1
[HL]
[HL]+1
[M]
[A]
[HL]
[HL]+1
[M]
[B]
STOP
Powered By www.technoscriptz.com
PROGRAM: ADDRESS 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 LOOP OPCODE LABEL MNEMO NICS MVI LXI OPERA ND B,00 H,4500 COMMENTS Clear B reg for quotient Initialize HL reg. to 4500H Transfer dividend to acc. Increment HL reg. to point next mem. Location. Subtract divisor from dividend Increment B reg Jump to LOOP if result does not yield borrow Add divisor to acc. Decrement B reg Increment HL reg. to point next mem. Location. Transfer the remainder from acc. to memory. Increment HL reg. to point next mem. Location. Transfer the quotient from B reg. to memory. Stop the program
A,M H M B LOOP
M B H M,A H M,B
OBSERVATION:
INPUT DATA
OUTPUT DATA
Powered By www.technoscriptz.com
RESULT: Thus the 16-bit multiplication was done in 8085p using repeated addition method.
Powered By www.technoscriptz.com
FLOWCHART: START
L H
[8050] [8051]
SP
HL
L H
[8052] [8053]
DE
HL
HL BC
0000 0000
HL
HL+SP
NO
DE
DE+1
NO
Powered By www.technoscriptz.com
[8054] [8055]
L H
[8056] [8057]
C B
STOP
Powered By www.technoscriptz.com
PROGRAM ADDRESS OPCODE LABEL MNEM ONICS 8000 START LHLD 8001 8002 8003 SPHL 8004 LHLD 8005 8006 8007 XCHG 8008 LXI 8009 800A 800B LXI 800C 800D 800E LOOP DAD 800F JNC 8010 8011 8012 INX 8013 NEXT DCX 8014 MOV 8015 ORA 8016 JNZ 8017 8018 8019 SHLD 801A 801B 801C MOV 801D STA 801E 801F 8020 MOV 8021 STA 8022 8023 8024 HLT OBSERVATION:
ADDRESS INPUT DATA OUTPUT ADDRESS DATA
OPERAN D 8050
COMMENTS Load the first No. in stack pointer through HL reg. pair
8052
Load the second No. in HL reg. pair & Exchange with DE reg. pair.
SP NEXT
Add SP with HL pair. If there is no carry, go to the instruction labeled NEXT Increment BC reg. pair Decrement DE reg. pair. Move the content of reg. E to Acc. OR Acc. with D reg. If there is no zero, go to instruction labeled LOOP Store the content of HL pair in memory locations 8054 & 8055. Move the content of reg. C to Acc. Store the content of Acc. in memory location 8056. Move the content of reg. B to Acc. Store the content of Acc. in memory location 8056. Stop program execution
B D A,E D LOOP
8054
A, C 8056
A, B 8057
Powered By www.technoscriptz.com
8053
8057
ALGORITHM: 1. Place all the elements of an array in the consecutive memory locations. 2. Fetch the first element from the memory location and load it in the accumulator. 3. Initialize a counter (register) with the total number of elements in an array. 4. Decrement the counter by 1. 5. Increment the memory pointer to point to the next element. 6. Compare the accumulator content with the memory content (next element). 7. If the accumulator content is smaller, then move the memory content (largest element) to the accumulator. Else continue. 8. Decrement the counter by 1. 9. Repeat steps 5 to 8 until the counter reaches zero 10. Store the result (accumulator content) in the specified memory location.
RESULT: Thus the largest number in the given array is found out.
Powered By www.technoscriptz.com
NO
NO
Powered By www.technoscriptz.com
PROGRAM: ADDRE SS 8001 8002 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D 800E 800F 8010 8011 8012 8013 8014 OPCO DE LABEL MNEM ONICS LXI OPER AND H,8100 COMMENTS Initialize HL reg. to 8100H Initialize B reg with no. of comparisons(n-1) Transfer first data to acc. Increment HL reg. to point next memory location Compare M & A If A is greater than M then go to loop Transfer data from M to A reg Decrement B reg If B is not Zero go to loop1
LOOP1
LOOP
A,M B LOOP1
STA
8105
HLT
OBSERVATION: INPUT ADDRESS DATA 8100 8101 8102 8103 8104 OUTPUT ADDRESS DATA 8105
Powered By www.technoscriptz.com
ALGORITHM: 1. Place all the elements of an array in the consecutive memory locations. 2. Fetch the first element from the memory location and load it in the accumulator. 3. Initialize a counter (register) with the total number of elements in an array. 4. Decrement the counter by 1. 5. Increment the memory pointer to point to the next element. 6. Compare the accumulator content with the memory content (next element). 7. If the accumulator content is smaller, then move the memory content (largest element) to the accumulator. Else continue. 8. Decrement the counter by 1. 9. Repeat steps 5 to 8 until the counter reaches zero 10. Store the result (accumulator content) in the specified memory location.
RESULT: Thus the smallest number in the given array is found out.
Powered By www.technoscriptz.com
YES
NO
Powered By www.technoscriptz.com
PROGRAM: ADDRE SS 8001 8002 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D 800E 800F 8010 8011 8012 8013 8014 OPCO DE LABEL MNEM ONICS LXI OPER AND H,8100 COMMENTS Initialize HL reg. to 8100H Initialize B reg with no. of comparisons(n-1) Transfer first data to acc. Increment HL reg. to point next memory location Compare M & A If A is lesser than M then go to loop Transfer data from M to A reg Decrement B reg If B is not Zero go to loop1
LOOP1
LOOP
A,M B LOOP1
STA
8105
HLT
OBSERVATION: INPUT ADDRESS DATA 8100 8101 8102 8103 8104 OUTPUT ADDRESS DATA 8105
Powered By www.technoscriptz.com
8.ASCENDING ORDER
AIM: To sort the given number in the ascending order using 8085 microprocessor. ALGORITHM: 1. Get the numbers to be sorted from the memory locations. 2. Compare the first two numbers and if the first number is larger than second then I interchange the number. 3. If the first number is smaller, go to step 4 4. Repeat steps 2 and 3 until the numbers are in required order
RESULT: Thus the ascending order program is executed and thus the numbers are arranged in ascending order.
Powered By www.technoscriptz.com
FLOWCHART:
YES
[HL] [A]
[HL] [HL] - 1
A Powered By www.technoscriptz.com
NO
NO
Powered By www.technoscriptz.com
PROGRAM: ADDR E SS 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D 800E 800F 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 801A OPCO DE LABEL MNEM ONICS MVI LOOP 3 LXI OPER AND B,04 H,8100 COMMENTS
Initialize B reg with number of comparisons (n-1) Initialize HL reg. to 8100H Initialize C reg with no. of comparisons(n-1) Transfer first data to acc. Increment HL reg. to point next memory location Compare M & A If A is less than M then go to loop1 Transfer data from M to D reg Transfer data from acc to M Decrement HL pair Transfer data from D to M Increment HL pair Decrement C reg If C is not zero go to loop2
LOOP1
DCR JNZ
B LOOP3
HLT
OBSERVATION: INPUT MEMORY LOCATION 8100 8101 8102 8103 DATA MEMORY LOCATION 8100 8101 8102 8103 OUTPUT DATA
Powered By www.technoscriptz.com
8104
8104
9. DESCENDING ORDER
AIM: To sort the given number in the descending order using 8085 microprocessor. ALGORITHM: 1. Get the numbers to be sorted from the memory locations. 2. Compare the first two numbers and if the first number is smaller than second then I interchange the number. 3. If the first number is larger, go to step 4 4. Repeat steps 2 and 3 until the numbers are in required order
RESULT: Thus the descending order program is executed and thus the numbers are arranged in descending order.
Powered By www.technoscriptz.com
FLOWCHART:
[HL] [A]
[HL] [HL] - 1
A Powered By www.technoscriptz.com
NO
NO
Powered By www.technoscriptz.com
PROGRAM: ADDRE SS 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D 800E 800F 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 801A OPCO DE LABEL MNEM ONICS MVI LXI OPER AND B,04 H,8100 COMMENTS Initialize B reg with number of comparisons (n-1) Initialize HL reg. to 8100H Initialize C reg with no. of comparisons(n-1) Transfer first data to acc. Increment HL reg. to point next memory location Compare M & A If A is greater than M then go to loop1 Transfer data from M to D reg Transfer data from acc to M Decrement HL pair Transfer data from D to M Increment HL pair Decrement C reg If C is not zero go to loop2
LOOP 3
LOOP1
DCR JNZ
B LOOP3
HLT
OBSERVATION: INPUT MEMORY LOCATION 8100 8101 8102 8103 DATA MEMORY LOCATION 8100 8101 8102 8103 OUTPUT DATA
Powered By www.technoscriptz.com
8104
8104
RESULT: Thus an ALP program for conversion of decimal to hexadecimal was written and executed.
Powered By www.technoscriptz.com
Powered By www.technoscriptz.com
FLOWCHART:
START
HL A
4500H 00
B B
00H B+1
A +1
NO
Is A=M?
YES
A B
8101
Stop
Powered By www.technoscriptz.com
PROGRAM: ADDRE SS 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D 800E 800F 8010 8011 8012 8013 OPCO DE LABEL MNEM ONICS LXI OPER AND H,8100 COMMENTS Initialize HL reg. to 8100H Initialize A register. Initialize B register.. Increment B reg. Increment A reg Decimal Adjust Accumulator Compare M & A If acc and given number are not equal, then go to LOOP Transfer B reg to acc. Store the result in a memory location. Stop the program
A,00 B,00 B 01
M LOOP
MOV STA
A,B 8101
HLT
Powered By www.technoscriptz.com
RESULT: Thus an ALP program for conversion of hexadecimal to decimal was written and executed.
Powered By www.technoscriptz.com
START
FLOWCHART:
HL A 8100H 00
B C B
A +1
Is there carry?
C D A,
C+1 A B,
Is A=M?
Powered By www.technoscriptz.com
PROGRAM: ADDRE SS 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D 800E 800F 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 801A 801B 801C 801D 801E 801F OPCO DE LABEL MNEM ONICS LXI OPER AND H,8100 COMMENTS Initialize HL reg. to 8100H Initialize A register. Initialize B register. Initialize C register for carry. Increment B reg. Increment A reg Decimal Adjust Accumulator If there is no carry go to NEXT. Increment c register. Transfer A to D Transfer B to A Compare M & A Transfer D to A If acc and given number are not equal, then go to LOOP Store the result in a memory location. Transfer C to A Store the carry in another memory location. Stop the program
NEXT
NEXT
STA
8101
MOV STA
A,C 8102
HLT
RESULT: INPUT ADDRESS 8100 OUTPUT ADDRESS DATA 8101 8102 Powered By www.technoscriptz.com
DATA
RESULT: Thus the 8 bit BCD numbers stored at 4500 &4501 are added and the result stored at 4502 & 4503.
Powered By www.technoscriptz.com
FLOW CHART:
START
[C]
00H
[HL]
4500H
[A]
[M]
[HL]
[HL]+1
[C]
[C]+1
[HL]
[HL]+1
[M]
[A]
[HL]
[HL]+1
[M]
[C]
STOP
Powered By www.technoscriptz.com
PROGRAM: ADDRESS OPCODE LABEL 4100 START 4103 4102 4103 4104 4105 4106 MNEMONICS OPERAND MVI C, 00 LXI H, 4500 COMMENT Clear C reg. Initialize HL reg. to 4500 Transfer first data to accumulator Increment HL reg. to point next memory Location. Add first number to acc. Content. Decimal adjust accumulator Jump to location if result does not yield carry. Increment C reg. Increment HL reg. to point next memory Location. Transfer the result from acc. to memory. Increment HL reg. to point next memory Location. Move carry to memory Stop the program
MOV INX
A, M H
L1
INR INX
C H
410E 410F
MOV INX
M, A H
4110 4111
MOV HLT
M, C
OBSERVATION:
OUTPUT
Powered By www.technoscriptz.com
RESULT: Thus the 8 bit BCD numbers stored at 4500 &4501 are subtracted and the result stored at 4502 & 4503.
Powered By www.technoscriptz.com
FLOW CHART:
START
Is there a Carry ?
YES
NO
[D] [D]+1
[HL]
[HL]+1
[4502] [4503]
A D
STOP
Powered By www.technoscriptz.com
PROGRAM: ADDRESS OPCODE LABEL 4100 START 4101 4102 4103 4104 4105 4106 MNEMONICS OPERAND COMMENT MVI D, 00 Clear D reg. LXI H, 4500 Initialize HL reg. to 4500 Transfer first data to accumulator Increment HL reg. to point next mem. Location. Move second no. to B reg. Move 99 to the Accumulator Subtract [C] from acc. Content. Increment A register Add [B] with [A] Adjust Accumulator value for Decimal digits Jump on carry to loop
MOV INX
B, M H
4107 4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 LOOP
C, M A, 99 C A B
LOOP
D H M,A H
MOV HLT
M, D
Increment D reg. Increment HL register pair Move the Acc.content to the memory location Increment HL reg. to point next mem. Location. Transfer D register content to memory. Stop the program
OUTPUT
Powered By www.technoscriptz.com