sv

8085 MICROPROCESSOR PROGRAMS

t ie

ka

nu ru .t k

ADDITION OF TWO 8 BIT NUMBERS
AIM: To perform addition of two 8 bit numbers using 8085. ALGORITHM: 1) 2) 3) 4) 5) 6) 7) Start the program by loading the first data into Accumulator. Move the data to a register (B register). Get the second data and load into Accumulator. Add the two register contents. Check for carry. Store the value of sum and carry in memory location. Terminate the program.

PROGRAM:

OBSERVATION: Input: Output: RESULT: Thus the program to add two 8-bit numbers was executed. 80 (4150) 80 (4251) 00 (4152) 01 (4153)

sv

MVI LDA MOV LDA ADD JNC INR LOOP: STA MOV STA HLT

t ie

C, 00 Initialize C register to 00 4150 Load the value to Accumulator. B, A Move the content of Accumulator to B register. 4151 Load the value to Accumulator. B Add the value of register B to A LOOP Jump on no carry. C Increment value of register C 4152 Store the value of Accumulator (SUM). A, C Move content of register C to Acc. 4153 Store the value of Accumulator (CARRY) Halt the program.

ka

nu

ru

.t

k

SUBTRACTION OF TWO 8 BIT NUMBERS
AIM: To perform the subtraction of two 8 bit numbers using 8085.

ALGORITHM: 1. 2. 3. 4. 5. 6. 7. 8. 9.

PROGRAM: MVI LDA MOV LDA SUB JNC CMA INR INR LOOP: STA MOV STA HLT C, 00 4150 B, A 4151 B LOOP A C 4152 A, C 4153

sv

Start the program by loading the first data into Accumulator. Move the data to a register (B register). Get the second data and load into Accumulator. Subtract the two register contents. Check for carry. If carry is present take 2’s complement of Accumulator. Store the value of borrow in memory location. Store the difference value (present in Accumulator) to a memory location and terminate the program.

t ie

ka

Initialize C to 00 Load the value to Acc. Move the content of Acc to B register. Load the value to Acc. Jump on no carry. Complement Accumulator contents. Increment value in Accumulator. Increment value in register C Store the value of A-reg to memory address. Move contents of register C to Accumulator. Store the value of Accumulator memory address. Terminate the program.

nu ru .t k

OBSERVATION: Input: 06 (4150) 02 (4251) Output: 04 (4152) 01 (4153)

RESULT:

sv

Thus the program to subtract two 8-bit numbers was executed.

t ie ka nu ru .t k

MULTIPLICATION OF TWO 8 BIT NUMBERS
AIM: To perform the multiplication of two 8 bit numbers using 8085. ALGORITHM: 1) 2) 3) 4) 5) 6) 7)

PROGRAM: MVI MVI LXI MOV INX MOV ADD JNC INR DCR JNZ STA MOV STA HLT D, 00 A, 00 H, 4150 B, M H C, M B NEXT D C LOOP 4152 A, D 4153

LOOP: NEXT:

sv

Start the program by loading HL register pair with address of memory location. Move the data to a register (B register). Get the second data and load into Accumulator. Add the two register contents. Check for carry. Increment the value of carry. Check whether repeated addition is over and store the value of product and carry in memory location. 8) Terminate the program.

t ie

ka

nu
Initialize register D to 00 Initialize Accumulator content to 00 Get the first number in B - reg Get the second number in C- reg. Add content of A - reg to register B. Jump on no carry to NEXT. Increment content of register D Decrement content of register C. Jump on no zero to address Store the result in Memory Store the MSB of result in Memory Terminate the program.

ru

.t

k

t ie ka nu ru .OBSERVATION: Input: Output: FF (4150) FF (4151) 01 (4152) FE (4153) RESULT: sv Thus the program to multiply two 8-bit numbers was executed.t k .

ALGORITHM: 1) 2) 3) 4) 5) 6) 7) PROGRAM: LXI MOV MVI INX MOV CMP JC SUB INR JMP STA MOV STA HLT NEXT: LOOP: sv Start the program by loading HL register pair with address of memory location. Clear C – reg for qoutient Get the divisor in A – reg. M B LOOP B C NEXT 4152 A. 00 H A. Move the data to a register(B register).DIVISION OF TWO 8 BIT NUMBERS AIM: To perform the division of two 8 bit numbers using 8085. . M C. Increment the value of carry . Jump to NEXT Store the remainder in Memory Store the quotient in memory Terminate the program. Compare the two numbers to check for carry. Jump on carry to LOOP Subtract A – reg from B. 4150 B. Subtract the two numbers. t ie ka H. Check whether repeated subtraction is over and store the value of product and carry in memory location.reg. 8) Terminate the program. C 4153 nu ru Get the dividend in B – reg.t k . Increment content of register C. Get the second data and load into Accumulator. Compare A .reg with register B.

t k .Quotient Output: RESULT: sv Thus the program to divide two 8-bit numbers was executed.OBSERVATION: Input: FF (4150) FF (4251) 01 (4152) ---.Remainder FE (4153) ---. t ie ka nu ru .

