EE0310-Microprocessor & Microcontroller Lab LABORATORY MANUAL EE0310 – MICROPROCESSOR & MICROCONTROLLER LAB DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING FACULTY OF ENGINEERING & TECHNOLOGY SRM UNIVERSITY, Kattankulathur – 603 203 1 EE0310-Microprocessor & Microcontroller Lab LIST OF EXEPRIMENTS Sl.No. 1 2 Name of the Experiments Induction to 8085 Microprocessor a) Addition of 2 - 8 bit numbers b) Subtraction of 2 - 8 bit numbers 3 a) Addition of 2 - 16 bit numbers b) Subtraction of 2 – 16 bit numbers 4 a) Multiplication of 2 - 8 numbers b) Division of 2 - 8 bit numbers 5 a) Ascending order b) Descending order 6 a) Fibonaci Series b) Sum of finite series 7 8 Factorial of Given Numbers a) Multiplication of 2 - 16 bit numbers b) Division of 2 - 16 bit numbers 9 a) Binary to BCD code conversions b) BCD to Binary code conversions 10 a) Rolling Display b) Flashing Display 11 Stepper motor rotate forward and reverse direction 12 Digital analog conversion 13 Analog digital conversion 14 Microcontroller a) Addition b) Subtraction c) Multiplication d) Division 2 Page No. EE0310-Microprocessor & Microcontroller Lab INTRODUCTION TO MICROPROCESSOR 8085 Aim To study the microprocessor 8085 Architecture of 8085 Microprocessor a) General purpose register It is an 8 bit register i.e. B,C,D,E,H,L. The combination of 8 bit register is known as register pair, which can hold 16 bit data. The HL pair is used to act as memory pointer is accessible to program. b) Accumulator It is an 8 bit register which hold one of the data to be processed by ALU and stored the result of the operation. c) Program counter (PC) It is a 16 bit pointer which maintain the address of a byte entered to line stack. d) Stack pointer (Sp) It is a 16 bit special purpose register which is used to hold line memory address for line next instruction to be executed. e) Arithmetic and logical unit It carries out arithmetic and logical operation by 8 bit address it uses the accumulator content as input the ALU result is stored back into accumulator. f) Temporary register It is an 8 bit register associated with ALU hold data, entering an operation, used by the microprocessor and not accessible to programs. g) Flags Flag register is a group of fire, individual flip flops line content of line flag register will change after execution of arithmetic and logic operation. The line states flags are i) Carry flag (C) ii) Parity flag (P) iii) Zero flag (Z) iv) Auxiliary carry flag (AC) v) Sign flag (S) h) Timing and control unit Synchronous all microprocessor, operation with the clock and generator and control signal from it necessary to communicate between controller and peripherals. i) Instruction register and decoder Instruction is fetched from line memory and stored in line instruction register decoder the stored information. j) Register Array These are used to store 8 bit data during execution of some instruction. 3 EE0310-Microprocessor & Microcontroller Lab PIN Description Address Bus 1. The pins Ao – A15 denote the address bus. 2. They are used for most significant bit Address / Data Bus 1. AD0 – AD7 constitutes the address / Data bus 2. These pins are used for least significant bit ALE : (Address Latch Enable) 1. The signal goes high during the first clock cycle and enables the lower order address bits. IO / M 1. 2. This distinguishes whether the address is for memory or input. When this pins go high, the address is for an I/O device. S0 – S1 S0 and S1 are status signal which provides different status and functions. RD 1. 2. This is an active low signal This signal is used to control READ operation of the microprocessor. WR 1. 2. WR is also an active low signal Controls the write operation of the microprocessor. HOLD 1. This indicates if any other device is requesting the use of address and data bus. HLDA 1. 2. HLDA is the acknowledgement signal for HOLD It indicates whether the hold signal is received or not. INTR 1. 2. INTE is an interrupt request signal IT can be enabled or disabled by using software INTA 1. 2. Whenever the microprocessor receives interrupt signal It has to be acknowledged. RST 5.5, 6.5, 7.5 1. These are nothing but the restart interrupts 2. They insert an internal restart junction automatically. 4 EE0310-Microprocessor & Microcontroller Lab TRAP 1. 2. Trap is the only non-maskable interrupt It cannot be enabled (or) disabled using program. RESET IN 1. This pin resets the program counter to 0 to 1 and results interrupt enable and HLDA flip flops. X1, X2 These are the terminals which are connected to external oscillator to produce the necessary and suitable clock operation. SID This pin provides serial input data SOD This pin provides serial output data VCC and VSS 1. VCC is +5V supply pin 2. VSS is ground pin Specifications 1. Processors Intel 8085 at E144 MHz clock 2. Memory Monitor RAM: 0000 – IFFF EPROM Expansion: 2000 – 3FFF’s 0000 – FFF System RAM: 4000 – 5FFF Monitor data area 4100 – 5FFF RAM Expansion 6000 – BFFF 3. Input / Output Parallel: A8 TTL input timer with 2 number of 32-55 only input timer available in -85 EBI. Serial: Only one number RS 232-C, Compatible, crucial interface using 8281A Timer: 3 channel -16 bit programmable units, using 8253 channel ‘0’ used for no band late. Clock generator. Channel ‘1’ is used for single stopping used program. Display: 6 digit – 7 segment LED display with filter 4 digit for adder display and 2 digit for data display. Key board: 21 keys, soft keyboard including common keys and hexa decimal keys. RES: Reset keys allow to terminate any present activity and retain to - 85 its on initialize state. 5 EE0310-Microprocessor & Microcontroller Lab INT: Maskable interrupt connect to CPU’s RST 7.5 interrupt DEC: Decrement the adder by 1 EXEC: Execute line particular value after selecting address through go command. NEXT: Increment the address by 1 and then display its content. Key Functions: E 0 SUB RD 1 i. Hex entry key ‘0’ ii. Substituting memory content where “next” key is paused immediately after 1, take used to st cutting address. iii. Register key ‘E’ i) ii) Hex code entry (1) Register key ‘D’ i) ii) iii) Hex code entry ‘2’ Retricre data from data ‘memory’ to data top Register key ‘C’ i) ii) iii) Hex code entry ‘3’ Retricre data from memory to top Register key ‘B’ i) ii) iii) Hex key entry ‘C’ Block search from byte Register key ‘F’ i) ii) iii) Hex key entry ‘5’ Fill block of RAM memory with desired data Register key ‘A’ i) ii) iii) Hex key entry ‘6’ TN/Tl used for sending (or) receiving Register key ‘H’ i) ii) Hex key entry ‘7’ Register key ‘H’ REG C 2 TN B 3 TR F 4 BLOC A 5 FILL L 6 SER H 7 F2 6 EE0310-Microprocessor & Microcontroller Lab i) ii) Register key ‘S’ Register key ‘I’ SNG i) ii) iii) Hex key entry ‘A’ Function key F3 Register key “ph” PH i) ii) Hex key entry “y” Signal step program (instruction by instruction) i) ii) iii) Hex key entry “c” Much a block of memory from a linear block Register key “SH” i) ii) Hex key D Compare 2 memory block i) ii) iii) Hex key entry ‘B’ Check a block from flame Register key “SPL” i) ii) Hex key ‘E’ Insert by test into memory (RAM) i) ii) Hex key ‘F’ Delete byte from memory RAM I 8 G0 PL 9 A F3 C SH MOV D CMP B SL BC E INS F DEL System Power Consumption Micro BSEB2 +5V @ 1Amp +12V @ 200 mA - 12V @ 100 mA MICRO SSEB +5V@ 800 mA 7 EE0310-Microprocessor & Microcontroller Lab Power Supply Specification MICRO SSEM 230V, AC @ 80 Hz +5V @ 600 mA Key Function 8 EE0310-Microprocessor & Microcontroller Lab IC’s Used 8085 8253 8255 8279 8251 2764 6264 7414 7432 7409 7400 7404 74373 74139 74138 - 8 bit p programmable internal timer programmable peripheral interface programmable key boards / display interface programmable communication interface 8 KV VV EPROM 8K STATIC PROM Hex inverter Quad 21/p OR GATE Quad 21/p AND GATE NAND Gate Dual D-FF Octal ‘D’ Latch Dual 2 to 4 line decoder 3 to 8 line decoder 9 EE0310-Microprocessor & Microcontroller Lab In Enter Program into Trainer Kit 1. 2. 3. 4. 5. 6. 7. 8. Press ‘RESET’ key Sub (key processor represent address field) Enter the address (16 bit) and digit in hex Press ‘NEXT’ key Enter the data Again press “NEXT” Again after taking the program, are use HLT instruction its Hex code Press “NEXT” How to executive program 1. Press “RESET” 2. Press “GO” 3. Enter the address location in which line program was executed 4. Press “Execute” key Result: Thus 8085 microprocessor was studied successfully. 10 EE0310-Microprocessor & Microcontroller Lab ADDITION OF TWO 8-BIT NUMBERS Aim: To write an assembly language for adding two 8 bit numbers by using micro processor kit. Apparatus required: 8085 micro processor kit (0-5V) DC battery Algorithm: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10 Step 11 Step 12 : : : : : : : : : : : : Start the microprocessor Intialize the carry as ‘Zero’ Load the first 8 bit data into the accumulator Copy the contents of accumulator into the register ‘B’ Load the second 8 bit data into the accumulator. Add the 2 - 8 bit datas and check for carry. Jump on if no carry Increment carry if there is Store the added request in accumulator More the carry value to accumulator Store the carry value in accumulator Stop the program execution. 11 EE0310-Microprocessor & Microcontroller Lab START Intialise the carry as zero Load the 1st 8 bit number Transfer the 1st number to register ‘B’ Load the 2nd 8 bit number Transfer and Add the contents of A and B No Check for carry? Yes Increment carry by one Store the added value in accumulator Move the contents of carry into accumulator Store the value of carry in accumulator END 12 EE0310-Microprocessor & Microcontroller Lab Address 4100 4102 4105 Mnemonics MVI C,00 LDA 4300 MOV, B,A Hex Code OE, 00 3A, (00, 43) 47 4106 LDA 4301 3A, (01, 43) 4109 410A 410D ADD B JNC INR C 80 D2, 0E, 41 OC STA 4302 32 (02, 43) 4111 MOV A,C 79 4112 STA 4303 32 (03, 43) 4115 HLT 76 410E Label Loop Comments Initialize the carry as zero Load the first 8 bit data Copy the value of 8 bit data into register B Load the second 8 bit data into the accumulator Add the hoo values Jump on if no carry If carry is there increment it by one Stone the added value in the accumulator More the value of carry to the accumulator from register C Store the value of carry in the accumulator Stop the program execution Input Without carry Input Address 4300 4301 Value 04 02 Output Address 4302 4303 Value 06 00 (carry) Input Address 4300 4301 Value FF FF Output Address 4302 4303 Value FE 01 (carry) Output With carry Calculation (1) 1111 1111 1111 1111 --------------1111 1110 ========= F E Result: The assembly language program for 8 bit addition of two numbers was executed successfully by using 8085 micro processing kit. 13 EE0310-Microprocessor & Microcontroller Lab SUBTRACTION OF TWO 8 BIT NUMBERS Aim: To write a assembly language program for subtracting 2 bit (8) numbers by using8085 micro processor kit. Apparatus required: 8085 micro processor kit (0-5V) DC battery Algorithm: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10 Step 11 Step 12 Step 13 : : : : : : : : : : : : : Start the microprocessor Intialize the carry as ‘Zero’ Load the first 8 bit data into the accumulator Copy the contents of contents into the register ‘B’ Load the second 8 bit data into the accumulator. Subtract the 2 8 bit datas and check for borrow. Jump on if no borrow Increment borrow if there is 2’s compliment of accumulator is found out Store the result in the accumulator More the borrow value from ‘c’ to accumulator Store the borrow value in the accumulator Stop program execution 14 EE0310-Microprocessor & Microcontroller Lab START Intialise the borrow as zero Load the 1st 8 bit number Move the 1st 8 bit data to register ‘B’ Load the 2nd 8 bit number Subtract the two values No Check for carry? Yes Increment carry by one 1’s compliment of 2nd value Add 1 to 1’s compliment for 2’s compliment Store the value of result in accumulator Move the carry into the accumulator Store the value of carry in accumulator END 15 EE0310-Microprocessor & Microcontroller Lab Address 4100 4102 Label Mnemonics MVI C,00 LDA 4300 Hex Code OE, 00 3A, (00, 43) MOV, B,A LDA 4301 47 3A, (01, 43) SUB B INC INR C 90 D2, 0E, 41 OC CMA ADI, 01 2F 6, 01 4111 4114 STA 4302 MOV A,C 32,02,43 79 4115 4118 STA 4303 HLT 32,03,43 76 4105 4106 4109 410A 410D 410E 410F Loop Loop Comments Initialize the carry as zero Load the first 8 bit data into the accumulator Copy the value into register ‘B’ Load the 2nd 8 bit data into the accumulator Subtract both the values Jump on if no borrow If borrow is there, increment it by one Compliment of 2nd data Add one to 1’s compliment of 2nd data Store the result in accumulator Moul the value of borrow into the accumulator Store the result in accumulator Stop Program execution Input Without borrow Input Address 4300 4301 Value 05 07 Output Address 4302 4303 Value 02 00 (borrow) Input Address 4300 4301 Value 07 05 Output Address 4302 4303 Value 02 01 (borrow) Output With carry borrow Calculation CMA ADJ 0.1 05 - 05 – 07 07 – 0111 1000 0001 -----1001 0101 -----1110 (-2) 16 EE0310-Microprocessor & Microcontroller Lab Result: The assembly language program subtraction of two 8 bit numbers was executed successfully by using 8085 micro processing kit. 17 EE0310-Microprocessor & Microcontroller Lab ADDITION OF TWO 16 – BIT NUMBERS Aim: To write an assembly language program for adding two 16 bit numbers using 8085 micro processor kit. Apparatus required: 8085 micro processor kit (0-5V) DC battery Algorithm: Step 1 Step 2 : : Step 3 Step 4 : : Step 5 Step 6 Step 7 Step 8 Step 9 : : : : : Step 10 Step 11 Step 12 : : : Start the microprocessor Get the 1st 8 bit in ‘C’ register (LSB) and 2nd 8 bit in ‘H’ register (MSB) of 16 bit number. Save the 1st 16 bit in ‘DE’ register pair Similarly get the 2nd 16 bit number and store it in ‘HL’ register pair. Get the lower byte of 1st number into ‘L’ register Add it with lower byte of 2nd number tore the result in ‘L’ register Get the higher byte of 1st number into accumulator Add it with higher byte of 2nd number and carry of the lower bit addition. Store the result in ‘H’ register Store 16 bit addition value in ‘HL’ register pair Stop program execution 18 EE0310-Microprocessor & Microcontroller Lab START C = 00H Load ‘HL’ with 1st Data Transfer HL - DE Load ‘HL’ with 2nd Data DE + HL = HL If Cy =0 C = C + 01 Store ‘HL’ in memory (SUM) Transfer C - A Store ‘A’ in memory (Cy) STOP 19 EE0310-Microprocessor & Microcontroller Lab Address 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 Label Mnemonics MVI C,00 LHLD XCHG LHLD 4802 DAD D JNC Ahead 450E 450A 450B 450C 450D 450E 450F 4510 4511 4512 4513 4514 4515 AHEAD 4800 INR SHLD C 4804 MOV STA C,A 4806 HLT Input Without Input Address 4800 4801 4802 4803 Value 01 (addend) 04 02 (augend) 03 (augend) Output Address 4804 4805 4806 Value 03 (sum) 07 (sum) 00 (carry) Output Calculation 0000 0100 0000 0001 0000 0011 0000 0010 --------------------------------0000 0111 0000 0011 0 7 0 3 20 Hex Code 0E 00 2A 00 48 EB 2A 02 48 19 D2 0E 45 0C 22 04 48 79 32 06 48 76 Comments C = 00H HL – 1st No. HL – DE HL – 2nd No. Double addition DE + HL If Cy = 0, G0 to 450E C = C + 01 HL – 4804 (sum) Cy – A Cy – 4806 Stop excution EE0310-Microprocessor & Microcontroller Lab With carry Calculation Input Address 4800 4801 4802 4803 Value FF (addend) DE (addend) 96 (augend) DF (augend) Output Address 4804 4805 4806 Value 95 (sum) BE (sum) 01 (carry) 1101 1110 1111 1111 1101 1111 1001 0101 --------------------------------1011 1110 1001 0101 B E 9 5 Result: The assembly language program for addition of two 16 bit numbers was executed using 8085 micro processing kit. 21 EE0310-Microprocessor & Microcontroller Lab SUBTRACTION OF TWO 16 – BIT NUMBERS Aim: To write an assembly language program for subtracting two 16 bit numbers using 8085 microprocessor kit. Apparatus required: 8085 microprocessor kit (0-5V) DC battery Algorithm: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 : : : : : : Step 7 Step 8 Step 9 : : : Step 10 Step 11 : : Start the microprocessor Get the 1st 16 bit in ‘HL’ register pair Save the 1st 16 bit in ‘DE’ register pair Get the 2nd 16 bit number in ‘HL’ register pair Get the lower byte of 1st number Get the subtracted value of 2nd number of lower byte by subtracting it with lower byte of 1st number Store the result in ‘L’ register Get the higher byte of 2nd number Subtract the higher byte of 1st number from 2nd number with borrow Store the result in ‘HL’ register Stop the program execution 22 EE0310-Microprocessor & Microcontroller Lab START C = 00H Load ‘HL’ with 1st Data Transfer HL - DE Load ‘HL’ with 2nd Data Transfer E – A (LSB) A = A – L (LSB) Store ‘A’ in memory (LSB) Transfer D – A (MSB) A – A – H – Borrow (MSB) Store ‘A’ in memory (MSB) STOP 23 EE0310-Microprocessor & Microcontroller Lab Address 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 450A 450B 450C 450D 450E 450F 4510 4511 4512 4513 Label Mnemonics MVI C,00 LHLD 4800 XLHG LHLD 4802 MOV SUB STA A,E L 4804 MOV SBB STA A,D H 4805 HLT Input Without borrow Input Address 4800 4801 4802 4803 Value 07 08 05 06 Output Address 4804 4805 4807 Value 02 02 00 Output 24 Hex Code 0E 00 2A 00 48 EB 2A 02 48 7B 95 32 04 48 7A 9C 32 05 48 76 Comments C = 00H L – 1st No. HL – DE HL – 2nd No. LSB of ‘1’ to ‘A’ A–A–L A – memory MSB of 1 to A A- A – H A – memory Stop execution EE0310-Microprocessor & Microcontroller Lab With borrow Calculation 05 06 - Input Address 4800 4801 4802 4803 Value 05 06 07 08 Output Address 4804 4805 4806 Value 02 02 01 07 05 06 CMA ADI 0101 0110 1010 1001 0000 0001 --------------1010 1010 05 + 06 (1) 08 07 08 CMA ACI 0111 1000 1000 0111 0000 0001 -------------1000 1000 07 08 1010 1010 1000 1000 --------------0010 0010 02 02 Result: The assembly language program for subtraction of two 16 bit numbers was executed by using 8085 micro processing kit. 25 EE0310-Microprocessor & Microcontroller Lab MULTIPLICATION OF TWO 8 – BIT NUMBERS Aim: To write an assembly language for multiplying two 8 bit numbers by using 8085 micro processor kit. Apparatus required: 8085 microprocessor kit (0-5V) DC battery Algorithm: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10 Step 11 : : : : : : : : : : : Step 12 Step 13 Step 14 : : : Start the microprocessor Get the 1st 8 bit numbers Move the 1st 8it number to register ‘B’ Get the 2nd 8 bit number Move the 2nd 8 bit number to register ‘C’ Intialise the accumulator as zero Intialise the carry as zero Add both register ‘B’ value as accumulator Jump on if no carry Increment carry by 1 if there is Decrement the 2nd value and repeat from step 8, till the 2nd value becomes zero. Store the multiplied value in accumulator Move the carry value to accumulator Store the carry value in accumulator 26 EE0310-Microprocessor & Microcontroller Lab START Get the 1st 8 bit number Move it to register ‘B’ Get the 2nd 8 bit number Intialize the accumulator as zero & carry as zero Add the accumulator with 1st number No Check for carry? Yes Increment carry Decrement 2nd number No 2nd Number Yes Store the value f carry in accumulator END 27 EE0310-Microprocessor & Microcontroller Lab Address 4100 4103 Label Mnemonics LDA 4500 MOV B,A Hex Code 3A, 00, 45 47 4104 4107 LDA 4501 MOV C,A 3A, 01, 45 4F 4108 MVI A, 00 3E, 00 410A 410C MVI D, 00 ADD B 16, 00 80 410D 4110 4111 4112 4115 INC INR D DCR C JNZ STA 4502 D2 11, 41 14 OD C2 0C, 41 32 02, 45 4118 MOV A,D 7A 4119 STA 4503 32,03,45 411C HLT 76 Comments Load the first 8 bit number Move the 1st 8 bit data to register ‘B’ Load the 2nd 16 it number Move the 2nd 8 bit data to register ‘C’ Intialise the accumulator as zero Intialise the carry as zero Add the contents of ‘B’ and accumulator Jump if no carry Increment carry if there is Decrement the value ‘C’ Jump if number zero Store the result in accumulator Move the carry into accumulator Store the result in accumulator Stop the program execution Input Input Address 4500 4501 Value 04 02 Output Address 4502 4503 Value 08 00 Output Result: The assembly language program for multiplication of two 8 bit numbers was executed using 8085 micro processing kit. 28 EE0310-Microprocessor & Microcontroller Lab DIVISION OF TWO 8 – BIT NUMBERS Aim: To write an assembly language program for dividing two 8 bit numbers using microprocessor kit. Apparatus required: 8085 microprocessor kit (0-5V) DC battery Algorithm: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10 Step 11 Step 12 Step 13 Step 14 : : : : : : : : : : : : : : Start the microprocessor Intialise the Quotient as zero Load the 1st 8 bit data Copy the contents of accumulator into register ‘B’ Load the 2nd 8 bit data Compare both the values Jump if divisor is greater than dividend Subtract the dividend value by divisor value Increment Quotient Jump to step 7, till the dividend becomes zero Store the result (Quotient) value in accumulator Move the remainder value to accumulator Store the result in accumulator Stop the program execution 29 EE0310-Microprocessor & Microcontroller Lab START Get the divided Intialise the Quotient as zero Get the divisor Compare the dividend & divisor Add the accumulator with 1st number No Check for carry? Increment carry Decrement 2nd number Dividend Yes Store the Quotient in accumulator Move the remainder to accumulator Store the remainder in accumulator END 30 EE0310-Microprocessor & Microcontroller Lab Address 4100 4102 4105 Label Mnemonics MVI C, 00 LDA, 4500 MOV B,A Hex Code 0E, 00 3A 00, 45 47 LDA, 4501 CMP B JC (LDP) 3A 01, 45 B8 DA 12,41 SUB B 90 INR C JMP (LDP, 41) 0C C3, 0D, 41 STA 4502 32 02,45 4115 MOV A,C 79 4116 STA 4503 32 03,45 4119 HLT 76 4106 4109 410A 410D Loop 2 410E 410F 4112 Loop 1 Input Input Address 4500 4501 Value 09 02 Output Address 4502 4503 Value 04 (quotient) 01 (reminder) Output Quotient Carry 1001 0010 – I -----0111 0010 – II -----0101 0010 – III -----0011 0010 – IV -----0001 – carry - 04 - 01 31 Comments Intialise Quotient as zero Get the 1st data Copy the 1st data into register ‘B’ Get the 2nd data Compare the 2 values Jump if dividend lesser than divisor Subtract the 1st value by 2nd value Increment Quotient (410D) Jump to Loop 1 till the value of dividend becomes zero Store the value in accumulator Move the value of remainder to accumulator Store the remainder value in accumulator Stop the program execution EE0310-Microprocessor & Microcontroller Lab Result: The assembly language program for division of two 8 bit numbers was executed using 8085 micro processing kit. 32 EE0310-Microprocessor & Microcontroller Lab ASCENDING ORDER Aim: To write a program to sort given ‘n’ numbers in ascending order Apparatus required: 8085 microprocessor kit (0-5V) DC battery Algorithm: Step 1 Step 2 : : Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 : : : : : : Step 9 Step 10 Step 11 Step 12 : : : : Start the microprocessor Accumulator is loaded with number of values to sorted and it is saved Decrement 8 register (N-1) Repetitions) Set ‘HL’ register pair as data array Set ‘C’ register as counter for (N-1) repetitions Load a data of the array in accumulator Compare the data pointed in ‘HL’ pair If the value of accumulator is smaller than memory, then jump to step 10. Otherwise exchange the contents of ‘HL’ pair and accumulator Decrement ‘C’ register, if the of ‘C’ is not zero go to step 6 Decrement ‘B’ register, if value of ‘B’ is not zero, go step 3 Stop the program execution 33 EE0310-Microprocessor & Microcontroller Lab START Load the count value in accumulator and save it in register ‘B’ Decrement ‘B’ register (N-1) Load the starting address of array in ‘HL’ Decrement ‘C’ register of array in ‘HL’ Increment the data pointer Compare the data pointed by ‘HL’ with ‘A’ Compare the datas A<M No Yes C=0? Increment carry by one No Yes Decrement register ‘B’ No B=0? END 34 Exchange the contents of memory pointer by ‘HL’ EE0310-Microprocessor & Microcontroller Lab Address 4100 4103 4104 4105 4108 4109 410A 410B 410C 410D Mnemonics LDA 4500 MOV B,A DCR B LXI H, 4500 MOV C,M DCR C INX H MOV A,M INX H CMP M Hex Code 3A, 00,45 47 05 21, 00,45 4E 0D 23 7E 23 BE 410E JC DA, 16, 41 4111 MOV D,M 56 4112 4113 MOV M,A DCX H 77 2B 4114 MOV M,D 72 INX H DCR C JNZ Loop 1 DCR B JNZ Loop 2 HLT 23 0D C2, 0B, 41 05 C2, 05, 41 76 4115 4116 4117 411A 411B 411E Label Loop 3 Loop 2 Loop 1 Comments Load the number of values Move it ‘B’ register For (N-1) comparisons Set the pointer for array Count for (N-1) comparisons For (N-1) comparisons Increment pointer Get one data in array ‘A’ Increment pointer Compare next with accumulator If content less memory go ahead If it is greater than interchange it Memory content Exchange the content of memory pointed by ‘HL’ by previous location One in by ‘HL’ and previous location Increment pointer Decrement ‘C’ register Repeat until ‘C’ is zero Decrement in ‘B’ values Repeat till ‘B’ is zero Stop the program execution Input Input Address 4500 4501 4502 4503 4504 Value 04 AB BC 01 0A Output Address 4500 4501 4502 4503 4504 Value 04 01 0A AB BC Output Address & Value Result: The assembly language program for sorting numbers in ascending order was executed by microprocessor kit. 35 EE0310-Microprocessor & Microcontroller Lab DESCENDING ORDER Aim: To write a program to sort given ‘n’ numbers in descending order Apparatus required: 8085 microprocessor kit (0-5V) DC battery Algorithm: Step 1 Step 2 : : Step 3 Step 4 : : Step 5 Step 6 Step 7 Step 8 : : : : Step 9 : Step 10 : Step 11 : Step 12 : Start the microprocessor Load the number of values into accumulator and save the number of values in register ‘B’ Decrement register ‘B’ for (N-1) Repetitions Set ‘HL’ register pair as data array address pointer and load the data of array in accumulator Set ‘C’ register as counter for (N-1) repetitions Increment ‘HL’ pair (data address pointer) Compare the data pointed by ‘HL’ with accumulator If the value of accumulator is larger than memory, then jump to step 10, otherwise next step. Exchange the contents of memory pointed by ‘HL’ and accumulator Decrement ‘C’ register, if the of ‘C’ is not zero go to step 6, otherwise next step. Decrement ‘B’ register, if ‘B’ is not zero, go step 3, otherwise next step. Stop the program execution 36 EE0310-Microprocessor & Microcontroller Lab START Load the count value to accumulator Save the value in ‘B’ register Decrement ‘B’ register (N-1) Load the starting address of data array in ‘HL’ pair Using data pointer, load the count value in ‘C’ Decrement ‘C’ register (counter for N-1) Increment the data pointer ‘HL’ with ‘A’ Compare the data pointed at ‘HL’ with ‘A’ A<M No Exchange the contents C=0? Decrement register C Yes Decrement register ‘C’ Decrement No B=0? No END Yes 37 EE0310-Microprocessor & Microcontroller Lab Address 4100 Mnemonics LDA 4500 Hex Code 3A, 00,45 MOV B,A DCR B LXI H, 4500 MOV C,M DCR C INX H MOV A,M INX H CMP M ICE, Loop 1 47 05 21, 00,45 4E 0D 23 7E 23 BE D2, 16,41 4111 MOV D,M 56 4112 MOV M,A 77 4113 4114 DCX H MOV M,D 2B 72 4115 4116 4117 411A 411B INX H DCR C JNZ Loop 2 DCR B JNZ Loop 3 23 0D C2, 0B, 41 05 C2, 05, 41 HLT 76 4103 4104 4105 4108 4109 410A 410B 410C 410D 410E Label Loop 3 Loop 2 Loop 1 411E Comments Load the number of values in accumulator Move it to ‘B’ register For (N-1) comparisons Set the pointer for array Count for (N-1) comparisons For (N-1) comparisons Increment pointer Get one data from array Increment pointer Compare next with number If content ‘A’ is greater than content of ‘HL’ pair If it is greater than interchange the datas Accumulator to memory value Decrement memory pointer Move the old to ‘HL’ and previous location Increment pointer Decrement ‘C’ register Repeat till ‘C’ is zero Decrement in ‘B’ values Jump to loop till the value of ‘B’ be Stop the program execution Input Input Address 4500 4501 4502 4503 4504 Value 04 AB BC 01 0A Output Address 4500 4501 4502 4503 4504 Value 04 BC AB 0A 01 Output Address & Value Result: The assembly language program for sorting ‘4’ numbers in descending order was executed successfully using microprocessor kit. 38 EE0310-Microprocessor & Microcontroller Lab SUM OF DATAS Aim: To write an assembly language program to calculate the sum of datas using 8085 microprocessor kit. Apparatus required: 8085 microprocessor kit (0-5V) DC battery Algorithm: Step 1 Step 2 : : Step 3 Step 4 Step 5 : : : Step 6 Step 7 Step 8 Step 9 Step 10 Step 11 Step 12 Step 13 : : : : : : : : Start the microprocessor Load the number of values in series in accumulator and move it to register C and load the starting address of array Intialize the value of A as ‘00’ Move the value of ‘A’ to ‘B’ register Add the content of accumulator with the data pointed by ‘HL’ pair If there exists a carry, increment ‘B’ by 1, if not continue Increment the pointer to next data Decrement the value of ‘C’ by 1, which is used as counter If ‘C’ is equal to zero, go to step 10 if not go to step 5. Store the value of ‘A’ to memory, it shows the result Move the content of B to A Store the value of A to memory Stop the program 39 EE0310-Microprocessor & Microcontroller Lab START Load the number of values in ‘A’ Move it to register ‘C’ Load the starting value of array Move the value from A to B Add the accumulator date with memory No Check for carry? Yes Increment ‘B’ register Decrement ‘C’ register by 1 Is C=0? Store the result in accumulator Move the value from B to A Store the value in A END 40 EE0310-Microprocessor & Microcontroller Lab Address 4100 Mnemonics LDA 4200 Hex Code 3A 00,42 4103 4104 MOV B,A LXI H, 4201 4F 21,01,42 4107 4108 4109 Loop SUB A MOV B,A ADD M 97 47 86 Skip JNC Skip INR B INX H D2, 0E, 41 04 23 410F 4110 4113 DCR C JNZ Loop STA 4400 0D C2, 09, 41 32,00,44 4116 MOV A,B 78 4117 411A STA 4401 HLT 32,01,44 76 410A 410D 410E Label Input Input Address 4200 4201 4202 4203 4204 Value 04 07 09 03 04 Output Address 4400 4401 Value 17 00 Output 07 + 09 + 03 + 04 = 23 = 17 (in Hexa decimal) (0F + 8 = 233) 0F 08 = = 0000 1111 0000 1000 --------------0001 0111 1 7 41 Comments Load the accumulator with number of values Move it from A to C Load the starting address of data array Intialise ‘A’ as 00 Intialise ‘B’ as 00 Add the previous sum with next data Jump on if no carry Increment carry by one Increment pointer for next data Decrement ‘C’ by one Jump if not zero Store the sum in accumulator Move the value of carry to A from B Store the carry in memory End of program EE0310-Microprocessor & Microcontroller Lab Result: The assembly language program for sum of datas was executed successfully using 8085 microprocessor kit. 42 EE0310-Microprocessor & Microcontroller Lab FACTORIAL OF 8 BIT NUMBER Aim: To write an program to calculate the factorial of a number (between 0 to 8) Apparatus required: 8085 microprocessor kit (0-5V) power supply Algorithm: Step 1 Step 2 Step 3 : : : Step 4 Step 5 Step 6 : : : Step 7 Step 8 Step 9 Step 10 : : : : Memory address 4250 4251 Intialize the stack pointer Get the number in accumulator Check for if the number is greater than 1. If no store the result otherwise go to next step. Load the counter and initialize result Now factorial program in sub-routine is called. In factorial, initialize HL RP with 0. Move the count value to B Add HL content with Rp. Decrement count (for multiplication) Exchange content of Rp (DE) with HL. Decrement counter (for factorial) till zero flag is set. Store the result Hault Content 05 (12010) 43 EE0310-Microprocessor & Microcontroller Lab START Intialize stack pointer Get the number If Number < 2 ? Result = 1 Load counter Initialize result CALL facto END 44 EE0310-Microprocessor & Microcontroller Lab Facto Result = Result X no No = No -1 No If No = 0 ? Yes RET 45 EE0310-Microprocessor & Microcontroller Lab Memory Location 4200 4201 4202 4203 4204 Hex Code 4205 4206 4207 4208 4209 420A 420B DA 17 42 5F 16 00 3D 420C Label 3A 50 42 FE 02 Mnemonics Op code Operand LDA 4250 CPI 02H JC Loop 1 MOV MVI E,A D,00 DCR A 4F MOV C,A 420D 420E 420F 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 421A 421B 421C 421D Sub Routine 4600 4601 4602 4603 CD 00 46 EB 22 51 42 C3 1D 42 21 00 01 22 51 42 76 CALL Facto Loop 1 XCHG SHLD 4251 JMP Loop 3 LXI H,0001H SHLD 4251 Loop 3 HLT 21 00 00 41 Facto LXI H,0000 MOV B,C 4604 19 Loop 2 DAD D 4605 4606 4607 4608 05 C2 04 46 DCR JNZ B Loop 2 46 Comments Get the number accumulator in Compare data with 2 and check it is greater than 1 If cy =1 jump to loop 1 If cy = 0 proceed Move content of A to E Load this term as a result Decrement accumulator by 1 Move ‘A’ content to ‘C’ (counter 1 less than A) Call sub routine programe Facto Exchange (DE) – (HL) Store content of HL in specified memory location Jump to Loop 3 HL is loaded with data 01 Store the memory result in Terminate the program Initialize HL pair Content of ‘C’ is moved to B Content of DE is added with HL ‘B’ is decremented Multiply by successive addition till zero flag is set EE0310-Microprocessor & Microcontroller Lab 4609 460A EB 0D XCHG DCR C 460B 460C 460D 460E C4 00 46 C9 CNZ Facto RET Memory address 4250 4251 [DE] – [HL] Decrement counter value Call on no zero to facto (i.e repeat process till zero flag for c = 1) Return to main program Content 04 18 1 x 2 x 3 x 4 = 24 Hexadecimal 16 24 1-8 Result: Thus, factorial program was done successfully 47 EE0310-Microprocessor & Microcontroller Lab FIBANOCCI SERIES Aim: To write an assembly language program to displace Fibanocci Series. Apparatus required: 8085 microprocessor kit (0-5V) DC battery Algorithm: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10 Step 11 Step 12 Step 13 Step 14 Step 15 Step 16 : : : : : : : : : : : : : : : : Start the microprocessor Load the length of series in the accumulator and decrement it by 2 Move the value to register ‘D’ Load the starting value of data value address Intialise the 1st number as 00 Move the pointer to 2nd data and intialise them as ‘01’ Move the pointer to next position for next data Intialise B as ‘00’ and C as ‘01’ for calculations Copy the contents of ‘B’ to accumulator Add the content of ‘C’ register to accumulator Move the content ‘C’ to ‘B’ and ‘A’ to C Now store the result to memory pointed by ‘HL’ pair Move the pointer to next pointer Decrement 0 by 1 for counter If ‘D’ is not zero, go to step 9 if ‘D’ is zero, end the program 48 EE0310-Microprocessor & Microcontroller Lab START Load the lenth of series Decrement it by 2 Move it to ‘D’ register Load the starting value of data Intialise their values as ‘00’ Move the pointer to next position Intialise the value as ‘01’ Move the pointer to next position Intialise ‘B’ as ‘00’ & ‘C’ as ‘01’ Move it from ‘B’ to ‘A’ Store the result in accumulator Move the pointer to next position Decrement D by 1 No Check D=0? Yes END 49 EE0310-Microprocessor & Microcontroller Lab Address 4200 Label Mnemonics LDA 4300 Hex Code 3A, 00, 43 4203 4205 4206 SUI 02 MOV D,A LXI H, 4301 D6, 02 57 21,01,43 4209 420B 420C 420E 420F 4211 4213 4214 4215 4216 4217 4218 4219 421A 421D MVI M,00 INX H MVI M, 01 INX H MVI B,00 MVI, C, 01 MOV A,B ADD C MOV B,C MOV C,A MOV M,A INX H DCR D JNZ loop HLT 36,00 23 36,01 23 06,00 0E, 01 78 81 41 4F 77 23 15 C2, 13,42 76 Loop Comments Store the length of series in ‘A’ Decrement ‘A’ by 02 Move ‘A’ to ‘D’ (counter) Load the starting address of array Intialise 4301 as ‘00’ Increment pointer Initialize 2nd as ‘01’ Increment pointer Intialise ‘B’ as ‘00’ Intialise ‘C’ as ‘01’ Move B to A Add ‘A’ and ‘C’ Move C to B Move A to C Move the result to memory Increment pointer Decrement counter If D = 0, jump to loop Stop the program Input Input Address 4300 Value 05 Output Address 4301 4302 4303 4304 4305 Value 00 01 01 02 03 Output 00 + 01 = 01 01+ 01 = 02 02 + 01 = 03 Result: The assembly language for Fibonaci series was executed successfully using 8085 microprocessor kit. 50 EE0310-Microprocessor & Microcontroller Lab 16 – BIT MULTIPLICATION Aim: To write an assembly language program for 16 bit multiplication by using 8085 microprocessor kit. Apparatus required: 8085 microprocessor kit (0-5V) DC battery Algorithm: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 : : : : : : : Step 8 Step 9 : : Step 10 : Step 11 : Start the microprocessor Load the 1st data in ‘HL’ register pair Move content of ‘HL’ pair to stack pointer Load the 2nd data in ‘HL’ and move it to ‘DE’ Make ‘HL’ pair as ‘00’ and ‘00’ Add ‘HL’ pair and ‘SP’ Check for carry condition, if carry is present increment it by one else move to next step. Decrement DE register Then move E to ‘A’ and perform ‘OR’ operation with ‘a’ and ‘D’ The value of operation is zero, then store the value else go to step 3 Stop the program 51 EE0310-Microprocessor & Microcontroller Lab START Load the lenth of series Move the value ‘HL’ to ‘SP’ Intialise both ‘BC’ & ‘HL’ as ‘0000’ Add the content of ‘HL’ & ‘SP’ No If Carry=0? Yes Increment BC pair Decrement DE pair Move ‘E’ to ‘a’ & “or” operation with ‘D’ Result or ≥1? No Yes Store the result in ‘HL’ END 52 EE0310-Microprocessor & Microcontroller Lab Memory Location 4100 4103 Hex Code Label 4106 4107 2A,02,42 EB LHLD XCHG 4202 4108 410B 410E 410F 21,00,00 01,00,00 39 D2, 13, 41 LXI H LXI B DAD JNC 0000 0000 SP Loop 4112 4113 03 1B INX DCX B D 4114 4115 7B B2 MOV ORA A,E D 4116 C2,0E,41 JNZ Next 4119 22,04,42 SHLD 4204 411C 411D 411E 69 60 22,06,42 MOV MOV SHLD L,C H,B 4206 4121 76 HLT 2A,00,42 F9 Next Loop Mnemonics Op code Operand LHLD 4200 SP HL Comments Get the 1st data in HL Save it in stack pointer4106 Get the 2nd data in HL Exchange ‘HL’ and ‘DC’ Make HL – 0000 Make BC – 0000 Add ‘SP’ and ‘HL’ Jump to loop if no carry Increment ‘BC’ by one Decrement ‘DE’ by one Make E – A ‘OR’ gate between A &D Jump on if number zero Store the LSB in memory Make C to L Make B to H Store the MSB in memory Stop the program Input Input Address 4200 4201 4202 4203 Value 04 07 02 01 Output Address 4204 4205 4206 4207 Value 08 12 01 00 Output Result: Thus the assembly language program for 16 bit multiplication was executed successfully. 53 EE0310-Microprocessor & Microcontroller Lab 16 – BIT DIVISION Aim: To write an assembly language program for 16 bit division in 8085 microprocessor. Apparatus required: 8085 microprocessor kit (0-5V) DC battery Algorithm: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10 Step 11 Step 12 Step 13 Step 14 Step 15 Step 16 : : : : : : : : : : : : : : : : Start the microprocessor Intialise ‘BC’ as ‘0000’ for Quotient Load the divisor in ‘HL’ pair and save it in ‘DE’ register pair Load the dividend in ‘HL’ pair Move the value of ‘a’ to register ‘E’ Subtract the content of accumulator with ‘E’ register Move the content ‘A’ to ‘C’ & ‘H’ to ‘A’ Subtract with borrow, the content of ‘A’ with ‘D’ Move the value of ‘a’ to ‘H’ If cy = 1, go to step 12, otherwise next step Increment ‘B’ register & jump to step ‘4’ Add both contents of ‘DC’ and ‘HL’ Store the remainder in memory Move the content of ‘C’ to ‘L’ & ‘B’ to ‘H’ Store the Quotient in memory Stop the program 54 EE0310-Microprocessor & Microcontroller Lab START Intialise the Quotient as zero Load the divisor in ‘HL’ & move it ‘DE’ Load the dividend in ‘HL’ pair Intialise A with compare ‘E’ & ‘L’ Transfer and Add the contents of A and B Check for if cy = 1 Yes Store te remainder in HL in memory Move the content of BC to ‘HL’ pair Store the Quotient in HL to memory END 55 Subtract ‘HL’ from ‘DE’ increment BC pair EE0310-Microprocessor & Microcontroller Lab Address 4500 4503 4506 4507 450A 450B 450C 450D 450E 450F 4510 4513 4514 4517 4518 451B 451C 451D 4520 Label Loop 2 Loop 1 Mnemonics LXI B,0000 LHLD 4802 XCHG LHLD 4800 MOV A,L SUB E MOV L,A MOV A,H SBB D MOV H,A JC loop 1 INX B JMP loop 2 DAD ‘D’ SHLD 4806 MOV L,C MOV H,B Hex Code 0,00,00 2A,02,48 EB 2A,00,48 7D 93 6F 7C 9A 67 DA,17,45 03 C3, 0A, 45 19 22,06,48 69 60 SHLD 4804 HLT 22,04,48 76 Comments Intialise Quotient as ‘0000’ Load the divisor in ‘HL’ Exchange ‘HL’ and ‘DE’ Load the dividend Move the ‘L’ value to ‘A’ (A-E) – A A- L (A value is move t L) H – A (a is stored with H) Subtract ‘D’ from ‘A’ Then A is moved to ‘H’ If cy is present go to loop 1 Increment BC pair by 1 Jump to loop 2 ‘DE’ and ‘HL’ pair all added HL is stored in memory Move ‘C’ register data to ‘L’ Move ‘B’ register data to ‘H’ Store the result in ‘HL’ pair Stop the program Input Input Address 4800 4801 4802 4803 Value 04 00 02 00 Output Address 4804 4805 4806 4807 Value 02 00 FE FF Output Result: Thus the assembly language program for 16 bit division was executed successfully. 56 EE0310-Microprocessor & Microcontroller Lab BINARY TO BCD CONVERSION Aim: To write an assembly language program to convert an 8 bit binary data to BCD using 8085 microprocessor kit. Apparatus required: 8085 microprocessor kit (0-5V) power supply Algorithm: Step 1 Step 2 : : Step 3 Step 4 Step 5 Step 6 : : : : Step 7 Step 8 Step 9 Step 10 Step 11 Step 12 : : : : : : Start the microprocessor Clear ‘D’ and ‘E’ register to account for hundred’s and ten’s load the binary data in accumulator Compare ‘A’ with 64 if cy = 01, go step C otherwise next step Subtract 64 from (64+1) ‘A’ register Increment ‘E’ register Compare the register ‘A’ with ‘0A’, if cy=1, go to step 11, otherwise next step Subtract (0AH) from ‘A’ register Increment D register Go to step 7 Combine the units and tens to from 8 bit result Save the units, tens and hundred’s in memory Stop the program execution 57 EE0310-Microprocessor & Microcontroller Lab START Intialise ‘D’ as ‘00’ for hundreds and ‘e’ as ‘00’ for tens Load the binary data in ‘A’ Compare the accumulator with ‘64’ Cy = ? Subratct 64 from accumulator Increment ‘E’ register Compare with 0A Cy = ? Subtract ‘0A’ from accumulator Increment register ‘D’ Combine the units & tens to form 8 bit cCom Save the units, tens & hundreds in memory END 58 EE0310-Microprocessor & Microcontroller Lab Memory Location 4100 Hex Code Label 4102 53 MOV D,E 4103 4106 3A,00,42 C3,06,41 LDA CPI 4200 64 4108 DA,11,41 JC TEN 410B 410D D6, 64 IC SUI INR 64 E 410E C3,06,41 JMP HUND 4111 C3, 0A CPI 0A 4113 DA,1C,41 JC UNIT 4116 4118 D6, 0A 14 SUI INR 0A D 4119 411C C3,11,41 4F JMP MOV TEN 4A 411D 7A MOV A,D 411E 411F 4120 07 07 07 RLC RLC RLC 4121 4122 4123 07 81 32,50,42 RLC ADD STA C 42,50 4126 4127 7B 32,51,42 MOV STA A,E 4251 412A 76 HLT 0E,00 HUND TEN UNIT Mnemonics Op code Operand MVI E,00 59 Comments Clear ‘E’ register (Hund) Clear ‘D’ register (tens) Get the data in ‘A’ Compare the data with 64 If content is less jump to ten Subtract data by 64 Increment carry each time Jump to hundred & repeat Compare the data with 0A If data is less jump to unit Subtract the data by 0A Increment ‘D’ each time Jump to ten & repeat Move the value ‘A’ to ‘C’ Move the value ‘D’ to ‘A’ Rotate the value of ‘A’ Of ‘A’ so that Lower and upper niddle Gets exchanged Add ‘A’ and ‘C’ Save ten’ & units in ‘M’ Move to E to A Save hundreds unit in ‘A’ Stop the program execution EE0310-Microprocessor & Microcontroller Lab Input Input Address 4200 Value 54 Output Address 4250 4251 Value 84 00 Output Result: Thus the binary to BCD conversion was executed successfully 60 EE0310-Microprocessor & Microcontroller Lab BCD TO BINARY Aim: To write an assembly language program to convert BCD data to Binary data using 8085 microprocessor kit. Apparatus required: 8085 microprocessor kit (0-5V) power supply Algorithm: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10 : : : : : : : : : : Step 11 Step 12 Step 13 : : : Start the microprocessor Get the BCD data in accumulator and save it in register ‘E’ Mark the lower nibble of BCD data in accumulator Rotate upper nibble to lower nibble and save it in register ‘B’ Clear the accumulator Move 0AH to ‘C’ register Add ‘A’ and ‘B’ register Decrement ‘C’ register. If zf = 0, go to step 7 Save the product in ‘B’ Get the BCD data in accumulator from ‘E’ register and mark the upper nibble Add the units (A-ug) to product (B-ug) Store the binary value in memory End the program 61 EE0310-Microprocessor & Microcontroller Lab START Get the BCD data in accumulator Move ‘A’ to register ‘E’ Lower nibble of BCD data in ‘A’ Rotate upper -> lower & save it in ‘B’ Clear the accumulator & move ‘0A’ to ‘C’ Load the 2nd 8 bit number Transfer and Add the contents of A and B Yes Zf = 0 ? Save the product in ‘B’ register Get the BCD data in A, move it to E and mark it Add the unit A and (B-ug) product Store the binary value in ‘M’ END 62 EE0310-Microprocessor & Microcontroller Lab Memory Location 4100 4103 4104 4106 4107 4108 4109 410A Hex Code 410B 410C 410E 410F 4110 4113 4114 4115 4117 4118 411B AF 0E,0A 08 0D C2,0E,41 47 7B E6, 0F 80 32,01,42 76 Label 3A,00,42 5E E6, F0 07 07 07 07 47 Mnemonics Op code Operand LDA 4200 MOV E,A ANI F0 RLC RLC RLC RLC MOV B,A XRA MVI REP DCR JNZ MOV MOV ANI ADD STA HLT A C,0A C B,A A,E 0F B 4201 Input Input Address 4200 Value 68 Output Address 4201 Value 44 Output 16 68 4-4 Result: Thus the BCD to binary conversion was executed successfully 63 Comments Get the data in ‘A’ Save in ‘E’ register Mark the lower nibble Rotate the upper To lower nibble And save in Register B Move it from ‘A’ to ‘B’ Clear the accumulator Intialise ‘C’ as ‘0A’ Decrement ‘C’ register Jump till value ‘C’ is 0 Move the value A to B Get the BCD in ‘A’ Mark the upper nibble Add ‘A’ and ‘B’ Save the binary data Stop the program execution EE0310-Microprocessor & Microcontroller Lab SPEED CONTROL OF STEPPER MOTOR Aim: To write an assembly program to make the stepper motor run in forward and reverse direction. Apparatus required: Stepper motor 8085 microprocessor kit (0-5V) power supply Algorithm: Step 1 Step 2 Step 3 : : : Step 4 Step 5 Step 6 Step 7 Step 8 : : : : : Load the ‘HL’ pair wit value from table Move it to ‘B’ register for setting the counter Move the memory value to accumulator and display it by control word Load ‘DE’ register pair with FFFF for starting delay subroutine Run the delay loop control D-register becomes zero. Increment ‘H’ address for next value from table Jump on no zero When B = 0, go to start and restart the program 64 EE0310-Microprocessor & Microcontroller Lab START Load ‘HL’ register pair with data Load ‘E’ with ‘04’ (count) Move memory to accumulator Display the accumulator content (8 bit port) Load the ‘DE’ pair with ‘FFFF’ Start delay subroutine Decrement ‘D’ by one, check ‘OR’ gate between ‘D’ and E D=0? Increment ‘HL’ pair by one (count) Decrement ‘B’ count by one Cy = ? 65 EE0310-Microprocessor & Microcontroller Lab Memory Location 4100 4103 4105 4106 4108 410B 410C 410D 410E 410F 4112 4113 4114 4117 Hex Code Label Start LXI Repeat Delay MVI MOV OUT LXI NOP DCX MOV ORA JNZ INX DCR JNZ JMP Mnemonics Op code Operand H,Look up 21,1A,41 B,04 A,M C0 D,03,03 D A,E D DELAY H B Repeat START 06,04 7E D3, C0 11 00 1B 7B B2 C2, 0B,41 23 05 C2,05,41 C3,00,41 Comments Load the ‘HL’ with data B = 04 Memory value to ‘A’ Display it Load ‘DE’ with FFFF Start delay loop Decrement DE by 1 Move ‘E’ to ‘A’ Check De = 0 or not Jump on zero Increment HL by 1 Decrement B by 1 Jump on no zero Jump to start Input Input Address 411A 411B 411C 411D Value 0A 06 05 09 Output Address 411A 411B 411C 411D Value 09 05 06 0A Reverse Direction Result: Thus, an assembly language program to control of stepper motor was written using 8085 microprocessor kit. 66 EE0310-Microprocessor & Microcontroller Lab FLASHING DISPLAY Aim: To write an assembly language program to obtain the following flashing display of a particular data. Apparatus required: 8085 micro processing kit (0-5V) power supply Algorithm: Step 1 : Step 2 Step 3 Step 4 : : : Step 5 Step 6 Step 7 Step 8 Step 9 Step 10 : : : : : : Get the control words in accumulator and output words through 8 bit address Load ‘HL’ register pair with memory address Get the count value in ‘C’ register Increment the register pair by one and display the character and call for delay. Clear the display and call delay routine to step 7 Go to step 7 Load ‘DE’ register pair with memory address Decrement ‘DE’ pair with memory address If the content is not equal to zero, go to step 8 Return to main program 67 EE0310-Microprocessor & Microcontroller Lab START Load the control loads for flashing display Load the register pair ‘HL’ with specified address Transfer count from memory to ‘C’ register Increment memory address Transfer memory count in accumulator Output accumulator content to a data register Increment count in register ‘c’ No Check for carry? Yes Call delay Load control word for linear screen Call delay Load ‘DE’ with memory address No If Content ? Yes Return 68 EE0310-Microprocessor & Microcontroller Lab Memory Location 4300 4302 Hex Code Label MVI OUT Mnemonics Op code Operand A,00 3E,00 01 DE,01 4304 MVI A,90 3E,90 4306 4308 430A 430C 430F 4310 4311 4312 4314 4315 4318 431B 431D 431F 4322 4600 4603 4604 4605 4606 4609 OUT MVI OUT LXI MOV INX MOV OUT DCR JNZ CALL MVI OUT CALL JMP LXI DCX MOV ORA JNZ RET 01 A,CC 01 H,5000 C,M H A,M 00 C Loop 1 Delay A,DC 01 Delay Loop 2 D,FFFF D A,E D Loop 3 C9 D3,01 3E,CC 0D,01 21,00,50 4E 23 7E D3, 00 0D C2,10,43 C0,00,46 3E,DC D3, 01 CD,00,46 C3 0C,43 11,FF,FF 1B 7B B2 C2,03,46 C9 Loop 2 Loop 1 Delay Loop 3 Comments Intialise ‘A’ as ‘00’ Out the control word trough 8 bit Intialise ‘a’ with cw for RAM Out the cw A = CC Out the cw Load ‘HL’ with M to C Increment ‘H’ by Move M to A Out the character Decrement ‘C’ by 1 Check for zero Call subroutine A <- 0C A<-01 Call subroutine Check for zf Intialise DE=FFFF Decrement DE by 1 Move ‘E’ to ‘A’ Check ‘De’ = ‘00’ Jump on no zero Return to main program Input Input Address 5000 5001 5002 5003 5004 5005 Value 05 68 68 68 FD 88 Output EEE – A Result: Thus, an assembly language program to obtain flashing display of a particular data was written using 8085 microprocessor kit. 69 EE0310-Microprocessor & Microcontroller Lab ROLLING DISPLAY Aim: To write an assembly language program to obtain a rolling display of a particular data by using 8085 microprocessor Apparatus required: 8085 micro processing kit (0-5V) power supply Algorithm: Step 1 : Step 2 : Step 3 : Step 4 Step 5 : : Step 6 Step 7 Step 8 : : : Get the control words in accumulator and output the control words through 8 bit port address Load ‘HL’ register pair with memory address and transfer memory content to ‘C’ register Increment ‘HL’ pair with one and transfer the particular bit pattern through 8 bit port address Call subroutine delay at step 6 If the count value in ‘C’ is not equal to zero then go to step 3 else go to step 2 Load ‘DE’ register pair by memory address Decrement ‘DE’ register pair by one If DE is not equal to zero, go to step 7 else main program 70 EE0310-Microprocessor & Microcontroller Lab Delay Intialise register ‘D’ with maximum count ‘EE’ Intialise register ‘c’ with maximum count ‘EE’ Decrement register ‘C’ count by one If Reg ‘C’ Count ? No Yes Decrement register ‘D’ content by one No If reg ‘D’ Count ? Yes Return 71 EE0310-Microprocessor & Microcontroller Lab Memory Location 4500 4502 Hex Code Label MVI OUT Mnemonics Op code Operand A,00 3E,00 01 DE, 01 4504 4506 MVI OUT A,90 01 3E, 90 DE,01 4508 450A MVI OUT A,CC 01 3E,CC DE,01 LXI H,5000 21,00,50 MOV INX MOV OUT CALL DCR JNZ JMP LXI DCX MOV ORA JNZ RET C,M H A,M 00 Loop C Loop 1 Loop 2 D,FFFF D A,D E Loop 3 4E 23 7E DE, 00 CD,00,46 0D C2,10,45 C3,0C,45 11,FFFF 1B 7A B3 C2,03,46 C9 450C 450F 4510 4511 4512 4514 4517 4518 451B 4600 4603 4604 4605 4606 4609 Loop 2 Loop 1 Loop Loop 3 Comments Initialise A 00 Control word through 8 bit A = RAM cw Output cw through 8 bit port A = CC Output cw through 8 bit port Memory -> HL location M -> C Increment ‘HL’ Move ‘H’ to ‘A’ Output the character Call the subroutine Decrement ‘C’ by one Jump on no zero Jump to L2 Load DE-FFFF Decrement ‘DE’ by 1 Move ‘D’ to ‘A’ (A) = (A) check Jump on no zero Return to main program Input Input Address 5000 5001 5002 5003 5004 5005 5006 Value 06 98 68 7A C8 1A 2C Output HELPUS Result: Thus, an assembly language program to obtain rolling display of a particular value written using 8085 microprocessor kit. 72 EE0310-Microprocessor & Microcontroller Lab SQUARE WAVE GENERATOR Aim: To write a program and to generate square generator using DAC. Apparatus required: 8085 microprocessor kit (0-5V) power supply Algorithm: Step 1 Step 2 Step 3 Step 4 Step 5 Delay Subtroutine Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 : : : : : Intialise ‘A’ as ‘00’ and take data pointer to port C8 Call delay Move FF to A and take port ‘C8’ Call delay Go to step 1 : : : : : : : Counter 1 = 05 Counter 2 = FF Decrement counter 2 Check if c= 0, if no jump to step 3 Decrement counter 1 Check if B = 0, if no jump to step 2 Return to main program 73 EE0310-Microprocessor & Microcontroller Lab START Load the control words as for displaying Call the delay subtroutine program Intialise the accumulator as ‘EE’ Output the accumulator contents register Call the delay subroutine program Jump to the start of program Intialise ‘B’ as 05 and ‘C’ as ‘FF’ and decrement ‘c’ by one Check for c=? No Yes Decrement the value of ‘B’ No Check for B=0? Yes Return 74 EE0310-Microprocessor & Microcontroller Lab Memory Location 4100 4102 4104 4107 4109 410B 410E 4111 4113 4115 4116 4119 411A 411D Hex Code Label 3E,00 D3,C8 CD,11,41 3E,FF D3,C8 CD,11,41 C3,00,41 06,05 0E OD C2,15,41 05 C2,13,41 C9 Start Delay Loop 1 Loop 2 Mnemonics Op code Operand MVI A,00 OUT C8 CALL Delay MVI A,FF OUT C8 CALL Delay JMP Start MVI B,05 MVI C,FF DCR C JNZ Loop 2 DCR B JNZ Loop 1 RET Comments Intialise ‘A’ with ‘00’ Load the control words Call delay sutroutine Intialise ‘A’ with ‘FF A -> C8 Call delay subroutine Jump to start B -> 05 [C] => FF Decrement ‘C’ register Jump on no zero Decrement ‘B’ register Jump on n zero Return to main program Result: Thus square wave was generated using 8085 microprocessor kit. 75 EE0310-Microprocessor & Microcontroller Lab TRIANGULAR WAVE GENERATOR Aim: To write an assembly language program for generating triangular wave using DAC. Apparatus required: 8085 micro processor kit (0-5V) DC battery Algorithm: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 : : : : : : : Move content of ‘C’ to ‘A’ where ‘L’ is intialised to ‘00’ Output content of C8 Increment L till zf = 0 Intialise ‘L’ register with FF Move content of ‘L’ to accumulator and output to port Decrement ‘L’ if not equal to zero jump else go to next step Jump on next step 76 EE0310-Microprocessor & Microcontroller Lab Delay Intialise the value of ‘1’ as ‘00’ Move the values of ‘1’ to ‘A’ Output the control word for control signal Increment the value of ‘L’ L=0? No Yes Set the value of ‘1’ as ‘FF’ Move the ‘1’ value to accumulator Output the control word L=0? Yes Jump to start 77 No EE0310-Microprocessor & Microcontroller Lab Memory Location 4300 4302 4303 4305 4306 Hex Code Label 2E,00 7D D3,C8 2C C2,02,43 Start Loop 1 4309 430B 430C 430E 430F 2E, FF 70 D3,C8 2D C2,0B,43 4312 C3,00.43 Loop 2 Mnemonics Op code Operand MVI L,00 MOV A,L OUT C8 INR L JNZ Loop 1 MVI MOV OUT DCR JNZ L,FF A,L C8 L Loop 2 JMP Start Comments Intialise ‘L’ as ‘00’ [L] -> [A] Load the control words Increment register ‘L’ Jump on no zero to loop 1 L = FF L -> A [C8] -> [A] Decrement L by one Jump on no zero to 430B Repeat process Result: Thus the triangular wave was generated using 8085 microprocessor kit. 78 EE0310-Microprocessor & Microcontroller Lab SAWTOOTH WAVE GENERATOR Aim: To write an assembly language program for generating Sawtooth waveform by using microprocessor 8085. Apparatus required: 8085 microprocessor kit (0-5V) power supply Algorithm: Step 1 Step 2 Step 3 Step 4 : : : : Intialise accumulator with ‘00’ Output current address specified Increment accumulator by one Jump to step one Delay Intialise the accumulator as ‘00’ Display the output port using cw Increment the accumulator Jump to loop 1 Memory Location 4500 4502 4504 4505 Hex Code Label 3E,00 D3, C8 3C C3,02,45 Start Loop 1 Mnemonics Op code Operand MVI A,00 OUT C8 INR A JMP Loop 1 TRIANGULAR WAVE 79 Comments Intialise ‘A’ as ‘00’ A = [C8] Increment ‘A’ by one Jump to loop one EE0310-Microprocessor & Microcontroller Lab SAW TOOTH WAVE SQUARE WAVE Result: Thus the Sawtooth wave was generated using 8085 microprocessor kit. 80 EE0310-Microprocessor & Microcontroller Lab ANALOG TO DIGITAL CONVERTER Aim: To write an assembly language program to convert analog to digital signal and to display it in 7 segment LED display Apparatus required: 8085 microprocessor kit (0-5V) power supply Algorithm: Step 1 Step 2 : : Step 3 Step 4 Step 5 : : : Step 6 : Access the channel of ADC Intialise the accumulator with start of conversion signal & output it to the ADC Send ‘0’ signal for ending the conversion for ADC Get the analog value converted to display from ADC The digital signal is separated into two nibbles and displayed in hexadecimal from by calling service subroutine. Go to step 1 81 EE0310-Microprocessor & Microcontroller Lab START Load the control word necessary for generation of ALE signal to control register Load the control word necessary to start the conversion to control register Get the output port specified If the 1st LSB bit=1? Get accumulator output in port specified Transfer accumulator content to ‘B’ Mask all MSR & Store memory in location Mask all 4 LSB & store memory in location Load accumulator with 03 & with 08 Load the pair with address of MSR Call the service subroutine 82 EE0310-Microprocessor & Microcontroller Lab Memory Location 5000 5002 5004 5006 Hex Code Label 5008 5009 500A 00 00 3E,10 NOP NOP MVI A,10 500C D3,C8 OUT C8 500E 5010 5012 5013 5014 5015 5017 5019 501B 501D 5020 5022 5023 5025 5028 5029 502B 502C 502E 502F 5032 5034 5036 3E,01 D3,D0 00 00 00 3E,00 D3,D0 DB,D8 E6,01 CA,19,50 DB,C0 47 E6,0F 32,51,51 78 E6,F0 0F 0F 0F 32,50,51 3E,03 0E,08 21,50,51 MVI OUT NOP NOP NOP MVI OUT IN ANI JZ IN MOV ANI STA MOV ANI RRC RRC RRC STA MVI MVI LXI H A,01 D0 5039 503C CD,05,00 C3,0E,50 3E,10 D3,C 3E,18 D3, C8 L2 L1 Mnemonics Op code Operand MVI A,10 OUT C8 MVI A,18 OUT C8 CALL JMP A,00 D0 D8 01 L1 C0 B,A 0F 5151 A,B F0 550 A,03 C,08 5150 0005 500E Comments Intialise ‘a’ with 10 Output channel through Intialise ‘A’ with 18 Output channel through 8 bit port No operation No operation Intialise ‘A’ with 2nd signal Output channel through 8 bit port Intialise ‘A’ with 2nd Output through 8 bit Get input from B -> A And of with ‘A’ Store in 5151 B -> A And F0 with A Rotate content ‘A’ Store MSB in 5150 03 -> A 08 -> C Load ‘HL’ pair with 5150 Call device subroutine Jump to 500E Result: Thus the analog to digital conversion was done microprocessor. 83 EE0310-Microprocessor & Microcontroller Lab ARTHMETIC OPERATIONS USING 8051 Aim: To do the arithmetic operations using 8051 microprocessor Apparatus required: 8085 microprocessor kit DAC interface kit Keyboard Algorithm: Addition / Subtraction Step 1 : Step 2 : Step 3 : Step 4 : Move 1H data to memory Add or subtract 1H data with 2nd data Initialize data pointer. Move result to memory pointed by DPTR. START Out 1H data in memory Add or subtract 1H and 1st data Initialize DPTR Move result to memory preset by DPTR Stop 84 EE0310-Microprocessor & Microcontroller Lab Program: 8-bit Addition: Memory Location 4100 4101 Label Opcode Start C3 74DA CLR C MOV A, # data 1 4103 24DA ADD A, # data 2 4105 464500 MOV DPTR, # 4500 4108 F0 MOV A @ DPTR, A 4109 80 FE Execution: Addition: ML 4103 4109 Mnemonics SJMP 4109 Input 0L 03 ML 4500 Comments Clear the carry flat Moves data 1 to register A Add content of A and data 2 and store in A Moves data 4500 to DPTR Moves control of A to location pointed DTPR Short jump to 4109 Output 05 Program: 8-bit Subtraction: Memory Location 4100 4101 Label Opcode Start C3 74DA CLR C MOV A, # data 1 4103 24DA SUB B, # data 2 4105 4108 464500 F0 MOV DPTR, # 4500 MOV X @ DPTR, A 4109 80 FE SJMP 4109 Execution: Subtraction: ML 4101 4103 Mnemonics Input 05 02 ML 4500 Result: Thus 8-bit addition, subtraction is performed using 8051. 85 Comments Clear the carry flat Moves data 1 to register A Subtract data 2 from content of A and store result in A Moves 4500 to DPTR Moves result by location by DTPR Short jump to 4109 Output 03 EE0310-Microprocessor & Microcontroller Lab ARTHMETIC OPERATIONS USING 8051 Aim: To do the arithmetic operations using 8051 microprocessor Apparatus required: 8085 microprocessor kit DAC interface kit Keyboard Algorithm: Multiplication / Division Step 1 : Step 2 : Step 3 : Step 4 : Step 5 : Step 6 : Step 7 : Get 1H data and 2nd data to memory Multiply or divide 1H data with 2nd data Initialize data pointer. Move result to memory pointed by DPTR (first port) Increment DPTR Move 2nd part of result to register A Move result to 2nd memory location pointer by DPTR START Get data into the register Complement the data Move the data to pointer by DPTR Increment data Increment DPTR Move data into paste location Short jump to preset location Stop 86 Yes EE0310-Microprocessor & Microcontroller Lab Program: 8-bit Multiplication: Memory Label Opcode Location 4100 Start 7403 Mnemonics MOV A, # data 1 4101 75F003 4105 A4 4106 904500 MOV DPTR, # 4500 4109 410B 410D 410E F0 E5F0 F0 80FE MOV X @DPTR, A MOV A,B MOV A @ DPTR SJMP 410E Execution: Multiplication: ML 4101 4103 Program: 8-bit Division: Memory Label Location 4100 Start MUL A B Input 0L 04 Move immediate data to accumulator Move 2nd data to B register Get the product in A & B Load data in 4500 location Move A t ext RAM Move 2nd data in A Same the ext RAM Remain idle in infinite loop Output Address 4500 Opcode 7408 4102 75F002 4105 84 4106 904500 4109 410A 410B 410D 410E F0 A3 ESF0 F0 80FE Execution: Division: ML 4101 4103 MOV B, # data 2 Comments Mnemonics Value 08 Comments MOV A, # data 1 Move immediate data to accumulator MOV B, @ data 2 DIV Move immediate to B AB reg. DIV AB Divide content of A & B MOV DPTR, # 4500 Load data pointer with 4500 location MOV X @ DPTR, A Move A to ext RAM INC DPTR Increment data pointer MOV A,B Move remainder to A MOV @ DPTR, A Move A to ext RAM SJMP 410E Remain idle in infinite loop Input 08 04 Output Address 4500 Result: Thus 8-bit multiplication & division is performed using 8051. 87 Value 02