Upload
donga
View
220
Download
2
Embed Size (px)
Citation preview
DHANALAKSHMI COLLEGE OF ENGINEERINGCHENNAI
CS 2252 – MICPROCESSOR AND MICROCONTROLLER LABORATORY
LABORATORY MANUAL
1
List of experiments
8085 Experiments1. Addition of two 8 bit number without carry
2. Addition of two 8 bit number with carry
3. Subtraction of two 8 bit number without borrow
4. Subtraction of two 8 bit number with borrow
5. Multiplication of two 8 bit numbers
6. Division of two 8 bit numbers
7. Largest number in an array of n numbers
8. Smallest number in an array of n numbers
9. Sorting of array in ascending order
10. Sorting of array in descending order
11. Programmable Parallel Interface 8255 with 8085
12. Interfacing of 8251 and 8253 with 8085
13. Interfacing of 7-segment display 8279 with 8085
8086 Experiments14. Addition of two 16-bit numbers – Direct Addressing
15. Addition of two 16-bit numbers – Indexed Addressing
16. Count the number of data stored in a string
17. Searching a string in a given array
18. Moving a string from one memory location to another
2
8051 Experiments19. Addition of two 16-bit numbers
20. Multiplication of two 8-bit numbers
21. Division of two 8-bit numbers
22. Sum of N-Elements in a given array
23. Finding the largest element in an array
3
8085 EXPERIMENTS
1. ADDITION AND SUBTRACTION OF TWO 8 BIT NUMBERS WITHOUT CARRY
AIM:
To write an assembly language program to perform addition and subtraction of two 8 bit numbers without carry and to execute it using 8085 microprocessor.
ALGORITHM:ADDITION OF TWO 8 BIT NUMBERS
Step1:Get the first number in accumulator.Step2:Get the second number in a register.Step3:Add the two numbers.Step4:Store the result in the memory specified
FLOWCHART:
4
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
ALGORITHM:SUBTRACTION OF TWO 8 BIT NUMBERSStep1:Get the first number in the accumulatorStep2:Get the second number in a registerStep3:Subtract the two numbersStep4:Store the difference in the memory
FLOWCHART:
6
RESULT:
Thus an assembly language program to perform 8 – bit addition and subtraction of two 8 bit numbers (without carry )were written and the outputs were verified using 8085 micro processor kit .
2. ADDITION AND SUBTRACTION OF TWO 8 BIT NUMBERS WITH CARRY
AIM:
To write an assembly language program to perform addition and subtraction of two 8 bit numbers with carry and to execute it using 8085 microprocessor
ALGORITHM:ADDITION OF TWO 8 BIT NUMBERS WITH CARRY
Step1:Get the first number in the accumulatorStep2:Get the second number in a registerStep3:Add the two numbersStep4:Check for carryStep5:If carry flag is set go to step 6 else go to step 7Step6:Increment the carryStep7:Store the sum in the memory specifiedStep8:Store the carry in the memory specified
FLOW CHART:
9
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
ALGORITHM:SUBTRACTION OF TWO 8 BIT NUMBERS WITH BORROWStep1:Get the first number in the accumulatorStep2:Get the second number in a registerStep3:Subtract the two numbersStep4:Check for borrowStep5:If carry flag is set go to step 6 else go to step 7Step6:Increment carryStep7:Store the difference in the memory specifiedStep8:Store the borrow in the memory specified
FLOW CHART:
12
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written to perform addition and subtraction of two 8 bit numbers with carry. It was executed using 8085 microprocessor and the output was verified.
3. ADDITION AND SUBTRACTION OF TWO 16 BIT NUMBERS
AIM:
15
To write an assembly language program to perform addition and subtraction of two 16 bit numbers and to execute it using 8085 microprocessor.
ALGORITHM:ADDITION OF TWO 16 BIT NUMBERS
Step1:Get the first 16 bit number in a register pair(say HL)Step2:Excahnge the contents of HL pair with DE pairStep3:Get the second 16 bit numberStep4:Perform double additionStep5:If carry flag is set go to step 6 else go to step 7Step6:Increment the carryStep7:Store the sum in the memory location specifiedStep8:Store the carry in the memory specified
FLOWCHART:
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS
16
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
ALGORITHM:SUBTRACTION OF TWO 16 BIT NUMBERS
Step1: Get the first 16 bit number in HL pairStep2: Exchange the contents of HL pair with DE pair
18
Step3: Get the second number in HL pairStep4: Subtract the lower order bytes of the two register pairsStep5: Subtract the higher order bytes of the two register pairs with borrowStep6: If borrow is present go to step 8 else go to step 7Step7: Increment the borrowStep8: Store the difference in the memory specifiedStep9: Store the borrow in the memory specified
FLOW CHART:
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS
19
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written to perform addition and subtraction of two 16 bit numbers. It was executed using 8085 microprocessor and the output was verified.
4. MULTIPLICATION OF TWO 8 BIT NUMBERS
AIM:
21
To write an assembly language program to perform multiplication of two 8 bit numbers and to execute it using 8085 microprocessor.
ALGORITHM:
Step1: Initialise Hl register pair and B registerStep2: Get the multiplicandStep3: Get the multiplierStep4: Perform double addition of multiplicand and B registerStep5: Decrement the multiplierStep6: If zero flag is set go to step7 else go to step 4Step7: Store the product in the memory location specifiedStep8: Halt the program
FLOW CHART:
PROGRAM:
22
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written to perform multiplication of two 8 bit numbers. It was executed using 8085 processor and the output was verified.
5. DIVISION OF TWO 8 BIT NUMBERS
AIM:
24
To write an assembly language program to perform division of two 8 bit numbers and to execute it using 8085 microprocessor.
ALGORITHM:
Step1: Get the dividend in the accumulatorStep2: Get the divisor in a register (say B)Step3: Compare the dividend and the divisorStep4: If dividend is less than divisor go to step 7 else go to step 5Step5: Subtract the contents of accumulator and B registerStep6: Increment the quotientStep7: Store the reminder in the memoryStep8: Store the quotient in the memory
FLOW CHART:
PROGRAM:
25
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written to perform division of two 8 bit numbers. It was executed using 8085 microprocessor and the output was verified.
6. LARGEST OF THE NUMBERS IN AN ARRAY
AIM:
27
To write an assembly language program to find the largest of the given numbers and to execute it using 8085 processor.
ALGORITHM:
Step1: Get the countStep2: Get the array of numbers using HL pointerStep3: Move the contents in the memory to the accumulatorStep4: Decrement the counterStep5: If zero flag is set go to step 10 else go to step 6Step6: Get the next data in a register(say B)Step7: Compare the contents of accumulator and B registerStep8: If carry flag is set go to step 9 else go to step 4Step9: Swap the contents of accumulator and B register and jump to step 4Step10: Store the largest number in the memory
FLOW CHART:
PROGRAM:
28
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written to find the largest number from the given numbers .It was executed using 8085 processor and the output was verified.
7. SMALLEST OF THE GIVEN NUMBERS
AIM:
30
To write an assembly language program to find the smallest of the given numbers and to execute it using 8085 processor.
ALGORITHM:Step1: Get the countStep2: Get the array of numbers using HL pointerStep3: Move the contents in the memory to the accumulatorStep4: Decrement the counterStep5: If zero flag is set go to step 10 else go to step 6Step6: Get the next data in a register(say B)Step7: Compare the contents of accumulator and B registerStep8: If carry flag is reset go to step 9 else go to step 4Step9: Swap the contents of accumulator and B register and jump to step 4Step10: Store the smallest number in the memory
FLOW CHART:
PROGRAM:
31
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written to find the smallest number from the given numbers .It was executed using 8085 processor and the output was verified.
8. SORTING OF ARRAY IN ASCENDING ORDER
AIM:
33
To write an assembly language program to sort the given numbers in ascending order and to execute it using 8085 microprocessor
ALGORITHM:
Step1: Get the count of the outer loopStep2: Get the count of the inner loopStep3: Initialise the memory pointer with t he address of the arrayStep4: Get the data from the memoryStep5: Get the next dataStep6: Compare the two numbersStep7: If carry flag is reset go to slep 8 else go to step 9Step8: Swap the contents of consecutive memory locationsStep9: Decrement the inner loop counterStep10: If zero flag is set go to step 11 else go to step 5Step11: Decrement the outer loop counterStep12: If zero flag is set go to step 13 else go to step 2Step13:Halt the program
FLOW CHART:
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS
34
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written to sort the given numbers in ascending order. It was executed using 8085 processor and the output was verified.
9.SORTING OF ARRAY IN DESCENDING ORDER36
AIM:
To write an assembly language program to sort the given numbers in descending order and to execute it using 8085 microprocessor
ALGORITHM:
Step1: Get the count of the outer loopStep2: Get the count of the inner loopStep3: Initialise the memory pointer with t he address of the arrayStep4: Get the data from the memoryStep5: Get the next dataStep6: Compare the two numbersStep7: If carry flag is set go to slep 8 else go to step 9Step8: Swap the contents of consecutive memory locationsStep9: Decrement the inner loop counterStep10: If zero flag is set go to step 11 else go to step 5Step11: Decrement the outer loop counterStep12: If zero flag is set go to step 13 else go to step 2Step13:Halt the program
FLOW CHART:
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS
37
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written to sort the given numbers in descending order. It was executed using 8085 processor and the output was verified.
10. EVEN NUMBERS
AIM:
39
To write an assembly language program to sort the even numbers from the given array and to execute it using 8085 microprocessor
ALGORITHM:
Step1: Get the size of the array(say in E register)Step2: Initialise a register pair with the address of the output arrayStep3: Initialise a register to count the even numbersStep4: Initialise HL pointer with the address of the input arrayStep5: Move the number from memory to accumulatorStep6: Right shift the data in accumulator by 1Step7: If carry flag is reset go to step 8 else got to step 12Step8: Increment the count of even numbersStep9: Move the data from memory to accumulatorStep10: Store the data in register used to store even numbersStep11: Increment the address location used to store even numbersStep12: Get the next number from the memoryStep13: Decrement the E counterStep14: If zero flag is set go to step 15 else go to step 5Step15: Store the count of even numbers in the memory specifiedStep16: Halt the program
FLOW CHART:
PROGRAM:
40
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:Thus an assembly language program was written to sort the even
numbers from the given array of numbers. It was executed using 8085 processor and the output was verified.
11. ODD NUMBERS
42
AIM:
To write an assembly language program to sort the odd numbers from the given array and to execute it using 8085 microprocessor
ALGORITHM:
Step1: Get the size of the array(say in E register)Step2: Initialise a register pair with the address of the output arrayStep3: Initialise a register to count the even numbersStep4: Initialise HL pointer with the address of the input arrayStep5: Move the number from memory to accumulatorStep6: Right shift the data in accumulator by 1Step7: If carry flag is set go to step 8 else got to step 12Step8: Increment the count of odd numbersStep9: Move the data from memory to accumulatorStep10: Store the data in register used to store odd numbersStep11: Increment the address location used to store odd numbersStep12: Get the next number from the memoryStep13: Decrement the E counterStep14: If zero flag is set go to step 15 else go to step 5Step15: Store the count of odd numbers in the memory specifiedStep16: Halt the program
FLOW CHART:
PROGRAM:
43
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:Thus an assembly language program was written to sort the odd numbers
from the given array of numbers. It was executed using 8085 processor and the output was verified.
12. TRANSFER OF BLOCK OF DATA
AIM:
45
To write an assembly language program to transfer a block of data from one memory location to another and to execute it using 8085 microprocessor.
ALGORITHM:
Step1: Get the count of the data to be transferredStep2: Initialise HL pointer with the address of the input arrayStep3: Initialise a register pair with the address of the output arrayStep4: Get the first input dataStep5: Move the data to accumulatorStep5: Store it in the memory specifiedStep6: Get the next dataStep7: Increment the output arrayStep8: Decrement the counterStep9: If zero flag is set go to step10 else go to step 5Step10: Halt the program
FLOW CHART:
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS
46
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:Thus an assembly language program was written to transfer a block of
data from one memory to another. It was executed using 8085 processor and the output was verified.
INTERFACING 8255 - PROGRAMMABLE PARALLEL INTERFACE (PPI) TO 8085 MICROPROCESSOR
AIM:48
To write assembly language programs to interface 8255 with 8085 microprocessor by configuring it three different modes (mode0, mode1, mode2).
Mode0:ALGORITHM:
Step1: StartStep2: Initialize the control register for mode0 configuration.Step3: Send the analog data to the memory.Step4: Send the converted data to the display and save the data in memory.Step5: Stop.
PROGRAMMABLE PARALLEL INTERFACE (PPI)- 8255
Table 1: Table 3:
Table 2:
49
ADDRESS OPCODE MNEUMONICS4100 3E MVI A,804101 804102 D3 OUT C64103 C64104 3E MVI A,554105 554106 D3 OUT C24107 C24108 76 HLT
ADDRESS OPCODE MNEUMONICS4100 3E MVI A,904101 904102 D3 OUT C64103 C64104 DB JN C04105 C04106 D3 OUT C24107 C24108 76 HLT
ADDRESS OPCODE MNEUMONICS4100 3E MVI A,904101 904102 D3 OUT C64103 C64104 DB JN C04105 C04106 32 STA 43004107 004108 434109 76 HLT
ADDRESS OPCODE MNEUMONICS4100 3E MVI A,904101 904102 D3 OUT C64103 C64104 DB JN C04105 C04106 32 STA 43004107 004108 434109 D3 OUT C2410A C2410B 76 HLT
Fig 1: Block Diagram of 8255A – Programmable Parallel Interface (PPI)
Fig 2: 8255 Mode Definition Format
50
Fig 3: Bit Set / Reset Control word format of 8255
MODE 0 OPERATION: SIMPLE I/O TRANSFER
ADDRESS OPCODE MNEUMONICS COMMENTS4100 3E, 90 MVI A,90 Move control word to accumulator4102 D3, C6 OUT C6 Load control word to control
register of 82554104 DB, C0 IN C0 Give input to Port C4106 D3, C2 OUT C2 Send it to Port A4108 76 HLT Stop the process
MODE 0 OPERATION: STORE VALUE TO PROCESSOR MEMORYADDRESS OPCODE MNEUMONICS COMMENTS4100 3E, 90 MVI A,90 Move control word to accumulator4102 D3, C6 OUT C6 Load control word to control
register of 82554104 DB, C0 IN C0 Give input to Port C4106 32, 00, 43 STA 4300 Store to memory location 43004109 76 HLT Stop the process
MODE 0 OPERATION: LOAD VALUE FROM PROCESSOR MEMORYADDRESS OPCODE MNEUMONICS COMMENTS4100 3E, 80 MVI A,80 Move control word to accumulator4102 D3, C6 OUT C6 Load control word to control
register of 82554104 3E, 55 MVI A,55 Load input from processor
memory
51
4106 D3, C2 OUT C2 Send it to Port A4108 76 HLT Stop the process
MODE 0 OPERATION: STORE VALUE TO PROCESSOR MEMORYADDRESS
OPCODE MNEUMONICS COMMENTS
4100 3E, 90 MVI A,90 Move control word to accumulator4102 D3, C6 OUT C6 Load control word to control register
of 82554104 DB, C0 IN C0 Give input to Port C4106 32, 00,
43STA 4300 Store to memory location 4300
4109 D3, C2 OUT C2 Send it to Port A410B 76 HLT Stop the process
52
Result:Thus the program for programmable parallel interface (PPI) to 8085
microprocessor was executed and verified
53
INTERFACING 8253 - TIMER/ COUNTER AND 8251 - USART TO 8085 MICROPROCESSOR
AIM
To write assembly language program to interface 8251 and 8253 with 8085 Microprocessor and to transmit and receive data serially through 8251.
ALGORITHM
1. To Transmit Data serially, initialize a counter.2. Load the 16-bit count in the counter.3. Load the control word in 8251.4. Send the data to 8251.5. Halt.6. To receive data serially, get the data from 8251.7. Save the data in memory.8. Halt
INTERFACING 8251 USART
Fig. 1 Block Diagram of 8251
54
Block diagram of 8253
PROGRAM
Transmitter Side
MEMORY OPCODE MNEMONICS COMMENTS4100 3E, 36 MVI A,36H Configure 8253 to count binary,mode3,
read / load LSB first then MSB, counter 0
4102 D3, CE OUT CE Load control word to control register of 8253
4104 3E, 0A MVI A, 0AH Move lower 8 bit count value to accumulator
4106 D3, C8 OUT C8H Load count to channel 0 of 82534108 3E, 00 MVI A,00H Move upper 8 bit count value to
accumulator410A D3,C8 OUT C8H Load count to counter 0 of 8253410C 3E, 4E MVI A, 4E Configure mode instruction of 8251 410E D3,C2 OUT C2H Load control word to control register of
82514110 3E, 37 MVI A,37 Configure command instruction of
82514112 D3,C2 OUT C2 Load control word to control register of
82514114 3E,41 MVI A,41H Move serial data to be transmitted 4116 D3,C0 OUT C0H Load the serial data to data register4118 76 HLT Stop the process
57
Receiver Side
MEMORY OPCODE MNEMONICS COMMENTS4200 DB,C0 IN C0 Get the serial data from data register4202 32, 50,41 STA 4150 Store in 4150 memory location of 80854205 76 HLT Stop the process
Output
Memory address
Input value Memory address
Output value
RESULT
Thus the Assembly language programs to interface 8251 and 8253 with 8085 were written and the data was transmitted and received serially using 8251.They were executed and the output was verified.
58
. INTERFACING 8279 – KEYBOARD / DISPLAY CONTROLLER WITH 8085 MICROPROCESSOR
AIM: To write an assembly language program to interface 8279 to 8085 microprocessor.
ALGORITHM:Step1: Start Step2: Initialize the accumulator.Step3: Load the appropriate command words in control register.Step4: Load the appropriate words for the characters to be displayed, in the accumulator in analog form.Step5: Send the converted data to 8279 display.Step6: Stop.
FLOW CHART:
59
PROGRAM:
MEMORY OPCODE MNEMONICS COMMENTS4100 21, 2C, 41 LXI H, 412C Load pointer address to HL register4103 16, 0F MVI D,0F Move look up table count value to D
register4105 3E, 10 MVI A,10 Set display mode to right entry4107 D3,C2 OUT C2 Load control word into control register4109 3E, CC MIV A,CC Clear Display RAM410B D3,C2 OUT C2 Load control word into control register410D 3E, 90 MVI A,90 Read data to display memory410F D3,C2 OUT C2 Load control word into control register4111 7E MOV A,M Move HL memory content to
accumulator4112 D3, C0 OUT C0 Move to LED segment register 4114 CD, 1F,
41CALL 411F Move program control to 411F-delay
loop4117 23 INX H Increment HL by one memory location4118 15 DCR D Decrement count value of look up
table4119 C2, 11, 41 JNZ 4111 Jump to 4111 till count value reaches
zero411C C3, 00, 41 JMP 4100 Display the look up table values
continually411F 06, A0 MVI B, 0A Load outer delay count value to B
register4121 0E, FF MVI C,FF Load inner delay count value to C
resister4123 0D DCR C Decrement C register content4124 C2, 23, 41 JNZ 4123 Jump to 4123 till count value reaches
zero4127 05 DCR B Decrement B register content4128 C2, 21, 41 JNZ 4121 Jump to 4121 till count value reaches
zero412B C9 RET Return to main program
60
LOOK UP TABLE:
MEMORY INPUT MEMORY INPUT412C FF 4134 FF412D FF 4135 98412E FF 4136 68412F FF 4137 7C4130 FF 4138 C84131 FF 4139 FF4132 FF 413A FF4133 FF 413B FF
RESULT:
Thus an assembly language program was written to interface 8279 with 8085 microprocessor. It was executed and the output was verified
61
INTERFACING STEPPER MOTOR WITH 8085
AIM:
To write on Assembly Language Program to interface a stepper motor with 8085 Microprocessor.
ALGORITHM:
1. Get the drive sequence using HL pointer.2. Initialize a counter for appropriate number of steps.3. Get the drive Sequence from memory to accumulator.4. Send the data to stepper motor.5. Call Delay.6. Get the next sequence to accumulator.7. Decrement the counter.8. Check zero flag. 9. If zero flag is reset go to step3 else go to step10.
10. Jump to step 1.
FLOW CHART:
62
PROGRAM:
Address Label Mnemonics Opcode Comments4100 Start LXI H, 4200H 21,00,42 Load the
immediate data 4200h to HL pointer.
4103 MVI C, 04H 0E, 04, Move the immediate data 04h to C register.
4105 Next MOV A, M JE Move the contents of M register to accumulator
4106 OUT C0H 03, C0 Out the data to the port with address C0h.
4108 LXI D, 1010H 11, 10, 10 Load DE register pair with immediate data 1010h
410B Delay DCX D 1B Decrement the contents of DE register pair by one.
410C MOV A, E 7B Move the contents of E register to accumulator.
410D ORA D B2 OR the contents of D register with that of accumulator.
410E JNZ Delay C2, 0B, 41 Jump on no zero to the address specified by label “Delay”
4111 INX H 23 Increment the
63
contents of HL pointer by one.
4112 DCR C 0D Decrement the contents of C register by one.
4113 JNZ Next C2, 05, 41 Jump on no zero to the address specified by label to “Next”.
4116 JMP Start C3, 00, 41 Jump unconditionally to the address specified by the label “Start”
RESULT:
Thus an assembly language program to interface stepper motor with 8085 processor was written. It was executed and the output was verified.
64
8086 EXPERIMENTS
ADDITION OF TWO 16 BIT NUMBERS – IMMEDIATE ADDRESSING
AIM:
To write an assembly language program to perform addition of two 16 bit numbers with immediate addressing and to execute it using 8086 microprocessor.
ALGORITHM:ADDITION OF TWO 8 BIT NUMBERS
Step1: Get the first number in accumulator.Step2: Get the second number in a register.Step3: Add the two numbers.Step4: Store the result in the memory specifiedStep5: Terminate the program execution
FLOW CHART:
65
MANUAL CALCULATION:
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written to perform addition of two 16 bit numbers by using immediate addressing mode. It was executed using 8086 processor and the output was verified.
67
ADDITION OF TWO 16 BIT NUMBERS – DIRECT ADDRESSING
AIM:
To write an assembly language program to perform addition of two 16 bit numbers with direct addressing and to execute it using 8086 microprocessor.
ALGORITHM:ADDITION OF TWO 8 BIT NUMBERS
Step1: Get the first number in accumulator.Step2: Get the second number in a register.Step3: Add the two numbers.Step4: Store the result in the memory specifiedStep5: Terminate the program execution
FLOW CHART:
68
MANUAL CALCULATION:
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written to perform addition of two 16 bit numbers by using immediate addressing mode. It was executed using 8086 processor and the output was verified.
ADDITION OF TWO 16 BIT NUMBERS – INDEXED ADDRESSING
70
AIM:
To write an assembly language program to perform addition of two 16 bit numbers with indexed addressing and to execute it using 8086 microprocessor.
ALGORITHM:ADDITION OF TWO 8 BIT NUMBERS
Step1: Get the first number in a register.Step2: Get the second number in accumulator.Step3: Add the two numbers.Step4: Store the result in the memory specifiedStep5: Terminate the program execution
FLOW CHART:
PROGRAM:
71
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written to perform addition of two 16 bit numbers by using indexed addressing mode. It was executed using 8086 processor and the output was verified.
COUNT THE NUMBER OF DATA IN A STRING
AIM:
73
To write an assembly language program to count the number of data in a string and to execute it using 8086 microprocessor.
ALGORITHM:ADDITION OF TWO 8 BIT NUMBERS
1. Initialize the memory location in to source register2. Load FFFFH to DX register3. Get the count value in to accumulator4. Increment the DX register content by one5. Move the content of SI in to AL register6. Compare AL with Ah register7. Jump on no zero, go to location specified in the instruction8. store the result in to memory location
FLOW CHART:
PROGRAM:
74
MEMORY ADDRESS
OPCODE MNEMONICS COMMENTS
1000 BE, 00, 12 MOV SI, 1200 Load memory location 1200H to SI1003 BA, FF, FF MOV DX, FFFF Load value FFFFH to DX register1006 B4, FF MOV AH, FF Load value FFH that specifies end
of count1008 42 INC DX Increment DX to reset its value1009 8A, 04 MOV AL, [SI] Move data pointed by SI register to
AL 100B 46 INC SI Increment SI register content100C 38, C4 CMP AH, AL Compare AL with AH register
content100E 75, F8 JNZ 1008 Jump on no zero to location ---------1010 89, 16, 00,
11MOV [1100], DX Move the count value in DX to
location 1100H1014 CC INT3 Call Break Point interrupt
MANUAL CALCULATION:
OUTPUT:
75
MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written to perform count the number of data in a string. It was executed using 8086 processor and the output was verified.
. SEARCHING A STRING IN A GIVEN ARRAY
AIM:
76
To write an assembly language program to searching a string in a given array and to execute it using 8086 microprocessor.
ALGORITHM:ADDITION OF TWO 8 BIT NUMBERS
1. Initialize the memory location in to source register2. Initialize the memory location in to destination register3. Get the count value in to CL and DL4. Compare DL with AL register5. Jump on zero, go to location specified in the instruction6. Decrement the CL register7. Increment the DX register content by one8. Jump on no zero, go to location specified in the instruction9. Move the content of Al in to DI register10.store the result in to memory location
FLOW CHART:
PROGRAM:
77
MEMORY ADDRESS
OPCODE MNEMONICS COMMENTS
1500 BF, 00, 13
MOV DI, 1300 Load memory location 1300H to DI for result
1503 BE, 00, 12
MOV SI, 1200 Load memory location 1200H to SI for storing data
1506 B1, 10 MOV CL, 10 Load count value 10H to CL register1508 B2, 01 MOV DL, 01 Load the string 01 to be searched
into DL 150A AC LODSB Loads byte at address DS:(E)SI into
AL150B 38, C2 CMP DL, AL Compares the contents of AL with
01H 150D 74, 05 JZ 1513 If zero flag is set jump to location
1513150F FE, C9 DEC CL Decrement CL register content1511 75, F7 JNZ 150A Jump to location 150A till count
value is non zero1513 88, 05 MOV [DI], AL Store the searched string 01H in AL
to DI pointed location 1300H1515 4E DEC SI Decrement memory location in SI1516 89, F3 MOV BX, SI Move location of occurrence of string
to BX register1518 47 INC DI Increment DI register value to 13011519 88, 1D MOV [DI], BL Move lower byte of location to DI151B 47 INC DI Increment DI register value to 1302151C 88, 3D MOV [DI], BH Move upper byte of location to DI151E CC INT3 Call Break Point interrupt
MANUAL CALCULATION:
78
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written to perform searching a string in a given array. It was executed using 8086 processor and the output was verified.
MOVE THE BLOCK OF DATA FROM ONE MEMORY LOCATION TO ANOTHER
AIM:
79
To write an assembly language program to move the block of data from one memory location to another and to execute it using 8086 microprocessor.
PROGRAM
MEMORY ADDRESS
OPCODE MNEMONICS COMMENTS
1000 B1, 08 MOV CL, 08 Load number of bytes to be moved to CL
1002 BE, 00, 14
MOV SI, 1200 Load address in SI for storing data
1005 BF, 50, 14
MOV DI, 1300 Load address in DI for storing result
1008 AC LODSB Loads byte at address DS:(E)SI into AL
1009 88, 05 MOV [DI], AL Store the result in specified location100B 47 INC DI Increment pointer location to 1301100C FE, C9 DEC CL Decrement count value loaded in CL100E 75, F8 JNZ 1008 Jump to location 1008 till count value
is non zero1010 CC INT3 Call Break Point interrupt
MANUAL CALCULATION:
80
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written move the block of data from one memory location to another. It was executed using 8086 processor and the output was verified.
8051 EXPERIMENTS
ADDITION OF TWO 16 BIT NUMBERS
81
AIM: To write an assembly language program to add two 16 bit numbers and to execute it using 8051 microprocessor
PROGRAM:
MEMORY ADDRESS
OPCODE LABEL MNEMONICS COMMENTS
4100 C3 CLR C Clear Carry flag C4101 74,34 MOV A, #34 Load lower byte first
operant to A4103 24,78 ADD A,#78 Add the lower byte
second operant with A content
4105 90,41,50 MOV DPTR,#4150 Load data pointer register (DPTR) with address 4150
4108 F0 MOV @DPTR,A Move the content of A to address pointed by DPTR
4109 A3 INC DPTR Increment DPTR content
410A 74,12 MOV A,#12 Load higher byte first operant to A
410C 34,56 ADDC A,#56 Add the higher byte second operant to content of A register with carry
410E F0 MOV @DPTR,A Move A register content to the address pointed by DPTR register
410F 80,FE HERE SJMP HERE Stop the execution
MANUAL CALCULATION:
82
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written for addition of two 16-bit numbers was executed using 8051 processor and the output was verified
. MULTIPLICATION OF TWO 8 – BIT NUMBERS
AIM:
83
To write an assembly language program to multiply two 8 bit numbers and to execute it using 8051 microprocessor
PROGRAM:
MEMORY ADDRESS
OPCODE LABEL MNEMONICS COMMENTS
4100 74,08 MOV A,#08 Load immediate value to Accumulator
4102 75,F0,04 MOV B, #04 Load immediate value to B register
4105 A4 MUL A,B Multiples the Accumulator by the B register. The least significant byte of the result is in Accumulator and the most-significant-byte is in B register
4106 90,45,00 MOV DPTR,#4500
Load memory location 4500 to DPTR register
4109 F0 MOVX @DPTR,A Accumulator is moved to the 16-bit External Memory address indicated by DPTR
410A A3 INC DPTR Increment DPTR content 410B E5,F0 MOV A,B Move most significant
byte of result to Accumulator
410D F0 MOVX @DPTR,A Accumulator is moved to the 16-bit External Memory address indicated by DPTR
410E 80,FE HERE SJMP HERE Stop the execution
MANUAL CALCULATION:
84
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written for multiplication of two 8-bit numbers was executed using 8051 processor and the output was verified.
DIVISION OF TWO 8 – BIT NUMBERS
AIM:
85
To write an assembly language program to Divide two 8 bit numbers and to execute it using 8051 microprocessor.
PROGRAM:MEMORY ADDRESS
OPCODE
LABEL MNEMONICS COMMENTS
4100 74,08 MOV A,#08 Load immediate value to Accumulator
4102 75,F0,04 MOV B, #04 Load immediate value to B register
4105 90 DIV A,B Divides the Accumulator by the B register. The resulting quotient is in Accumulator and the remainder in B register
4106 90,45,00 MOV DPTR,#4500 Load memory location 4500 to DPTR register
4109 F0 MOVX @DPTR,A Accumulator is moved to the 16-bit External Memory address indicated by DPTR
410A A3 INC DPTR Increment DPTR content
410B E5,F0 MOV A,B Move the remainder to Accumulator
410D F0 MOVX @DPTR,A Accumulator is moved to the 16-bit External Memory address indicated by DPTR
410E 80,FE HERE SJMP HERE Stop the execution
MANUAL CALCULATION:
86
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written for division of two 8-bit numbers was executed using 8051 processor and the output was verified.
SUM OF N – ELEMENTS IN AN ARRAY
AIM:
To write an assembly language program to find sum of N-elements in an array and to execute it using 8051 microprocessor.
87
PROGRAM:
MEMORY ADDRESS
OPCODE LABEL MNEMONICS COMMENTS
4100 90,42,00 MOV DPTR,#4200
Load location 4500 to DPTR
4103 E0 MOV A,@DPTR Load DPTR content to A4104 F8 MOV R0,A Move Accumulator to R04105 75,F0,00 MOV B,#0 Load B register with zero4108 A9,F0 MOV R1,B Move B register content to
R1410A C3 ADD CLR C Clear Carry flag C410B E0 MOV A,@DPTR Move content of DPTR to A410C E5,F0 ADD A,B Add Accumulator to B
register410E F5 MOV B,A Move Accumulator to B
register410F F0,50,01 JNC NC Jump to 4114 if Carry is not
set 4112 09 INC R1 Increment R1 register
content4113 A3 INC DPTR Increment DPTR content4114 D8,F4 NC DJNZ R0,ADD Decrement Register R0
and Jump if Not Zero to ADD
4116 90,45,00 MOV DPTR, #4500
Load DPTR with location 4500
4119 E9 MOV A,R1 Move R1 content to A411A F0 MOVX @DPTR,A Accumulator is moved to
the 16-bit External Memory address indicated by DPTR
411B A3 INC DPTR Increment DPTR content411C E5,F0 MOV A,B Move Accumulator to B
register411E F0 MOVX @DPTR,A Accumulator is moved to
the 16-bit External Memory address indicated by DPTR
411F 80,FE HERE SJMP HERE Stop the execution
MANUAL CALCULATION:
88
OUTPUT:MEMORY ADDRESS
INPUT VALUES MEMORY ADDRESS
OUTPUT VALUES
RESULT:
Thus an assembly language program was written for Sum of N-elements in an array was executed using 8051 processor and the output was verified.
LARGEST ELEMENT IN AN ARRAY
AIM:
To write an assembly language program to find the largest element in an array and to execute it using 8051 microprocessor.
PROGRAM:
89
MEMORY ADDRESS
OPCODE LABEL MNEMONICS COMMENTS
4100 90,42,00 MOV DPTR,#4200
Load location 4200 to DPTR
4103 75,40,00 MOV 40,#00 Load zero to memory 40H4106 7D,0A MOV R5,A Move Accumulator to R54105 75,F0,00 MOV B,#0 Load zero to B register4108 E0 LOOP2 MOVX A,@DPTR Accumulator is moved
to16 bit External Memory address indicated by DPTR
4109 B5,40,14 CJNE A,40 LOOP1
Compare A with contents of location 40H and Jump if Not Equal to LOOP1
410C A3 LOOP3 INC DPTR Increment DPTR content 410D DD,F9 DJNZ R5,LOOP2 Decrement Register R5
and Jump if Not Zero to LOOP2
410F E5,40 MOV A,40 Move value in location 40H to Accumulator
4111 F0 MOVX @DPTR,A Accumulator is moved to16 bit External Memory address indicated by DPTR
4112 80,FE HLT SJMP HLT Stop the execution4114 40,F6 LOOP1 JC LOOP3 Jump if Carry Set to
LOOP34116 F5,40 MOV 40,A Move A to location 40H4118 F2 SJMP LOOP2 Perform short jump to
location LOOP2
MANUAL CALCULATION:
90