t k . 13) Terminate the program.M B LOOP 4300 LOOP: AHEAD: sv 1) Load the address of the first element of the array in HL pair 2) Move the count to B – reg. go to step 6. 3) Increment the pointer 4) Get the first data in A – reg.M H A.reg. or if ZF = 1 go to next step. 5) Decrement the count. 12) Store the largest data in memory. 8) If Carry = 0.4200 B. go to step 10 or if Carry = 1 go to step 9 9) Move the content of memory addressed by HL to A – reg.M B H M AHEAD A. If ZF = 0.reg > M go to AHEAD Set the new value as largest Repeat comparisons till count = 0 Store the largest value at 4300 . t ie ka nu ru Set pointer for array Load the Count Set 1st element as largest data Decrement the count If A.LARGEST NUMBER IN AN ARRAY OF DATA AIM: To find the largest number in an array of data using 8085 instruction set. 10) Decrement the count 11) Check for Zero of the count. ALGORITHM: PROGRAM: LXI MOV INX MOV DCR INX CMP JNC MOV DCR JNZ STA HLT H. 6) Increment the pointer 7) Compare the content of memory addressed by HL pair with that of A .

t k .OBSERVATION: Input: 05 (4200) ----.Array Size 0A (4201) F1 (4202) 1F (4203) 26 (4204) FE (4205) FE (4300) RESULT: sv Output: Thus the program to find the largest number in an array of data was executed t ie ka nu ru .

12) Store the smallest data in memory. go to step 6. 6) Increment the pointer 7) Compare the content of memory addressed by HL pair with that of A .t k . or if ZF = 1 go to next step.SMALLEST NUMBER IN AN ARRAY OF DATA AIM: To find the smallest number in an array of data using 8085 instruction set. t ie ka nu ru Set pointer for array Load the Count Set 1st element as largest data Decrement the count If A.reg < M go to AHEAD Set the new value as smallest Repeat comparisons till count = 0 Store the largest value at 4300 . 10) Decrement the count 11) Check for Zero of the count. ALGORITHM: PROGRAM: LXI MOV INX MOV DCR INX CMP JC MOV DCR JNZ STA HLT H.4200 B. If ZF = 0. 5) Decrement the count.M H A.reg. go to step 10 or if Carry = 0 go to step 9 9) Move the content of memory addressed by HL to A – reg.M B H M AHEAD A. 3) Increment the pointer 4) Get the first data in A – reg. 13) Terminate the program.M B LOOP 4300 LOOP: AHEAD: sv 1) Load the address of the first element of the array in HL pair 2) Move the count to B – reg. 8) If carry = 1.

OBSERVATION: Input: 05 (4200) ----.t k .Array Size 0A (4201) F1 (4202) 1F (4203) 26 (4204) FE (4205) 0A (4300) RESULT: sv Output: Thus the program to find the smallest number in an array of data was executed t ie ka nu ru .

If they are out of order.M C D.register become zero Decrement C –register content by 1 Repeat steps 3 to 9 till the value in C – register becomes zero REPEAT: t ie ka nu H. exchange the contents of A –register and Memory Decrement D –register content by 1 Repeat steps 5 and 7 till the value in D. LOOP: SKIP: Initialize HL pair as memory pointer Get the count at 4200 into C – register Copy it in D – register (for bubble sort (N-1) times required) Get the first value in A – register Compare it with the value at next location.A H M.4201 A.M H M SKIP B. 5. 4. 2.M M. 7. 9. 8.4200 C.C H.ARRANGE AN ARRAY OF DATA IN ASCENDING ORDER AIM: To write a program to arrange an array of data in ascending order ALGORITHM: PROGRAM: LXI MOV DCR MOV LXI MOV INX CMP JC MOV MOV DCX MOV INX DCR JNZ DCR JNZ HLT sv 1. 3. 6.B H D LOOP C REPEAT ru . 10.t k .

t ie ka nu ru .OBSERVATION: Input: 4200 4201 4202 4203 4204 4205 4200 4201 4202 4203 4204 4205 05 (Array Size) 05 04 03 02 01 05(Array Size) 01 02 03 04 05 RESULT: sv Output: Thus the given array of data was arranged in ascending order.t k .

t k . 6. exchange the contents of A –register and Memory Decrement D –register content by 1 Repeat steps 5 and 7 till the value in D. 10.register become zero Decrement C –register content by 1 Repeat steps 3 to 9 till the value in C – register becomes zero REPEAT: t ie ka nu H.M H M SKIP B. 7. 8.4200 C.ARRANGE AN ARRAY OF DATA IN DESCENDING ORDER AIM: To write a program to arrange an array of data in descending order ALGORITHM: PROGRAM: LXI MOV DCR MOV LXI MOV INX CMP JNC MOV MOV DCX MOV INX DCR JNZ DCR JNZ HLT sv 1.C H. 3.A H M. 9. LOOP: SKIP: Initialize HL pair as memory pointer Get the count at 4200 into C – register Copy it in D – register (for bubble sort (N-1) times required) Get the first value in A – register Compare it with the value at next location.M M. If they are out of order.B H D LOOP C REPEAT ru .M C D.4201 A. 2. 4. 5.

t k .OBSERVATION: Input: 4200 4201 4202 4203 4204 4205 4200 4201 4202 4203 4204 4205 05 (Array Size) 01 02 03 04 05 05(Array Size) 05 04 03 02 01 RESULT: sv Output: Thus the given array of data was arranged in descending order. t ie ka nu ru .

M A B.4150 A.A A A B H M H M. t ie LXI MOV ADD MOV ADD ADD ADD INX ADD INX MOV HLT ka H.t k .BCD TO HEX CONVERSION AIM: To convert two BCD numbers in memory to the equivalent HEX number using 8085 instruction set ALGORITHM: 1) 2) 3) 4) 5) PROGRAM: OBSERVATION: Input: Output: RESULT: 4150 : 02 (MSD) 4151 : 09 (LSD) 4152 : 1D H sv Initialize memory pointer to 4150 H Get the Most Significant Digit (MSD) Multiply the MSD by ten using repeated addition Add the Least Significant Digit (LSD) to the result obtained in previous step Store the HEX data in Memory Thus the program to convert BCD data to HEX data was executed.A Initialize memory pointer MSD X 2 Store MSD X 2 MSD X 4 MSD X 8 MSD X 10 Point to LSD Add to form HEX Store the result nu ru .

reg for Most significant Byte Clear Accumulator Get HEX data Count the number one by one Adjust for BCD count nu ru Store the Least Significant Byte Store the Most Significant Byte .register Perform repeated addition for C number of times Adjust for BCD in each step Store the BCD data in Memory t ie LXI MVI XRA MOV ADI DAA JNC INR DCR JNZ STA MOV STA HLT ka H.M 01 LOOP1 D C LOOP2 4151 A.00 A C.HEX TO BCD CONVERSION AIM: To convert given Hexa decimal number into its equivalent BCD number using 8085 instruction set ALGORITHM: 1) 2) 3) 4) 5) PROGRAM: LOOP2: LOOP1: OBSERVATION: Input: Output: RESULT: Thus the program to convert HEX data to BCD data was executed.D 4152 Initialize memory pointer Clear D.4150 D.t k . 4150 : FF 4151 : 55 (LSB) 4152 : 02 (MSB) sv Initialize memory pointer to 4150 H Get the Hexa decimal number in C .

9. 5.t k . 8. 4.A 0F SUB1 4201 A.register and move to B – register Mask the upper nibble of the Hexa decimal number in A – register Call subroutine to get ASCII of lower nibble Store it in memory Move B –register to A – register and mask the lower nibble Rotate the upper nibble to lower nibble position Call subroutine to get ASCII of upper nibble Store it in memory Terminate the program. ALGORITHM: 1. 7.B F0 Get Hexa Data nu 0A SKIP 07 30 Mask Upper Nibble Get ASCII code for upper nibble Mask Lower Nibble SUB1 Get ASCII code for lower nibble 4202 ru . 6. PROGRAM: sv SUB1: SKIP: t ie LDA MOV ANI CALL STA MOV ANI RLC RLC RLC RLC CALL STA HLT CPI JC ADI ADI RET ka 4200 B. 2.HEX TO ASCII CONVERSION AIM: To convert given Hexa decimal number into its equivalent ASCII number using 8085 instruction set. Load the given data in A. 3.

t k .OBSERVATION: Input: Output: 4200 4201 4202 E4(Hexa data) 34(ASCII Code for 4) 45(ASCII Code for E) RESULT: sv Thus the given Hexa decimal number was converted into its equivalent ASCII Code. t ie ka nu ru .

Else proceed to next step. 7. 5. Subtract 07 H from A – register Store the result Terminate the program Thus the given ASCII character was converted into its equivalent Hexa Value. 6. jump to step6. PROGRAM: OBSERVATION: Input: Output: RESULT: 4500 4501 31 0B sv SKIP: Load the given data in A.ASCII TO HEX CONVERSION AIM: To convert given ASCII Character into its equivalent Hexa Decimal number using 8085 instruction set. t ie LDA SUI CPI JC SUI STA HLT ka 4500 30 0A SKIP 07 4501 nu ru .t k . 3.register Subtract 30 H from A – register Compare the content of A – register with 0A H If A < 0A H. 2. ALGORITHM: 1. 4.

4.SQUARE OF A NUMBER USING LOOK UP TABLE AIM: To find the square of the number from 0 to 9 using a Table of Square. 2. Initialize HL pair to point Look up table Get the data .00 B A.A B. 5.FF 4151 ka Initialsie Look up table address Get the data Check input > 9 if yes error Error Indication Add the desired Address Store the result Terminate the program nu ru . Check whether the given input is less than 9. If yes go to next step else halt the program Add the desired address with the accumulator content Store the result PROGRAM: AFTER: LOOKUP TABLE: 4125 4126 4127 4128 4129 4130 4131 4132 4133 01 04 09 16 25 36 49 64 81 sv t ie LXI LDA CPI JC MVI STA HLT MOV MVI DAD MOV STA HLT C.M 4151 H. 6. 3.4125 4150 0A AFTER A. ALGORITHM: 1.t k .

sv Output: t ie ka nu ru .t k .OBSERVATION: Input: Output: 4150: 05 4151 25 (Square) Input : 4150: 11 4151: FF (Error Indication) RESULT: Thus the program to find the square of the number from 0 to 9 using a Look up table was executed.

sv INTERFACING WITH 8085 t ie ka nu ru .t k .

Control words should be written into the control register of 8251. The USART accepts data characters from the CPU in parallel format and then converts them into a continuous serial data stream for transmission. These control signals define the complete functional definition of the 8251 and must immediately follow a RESET operation. By selecting the appropriate baud factor sync mode.INTERFACING 8251 (USART) WITH 8085 PROCESSOR AIM: To write a program to initiate 8251 and to check the transmission and reception of character THEORY: The 8251 is used as a peripheral device for serial communication and is programmed by the CPU to operate using virtually any serial data transmission technique. The CPU can read the status of USART ant any time. MODE INSTRUCTION WORD 2. Simultaneously. Parity and Stop bits required to work with asynchronous data communication. the 8251 can be operated in Synchronous mode. COMMAND INSTRUCTION WORD 1. MODE INSTRUCTION WORD This format defines the Baud rate. Initializing 8251 using the mode instruction to the following conditions 8 Bit data No Parity Baud rate Factor (16X) 1 Stop Bit gives a mode command word of 01001110 = 4E (HEX) sv t ie ka nu ru . These control words are split into two formats: 1. it can receive serial data streams and convert them into parallel data characters for the CPU. the 8251 must be loaded with a set of control words generated by the CPU. Prior to starting data transmission or reception. These include data transmission errors and control signals.t k . Character length.

SYNCHRONOUS MODE S2 S1 EP PEN L2 L1 B2 B1 BAUD RATE FACTOR 1 0 0 1 (1X) (16X) CHARACTR LENGTH 0 1 0 0 0 1 6 7 BITS BITS PARITY ENABLE 1= ENABLE 0 = DISABLE EVEN PARITY GEN/CHECK 0 =ODD 1 = EVEN NUMBER OF STOP BITS 0 1 0 0 0 1 1.t k .MODE INSTRUCTION .5 1 BIT BIT sv t ie ka 0 0 SYNC MODE 1 1 (64X) 1 1 8 BITS 5 BITS nu INVALID ru 1 1 2 BIT .

to return to the mode instruction format.ASYNCHRONOUS MODE S2 S1 EP PEN L2 L1 B2 B1 CHARACTER LENGTH 0 1 0 1 0 0 1 1 5 BITS 6 BITS 7 BITS 8 BITS PARITY ENABLE 1= ENABLE 0 = DISABLE EVEN PARITY GEN/CHECK 0 =ODD 1 = EVEN EXTERNAL SYNC DETECTS 1 = SYSDET IS AN INPUT 0 = SYSDET IS AN IOUTPUT SINGLE CHARACTER SYNC 1 = SINGLE SYNC CHARACTER 0 = DOUBLE SYNC CHARACTER 2. and forces RTS output to zero.t k . sv t ie ka nu ru . Thus the control word 37 (HEX) enables the transmit enable and receive enable bits. forces DTR output to zero. the master reset bit in the command instruction word can be set to initiate an internal reset operation which automatically places the 8251 back into the mode instruction format. The command instructions can be written into 8251 at any time in the data block during the operation of the 8251. COMMAND INSTRUCTION WORD This format defines a status word that is used to control the actual operation of 8251.MODE INSTRUCTION . Command instructions must follow the mode instructions or sync characters. resets the error flags. All control words written into 8251 after the mode instruction will load the command instruction.

OE.EH IR RTS ER SBRK RXE DTR TXEN TRANSMIT ENABLE 1=Enable 0 = Disable DATA TERMINAL READY HIGH will force DTR Output to Zero RECEIVE ENABLE 1=Enable 0 = Disable SEND BREAK CHARACTER 1 = Forces TXD LOW 0 = Normal Operation ERROR RESET 1=Reset Error Flags PE.FE REQUEST TO SEND HIGH will force RTS Output to Zero sv t ie ka nu ru COMMAND INSTRUCTION FORMAT .t INTERNAL RESET HIGH Returns 8251 to Mode Instruction Format ENTER HUNT MODE 1= Enable a Search for Sync Characters( Has No Effect in Async mode) k .

Initialise timer (8253) IC Move the mode command word (4E H) to A -reg Output it to port address C2 Move the command instruction word (37 H) to A -reg Output it to port address C2 Move the the data to be transferred to A -reg Output it to port address C0 Reset the system Get the data through input port address C0 Store the value in memory Reset the system PROGRAM: OBSERVATION: Output: RESULT: Thus the 8251 was initiated and the transmission and reception of character was done successfully. 7. 6. 2. 5. 4500 41 sv t ie MVI OUT MVI OUT MVI OUT LXI MVI OUT MVI OUT MVI OUT RST ORG IN STA RST A. 11.00 C8H H. 8.36H CEH A.41 C0 1 4200 C0 4500 1 ka nu ru .4E C2 A.ALGORITHM: 1. 4.37 C2 A.0AH C8H A. 9. 10. 3.t k .4200 A.

10 D0 A A A A.18 C8 A.INTERFACING ADC WITH 8085 PROCESSOR AIM: To write a program to initiate ADC and to store the digital data in memory PROGRAM: OBSERVATION: RESULT: Thus the ADC was initiated and the digital data was stored at desired location sv LOOP: MVI OUT MVI OUT MVI OUT XRA XRA XRA MVI OUT IN ANI CPI JNZ IN STA HLT A.t k .00 D0 D8 01 01 LOOP C0 4150 Compare the data displayed at the LEDs with that stored at location 4150 t ie ka nu ru .10 C8 A.

t k .04 (appx. the output is +5V.00 … 4. APPARATUS REQUIRED: THEORY: DAC 0800 is an 8 – bit DAC and the output voltage variation is between – 5V and + 5V. saw tooth and triangular wave. Outputting digital data 00 and FF at regular intervals. with FF H as input. Similarly. with 00 H as input to DAC.4. sv • • 8085 Trainer Kit DAC Interface Board t ie ka nu Output Voltage .5.00 .4.96 5.The output voltage varies in steps of 10/256 = 0. etc. Input Data in HEX 00 01 02 … 7F … FD FE FF Referring to Table1.92 4. The port address of DAC is 08 H. results in different wave forms namely square. The digital data input and the corresponding output voltages are presented in the Table1.96 .INTERFACING DAC WITH 8085 AIM: To interface DAC with 8085 to demonstrate the generation of square. to DAC.00 ru . the analog output is – 5V.).92 … 0. triangular..

Else go to step 7. 3. If accumulator content is zero go to step2. t ie ka nu ru . 2. 6. Load value (FF) to Accumulator Move the accumulator content to DAC Decrement the accumulator content by 1. 8. Repeat Steps 3 and 4. 4. 5.ALGORITHM: (a) Square Wave Generation 1. 3. 4. 5. Repeat Steps 2 to 5 (b) Saw tooth Wave Generation 1.t k . 3. If accumulator content is zero proceed to next step. Load the initial value (00) to Accumulator and move it to DAC Call the delay program Load the final value(FF) to accumulator and move it to DAC Call the delay program. 9. Else go to step 3. 2. 4. 7. Load the initial value (00) to Accumulator Move the accumulator content to DAC Increment the accumulator content by 1. (c) Triangular Wave Generation 2. sv Load the initial value (00) to Accumulator Move the accumulator content to DAC Increment the accumulator content by 1.

00 Port address of DAC A L1 START ru .t k .05 C.FF Port address of DAC DELAY START B.FF C L2 B L1 (b) Saw tooth Wave Generation sv DELAY: L1: L2: START: L1: t ie MVI OUT INR JNZ JMP ka nu A.00 Port address of DAC DELAY A.PROGRAM: (a) Square Wave Generation START: MVI OUT CALL MVI OUT CALL JMP MVI MVI DCR JNZ DCR JNZ RET A.

00 A.L Port address of DAC L L2 START RESULT: Thus the square.(c) Triangular Wave Generation START: L1: MVI MOV OUT INR JNZ MVI MOV OUT DCR JNZ JMP L.L Port address of DAC L L1 L.t k . triangular and saw tooth wave form were generated by interfacing DAC with 8085 trainer kit. sv L2: t ie ka nu ru .FF A.

LSB of count. CRO. Connect the CLK 0 to the debounce circuit and execute the following program. Let us see the channel in mode0. . the output will become high until reloaded again. the output will remain low following the rising edge of the gate input.C power supply. hence the output will remain low for the full count after any rising edge of the gate input. Regulated D. The output will go high on the terminal count.INTERFACING 8253 (TIMER IC) WITH 8085 PROCESSOR AIM: To interface 8253 Programmable Interval Timer to 8085 and verify of 8253 in six different modes.Channel 0 in mode 0.t k . sv 1) 2) 3) 4) 5) 8085 Microprocessor toolkit. . APPARATUS REQUIRED: the operation MODE 0-Interrupt On Terminal Count:The output will be initially low after mode set operation. the output will remain low while counting and on terminal count. It is retriggerable. 30H OUT CEH MVI A. ru . MODE 1-Programmable One Shot:After loading the count.MSB of count. 8253 Interface board. After giving ‘x’ clock pulses. VXT parallel bus. we may notice that the output goes high. PROGRAM: MVI A. After loading the counter. 00H OUT C8H HLT It is observed in CRO that the output of channel 0 is initially low. t ie ka nu . 05H OUT C8H MVI A.

. PROGRAM: MVI A. .MSB of count. 00H OUT C8H OUT DOH HLT . PROGRAM: MVI A. Execute the program and give clock pulses through the debounce logic and verify using CRO.Channel 0 in mode 3. MODE 3-Square Generator: It is similar to mode 2 except that the output will remain high until one half of the count and goes low for the other half provided the count is an even number. sv t ie ka nu . . 36H OUT CEH MVI A. The period from one output pulse to next equals the number of input count in the count register. This program divides the program clock by 10 and thus the Output at channel 0 is 150 KHz. the present period will not be affected. 05H OUT C8H MVI A.t k .LSB of count. If the count register is reloaded between output pulses. . 0AH OUT C8H MVI A. If the count is odd the output will be high for (count +1)/2 counts. OUT 0 goes low as clock pulses and after triggering It goes back to high level after five clock pulses.LSB of count. 00H OUT C8H HLT We utilize mode 3 to generate a square wave of frequency 150 kHz at Channel 0. ru .Trigger Gate 0. The output will be low for one period of the input clock. . MODE 2-Rate Generator: It is a simple divide by N counter. . This mode is used for generating baud rate of 8251. 32H OUT CEH MVI A. .Channel 0 in mode 1.Set the jumper so that the clock of 8253 is given a square wave of Frequency 1.The following program initializes channel 0 of 8253 in Mode 1 and also initializes triggering of gate.5 MHz.MSB of count. but the subsequent period will reflect a new value.

When the terminal count is reached. Mode 1 and mode 3 was verified. This mode can be used for interrupt generation. On terminal count. the counter is retrigerrable. sv t ie ka nu ru . the output will go low for one clock period and becomes high again. This mode can be used for interrupt generation. On Terminal count.MODE 4-Software Triggered Strobe: The output is high after the mode is set and also during counting. RESULT: Thus the 8253 PIT was interfaced to 8085 and the operations for mode 0. the output will go low for one clock period and becomes high again.t k . MODE 5-Hardware Triggered Strobe: Counter starts counting after rising edge of trigger input and the output goes low for one clock period.

Clear display.M C0H DELAY H D LOOP START B.t k . A0H C. A.CCH .90H . C2H A. 8279 Interface board.INTERFACING 8279 KEYBOARD/DISPLAY CONTROLLER WITH 8085 MICROPROCESSOR AIM: To interface 8279 Programmable Keyboard Display Controller to 8085 Microprocessor.0FH . ka H. A. Regulated D.C power supply. VXT parallel bus.Initialize counter. FFH C LOOP1 B LOOP2 nu ru .10H C2H .4130H D. APPARATUS REQUIRED: PROGRAM: START: sv 1) 2) 3) 4) LOOP: DELAY: LOOP2: LOOP1: t ie LXI MVI MVI OUT MVI OUT MVI OUT MOV OUT CALL INX DCR JNZ JMP MVI MVI DCR JNZ DCR JNZ RET 8085 Microprocessor toolkit.Set Mode and Display.Write Display C2H A.

4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 413A 413B 413C 413D 413E 413F .FF –FF –FF –FF –FF –FF –FF –FF –98 –68 -7C -C8 -1C -29 -FF -FF RESULT: Thus 8279 controller was interfaced with 8085 and program for rolling display was executed successfully.Pointer equal to 4130 . sv t ie ka nu ru .t k .FF repeated eight times.

t k .sv t ie 8051 MICROCONTROLLER PROGRAMS ka nu ru .

A HERE nu ru . Add the two data Store the result in memory pointed by DPTR t ie ORG CLR MOV ADD MOV MOVX SJMP ka 4100 C A. 2.t k . 4.#4500 @DPTR.#data1 A.ADDITION OF TWO 8 – BIT NUMBERS AIM: To perform addition of two 8 – bit numbers using 8051 instruction set. ALGORITHM: 1.#data2 DPTR. sv HERE: Clear C – register for Carry Get the data immediately . PROGRAM: OBSERVATION: Input: Output: 66 23 89 (4500) RESULT: Thus the program to perform addition of two 8 – bit numbers using 8051 instruction set was executed. 3.

sv HERE: Clear C – register for Carry Get the data immediately . 2.#data1 A. 3.SUBTRACTION OF TWO 8 – BIT NUMBERS AIM: To perform Subtraction of two 8 – bit numbers using 8051 instruction set. 4.t k . ALGORITHM: 1. Subtract the two data Store the result in memory pointed by DPTR t ie ORG CLR MOV SUBB MOV MOVX SJMP ka 4100 C A.#4500 @DPTR.#data2 DPTR. PROGRAM: OBSERVATION: Input: Output: 66 23 43 (4500) RESULT: Thus the program to perform subtraction of two 8 – bit numbers using 8051 instruction set was executed.A HERE nu ru .

t k . 3.A HERE ru .A DPTR A.B @DPTR. Store the results. The lower order of the result is in A – reg. HERE: t ie ka nu 4100 C A. 6. PROGRAM: ORG CLR MOV MOV MUL MOV MOVX INC MOV MOVX SJMP sv Get the data in A – reg. Multiply the two data The higher order of the result is in B – reg. 2. 5.#4500 @DPTR.#data1 B.MULTIPLICATION OF TWO 8 – BIT NUMBERS AIM: To perform multiplication of two 8 – bit numbers using 8051 instruction set. ALGORITHM: 1. Get the value to be multiplied in B – reg.#data2 AB DPTR. 4.

sv t ie ka nu ru .OBSERVATION: Input: Output: 80 80 00 (4500) 19 (4501) RESULT: Thus the program to perform multiplication of two 8 – bit numbers using 8051 instruction set was executed.t k .

The remainder is in B – reg. t ie ka nu 4100 C A.#data1 B.A HERE ru . 3. 6. PROGRAM: ORG CLR MOV MOV DIV MOV MOVX INC MOV MOVX SJMP sv HERE: Get the data in A – reg. 5.#data2 AB DPTR.#4500 @DPTR. 2.DIVISION OF TWO 8 – BIT NUMBERS AIM: To perform division of two 8 – bit numbers using 8051 instruction set.A DPTR A. 4.B @DPTR.t k . Divide the two data The quotient is in A – reg. ALGORITHM: 1. Store the results. Get the value to be divided in B – reg.

OBSERVATION: Input: Output: 05 03 01 (4500) 02 (4501) RESULT: Thus the program to perform multiplication of two 8 – bit numbers using 8051 instruction set was executed. sv t ie ka nu ru .t k .

30 DPTR.#data1 A.RAM ADDRESSING AIM: To exhibit the RAM direct addressing and bit addressing schemes of 8051 microcontroller. 2.#data2 A.A HERE sv HERE: HERE: For Bit addressing.#data2 A. ALGORITHM: 1.A HERE ru .t k .3 R0.#data1 A.#4500 @DPTR. Select Bank 1 of RAM by setting 3rd bit of PSW Using Register 0 of Bank 1 and accumulator perform addition For direct addressing provide the address directly (30 in this case) Use the address and Accumulator to perform addition Verify the results t ie SETB MOV MOV ADD MOV MOVX SJMP ka nu PSW. 3. 5.#4500 @DPTR.R0 DPTR. PROGRAM: Bit Addressing: Direct Addressing: MOV MOV ADD MOV MOVX SJMP 30. 4.

sv 54 25 t ie 79 (4500) ka nu ru .OBSERVATION: Bit addressing: Input: Output: 54 25 79 (4500) Direct addressing: Input: Output: RESULT: Thus the program to exhibit the different RAM addressing schemes of 8051 was executed.t k .

t B2 0 1 0 1 k . The motor under our consideration uses 2 – phase scheme of operation. sv • • A1 1 0 0 1 t ie Clockwise B1 A2 0 0 1 0 1 0 0 1 8051 Trainer Kit Stepper Motor Interface Board ka B2 1 0 1 0 nu A1 1 0 0 1 ru Anti . In order to vary the speed of the motor. any two adjacent stator windings are energized. direction of motor. In this scheme. The switching condition for the above said scheme is shown in Table. the values stored in the registers R1. R2. R3 can be changed appropriately. The rotor motion occurs in a stepwise manner from one equilibrium position to next.Clockwise B1 A2 0 1 1 0 1 0 0 0 .INTERFACING STEPPER MOTOR WITH 8051 AIM: To interface stepper motor with 8051 parallel port and to vary speed of motor. APPARATUS REQUIRED: THEORY: A motor in which the rotor is able to assume only discrete stationary angular position is a stepper motor.

Decrement the count in R0.#04 A.#4500H R0.t k . Pop up the values in stack and increment it.AGAIN START ru . 4.#FFC0H R2. Call the delay program Send the control word for motor rotation to the external device.DLY R1. 3. 7.#FFH R3. 10. Perform steps 1 to 9 repeatedly. PROGRAM: sv START: AGAIN: DLY1: DLY: t ie ORG MOV MOV MOVX PUSH PUSH MOV MOV MOV MOV DJNZ DJNZ DJNZ MOVX POP POP INC DJNZ SJMP ka nu 4100 DPTR. 04H R1. 5. 2.ALGORITHM: 1. 8. #FFH R3.DLY1 @DPTR.DLY1 R2. 9.@DPTR DPH PDL DPTR. Store the look up table address in DPTR Move the count value (04) to one of the register (R0) Load the control word for motor rotation in accumulator Push the address in DPTR into stack Load FFC0 in to DPTR. If zero go to next step else proceed to step 3.A DPL DPH DPTR R0. 6.

t ie ka nu ru .DATA: 4500: 09. 0A RESULT: sv Thus the speed and direction of motor were controlled using 8051 trainer kit. 05.t k . 06.

Referring to Table1. with FF H as input.00 … 4.INTERFACING DAC WITH 8051 AIM: To interface DAC with 8051 parallel port to demonstrate the generation of square. Similarly. the analog output is – 5V. APPARATUS REQUIRED: sv • • 8051 Trainer Kit DAC Interface Board t ie Input Data in HEX 00 01 02 … 7F … FD FE FF THEORY: DAC 0800 is an 8 – bit DAC and the output voltage variation is between – 5V and + 5V. saw tooth and triangular wave.4.96 5.4.00 .00 .).96 . results in different wave forms namely square.The output voltage varies in steps of 10/256 = 0. Outputting digital data 00 and FF at regular intervals. etc.92 4. with 00 H as input to DAC.. triangular.5. ka nu ru Output Voltage . to DAC.04 (appx.92 … 0. The digital data input and the corresponding output voltages are presented in the Table below . the output is +5V.t k .

4. Saw tooth Wave Generation Move the port address of DAC to DPTR Load the initial value (00) to Accumulator Move the accumulator content to DAC Increment the accumulator content by 1. 3. 8. Else go to step 3. 3. 2. Load value (FF) to Accumulator Move the accumulator content to DAC Decrement the accumulator content by 1. Triangular Wave Generation Move the port address of DAC to DPTR Load the initial value (00) to Accumulator Move the accumulator content to DAC Increment the accumulator content by 1. 5. 2. 6. ru . 4. Square Wave Generation Move the port address of DAC to DPTR Load the initial value (00) to Accumulator and move it to DAC Call the delay program Load the final value(FF) to accumulator and move it to DAC Call the delay program. 5. If accumulator content is zero go to step2.t k . If accumulator content is zero proceed to next step. 5. ka nu (c) 1. 7. Else go to step 7. 3. 6. Repeat Steps 3 and 4. 4.ALGORITHM: (a) 1. Repeat Steps 2 to 5 sv t ie (b) 1. 2. 9.

#FF R2.PORT ADDRESS OF DAC A.A DELAY START R1.LOOP START (b) Saw tooth Wave Generation sv DELAY: LOOP: HERE: LOOP: t ie ORG MOV MOV MOVX INC SJMP ka nu 4100 DPTR.t k .HERE R1.#00 @DPTR.A A LOOP ru .#00 @DPTR.#FF @DPTR.A DELAY A.PROGRAM: (a) Square Wave Generation START: ORG MOV MOV MOVX LCALL MOV MOVX LCALL LJUMP MOV MOV DJNZ DJNZ RET SJMP 4100 DPTR.PORT ADDRESS OF DAC A.#05 R2.

triangular and saw tooth wave form were generated by interfacing DAC with 8051 trainer kit.A A LOOP2 START START: LOOP1: RESULT: Thus the square.#00 @DPTR.(c) Triangular Wave Generation ORG MOV MOV MOVX INC JNZ MOV MOVX DEC JNZ LJMP 4100 DPTR.A A LOOP1 A.t k .#FF @DPTR.PORT ADDRESS OF DAC A. sv LOOP2: t ie ka nu ru .

t ie ka nu ru .#05H B. 16. The results stored in registers will be displayed in Project window. 13. select START/STOP Debug option. PROCEDURE: 1. 19. In project window the status of all the registers will be displayed. 7. 4. Right Click the Source group and click “Add files to Source group” A new window will open. 11. 5. 8. 3.PROGRAMMING 8051 USING KEIL SOFTWARE AIM: To perform arithmetic operations in 8051 using keil software. Errors if any will be displayed.asm” Click Add. 10. 17. 15. 9. Click Go from Debug Menu. 18. 6.t k . Select our file with extension “. From Debug menu.asm” In project window click the tree showing TARGET A source group will open.#02H AB sv Click Keil Vision2 icon in the desktop From Project Menu open New project Select the target device as ATMEL 89C51 From File Menu open New File Type the program in Text Editor Save the file with extension “. 2. 14. 12. PROGRAM: ORG CLR MOV MOV DIV 4100 C A. Go to project window and right click Source group again Click Build Target (F7). Stop the Debug process before closing the application.

t ie ka nu ru .OBSERVATION: A: 02 B: 01 SP:07 Note that Stack pointer is initiated to 07H RESULT: sv Thus the arithmetic operation for 8051 was done using Keil Software.t k .

#FFC2 A.#00 . PROCEDURE: PROGRAM: MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV sv 1.# R1. Read the key from user 6. Display ‘O’ to indicate open. Initialize the password 4.SYSTEM DESIGN USING MICROCONTROLLER AIM: To Design a microcontroller based system for simple applications like security systems combination lock etc. Read number of bytes in the password 2. If entered password equal to initialized password.#50 R3.# 53H.#51 R0.# 52H. 8.# 54H. t ie ka nu ru 51H. Display ‘E’ to indicate Error.#08 DPTR. Initialize the Keyboard Display IC (8279) to get key and Display 5.#04 R2. Blank the display 3. Compare with the initialized password 7. Repeat the steps 6 and 7 to read next key 9. If it is not equal.t k .

NEQ R1 R3.t k .#FFCO @DPTR.@R1 A.A A.A YY .#07 WAIT A.LOOP: AGAIN: WAIT: XX: MOVX MOV MOVX MOV MOVX MOV MOV MOVX DJNZ MOV MOVX ANL JZ MOV MOVX MOV MOVX MOV MOV CJNE INC DJNZ MOV MOV MOVX SJMP @DPTR.#FFCO A.#FFCO A.A A.#68 @DPTR.#90 @DPTR.50H.A DPTR.#FFCO A.AGAIN DPTR.#FFC2 A.LOOP DPTR.@DPTR A.A XX RESULT: Thus the program for security lock system was executed sv t ie NEQ: YY: ka MOV MOV MOVX SJMP nu ru DPTR.#40 @DPTR.@DPTR @R0.#FF DPTR.A A.A R2.A A.#CC @DPTR.#OC @DPTR.

Sign up to vote on this title
UsefulNot useful