0% found this document useful (0 votes)
48 views

MPMC Lab

Uploaded by

SpectroMan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
48 views

MPMC Lab

Uploaded by

SpectroMan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 62
ANNA UNIVERSITY REGIONAL CAMPUS, COIMBATORE. LABORATORY RECORD BOOK 1 Each Experiment should begin on a new page 1 The name of the Experiment should be written in capital letters on the top of the page. Experiment number with date should be written at the top left hand cover. Each report should contain the following items. * Aim of the Experiment © Apparatus required * Procedure * Model Calculations * Results / Discussions All the above should be neatly written on the right hand page of the record. + Neat Circuit diagram * Specifications / Design details * Tabulations The above should be written / drawn on the left hand side page of the record using Pen / 2B Pencil. 1 Graph sheets are attached at the end of the record note. % Special sheet like semilog should be firmly pasted on to the record. 3 Before writing the report, the student should get the corresponding observations approved by the Faculty In-charge and carry over the marks obtained to the record, 1 The report should be completed in all respects and submitted in the very next class. LISLOF EXPERIMENTS Name of the Experiment Sigrstare Basic Arithmetic and Logical operations using 8086 Move a data block without overlap using 8086 Code conversion, Decimal arithmetic and Matrix operations using 8086 Floating point operations, String ‘manipulations, Sorting and Searching using 8086 Password checking, Print RAM size and System date using 8086 Counters and Time Delay using 8086 Basic Arithmetic and Logical operations using 8051 Square and Cube program, Find 2's complement of a numberusing 8051 Unpacked BCD to ASCII using 8051 Traffic light control using 8086/8051 Stepper motor control using 8086/8051 Digital clock using 8086/8051 Key board and Display using 8086/8051 Printer status using 8086/8051 Serial interface and Parallel interface usi 8086/8051 an AID and D/A interface and. Waveform Generation using 8086/8051 SECC CUEC CECE ELEEECEEEEEEEELEEL Ex.No.:1 913 |2020 BASIC ARITHM! |ETIC AND LOGICAL OPERATIONS Aim To write an assembly language program to perform an addition, subtraction, multiplication and division of two 8-bit numbers using 8086 microprocessor kit. Apparatus required S.No. 1TEM SPECIFICATION Microprocessor kit 8086 kit Power Supply +5.Vde Initialize the SI register to input data memory location Initialize the DI register to output data memory location Initialize the CL register to zero ¥or carry Get the 1* data into accumulator. ‘Add the accumulator with 2" data Check the carry flag, if not skip next line Increment carry (CL Reg) ‘Move the result from accumulator to m Also store carry register Halt ‘Mnemonics Comment ‘MOV SI, 2000H Initialize 2000 as Source Index MOV DI, 3000H Initialize 3000 as Destination Index’ MOV CL, 00H Clear carry register MOV_AX, [SI] Move the contents of SIregister to Accumulator ADD AX, [S12] | Add the contents of Accumulator with the second data Jump on no carry to store Tnerement carry Move the result from Accumulator to destination index Subtraction Algorithm Step 1: Initialize the SI register to input data memory location Step 2: Initialize the DI register to output data memory location Step 3: Initialize the CL register to zero for borrow Step 4: Get the 1* data into accumulator. Step 5: Subtract the accumulator with 2 data Step 6: Check the carry flag, if not set skip next line Step 7: Increment carry (CL Reg) Step 8: Move the result from accumulator to memory. Step 9: Also store carry register Step 10: Halt Program aan Mnemonics Com MOV SI, 2000H | Initialize 2000 as Source Index. MOV DI, 3000H_| Initialize 3000 as Destination Index. MOV CL, 00H Cleatyearry register MOV_AX, [SI]__| Move the contents of SI register to Accumulator ‘SUB AX, [SI+2] | Subtract the contents of ‘Accumulator with the second data INC STORE Jump on no carry to store INC CL, Increment carry NEG AX Negation of, MOV (Dil, AX | Move the sult orp Accumulator to destination index MOV [DI#2], CL | Moyé the carry to déstination index HLT pa of the program | oe Algorithm. Step 1: Get Multiplier into Accumulator From Memory Step2: Get Multiplicand Into BX Register Step 3: Step 4: Step 5: Step 6: Mnemonics Comment MOV AX, [20004] | Move the contents of 2000 to AX MOV BX, [20021] | Move the contents of 2002 to BX MUL BX Multiply AX and BX MOV [3000], AX _ | Move the result to 3000 MOV [3002], DX _ | Move the carry to 3002 HLT End of the program Get Dividend into Accumulator from Memory Get divisor Into BX Register Divide the two Store Lower Order Word From Accumulator into Memory Store Higher Order Word From DX Into Memory Halt ¥ Mnemonics Comment MOV AX, [2000H] | Move the contents of 2000 to AX MOV BX, [2002H] | Move the cafitents of 2002 to BX DIV BX Divide AX and BX | MOV [3000], AX | Moyé the result to 3000| MOV [3002], DX__| Move the carry to 3002 HLT End of the program dditior ony Output pul A = Data ‘Address Data 2001 BOO 3000 Ose 3001 60. 20028 —O0_ 03 3002H oF ena Yo) 3003 00, Subtraction Tnput Output Address Data Address Data 2000H 1 3000H Be eLUe 00 3001 “020 2002H o2— 30021 om 2003H 00 30034 oO. Input ‘Output ‘Address Data ‘Address Data 2000H pica 3000H Sp 2001H 0 3001 ©0 20024 Oe 3002 o4 20034 oO 3003H 00 Divisi Input Output ‘Address Data ‘Address Data 2000H 1 3000H 02 2001H ES 3001 2002H i == 2003H 6 = 4 4 4 4 4 4 ! 4 ‘ ‘ "Ty ey yy MYM YMMUNEHKMTUMUU UU EVE EHUVHVKUGUGCUOGUGEEES Aim To write an assembly language program for performing Logic Operation using 8086 microprocessor kit. Apparatus required S.No. 1TEM ‘SPECIFICATION QUANTITY 1._|_ Microprocessor kit 8086 kit 1 2 | Power Supply Beye 1 ‘Logic operation Algorithm ‘ Step 1: Get value into source index register Step 2: Perform AND, OR, XOR, NOT operation Step 3: Display results in destination register by incrementing. Step 4: Halt Program for Logic operation Memory | Label Mnemonics ‘Comment Address Mi MOV SI,1200 ‘Move memory location 1200 to source index MOV DI,1300 “Move memory Tocation 1300 to destination index MOV AX, [SI] ‘Move the contents of source index to AX register, AND AX,OFFDF ‘AND AX with Offdf MOV [DI], AX Move the AND operated value to DI OR AL,20 ‘OR AL with 20 MOV [DI+2], AL _ | Move the OR ed'value to DI incremented by 2 XOR AX, AX’ XOR AX with AX | MOV [DI*4], AX _ | Move XORed value to memory location Diva MOV BX, [SI+2] _ | Load4nother data from’source index and move it to BX NOT BX Pepform NOT operation on BX MOV [DI+6], BX _| Store the result in memory location DI+6 HLT ‘End of the program 4 A 4 A A A A A 4 4 4 4 2 4 e 4 4 4 ~~~,~~rrrwrevse w~wuvvuvvwe veveveve wueuveovgeuvuese MOVE A BLOCK OF DATA WITHOUT OVERLAP Ex.No:2 (Cet ocr ‘Aim sto wrt an Assembly Language Program (ALP) to mave a block of data without overlap Apparatus required S.No. TEM SPECIFICATION QUANTITY T. | Microprocessor kit 8086 kit T 2.__[ Power Supply. +5Vde T Step 1: _ Move the contents to DS Step 2: Place it in an array Step 3: Move the contents to sourc Step 4: Increment SI and DI Step 5: Loop it till it gets completed Step 6: End ¥ Program pcre Label Mnemonics Comment MOV SI,1200 MOV 1200 TO SI MOV Di,1300 MOV 1300 TODL, MOV CX,0006 ‘Assign Coumit Valug CX As 6 cD Clear Direction Flag a MOVSB ‘Copies A Single Byte and Increment Both SI And DI LOOP LI Répeat Till it Completes Block Transfer HLT End of the program pre Result: ‘Thus the above program was written executed and aa a ee ~~ -~~-~wwe w~vyvvvvuvevr weve vee eee eae CODE CONVERSION AND DECIMAL ARITHMETIC ou Aim To write an Assembly Language Program (ALP) for performing code conversion ASCII to Packed BCD and Packed BCD to ASCII operation and decimal arithmetic. Apparatus required S.No. TrEM ‘SPECIFICATION. QUANTITY T._| Microprocessor kit | 8086 kit I 2._| Power Supply #5 Vdc T ASCIL to Packed BCD Algorithm Step 1: Move ASCII numbers to AL and BL registers Step 2: AND operate with OF Step 3: Perform rotate right by 4 bits on dre value Step 4: Perform OR operation on the two values Step 5: Store the result in destination register. == \ Step6: HLT y | Program / ae Label ‘Mnemonics i, Comment MOV DI,1300 niialize DI by 1300 MOV BL,35 ‘Move ASCII value 35 to BL MOV AL,39 Move ASCII value 39 to AL "AND BL,OFH "AND BL with OF lower nibble masked "AND AL,OFH ‘AND AL with OF lower nibble masked MOV CL,04 Thitialize count value to 4 ROR BL, CL Rotate the value of BL right by 4 bits, both higher and ORAL BL OR AL and BL MOV (DI, AL Move the packed BCD number to destination indexed HLT TEnd of the program Packed BCD to ASCH Algorithm. itialize the memory location to the data pointer. Fanaa yea BCD to Unpacked by performing AND operation with OF Perform ADD operation on one value with 30 Perform ROL operation ‘on the other value and ADD with 30 Store the ASCII numbers in destination registers HLT Mnemonics Comment MOV DI,1400 Initialize destination index MOV SI,1300 Tnitialize source index MOV AL, [SI] Move the content of Sito AL ‘AND AL,OFH ‘AND AL with Of ‘ADD AL,30H ‘ADD AL with 30 MOV [DI], AL Move the ASCII value to DI MOV AL, [SI] Take the next value AND AL, FOH Mask higher order nibble MOV CL,04H Initialize the counter to 4 ROL AL, CL Rotate teft by 4 bits ‘ADD AL,30H’ (dd 30 AL MOV (DI + 1), AL Move the ASCII value to another ‘ALT End of the program 1 Desi ics Algorithm Step 1: Initialize the SI register to input data memory location Initialize the DI register to output data memory location ‘Step 3: Initialize the CL register to zero for carry Step 4: Get the first decimal data into accumulator. Add the accumulator with 2 data Step 6: Check the carry flag, if not skip next line Increment carry register Step 8: — Move the result from accumulator to memory, Step 9: Also store carry register Step 10: Halt - 4 4 ] 4 “ «4 A A A « 4“ é A é a a 4 4 4 4 4 4 4 Label | Mnemonics Comment MOV SI, 2000H Tnitialize 2000 as Source Index MOV _DI, 3000H Initialize 3000 as Destination Index MOV CL, 00H MOV_AX. [SI] Clear ca ster, ‘Move the contents of SI register to Accumulator ‘ADD AX, [SI+2] ‘Add the contents of Accumulator with the INC STORE, INC CL ump on no carry to store Tncrement carry : [MOV [DI], AX ‘Move the result from Accumulator to content in Dbl MOV _[DI+2], CL Move the cafty to destination index HLT End of the program ¢ 4 4 4 ‘ ( 4 4 4 FLOATING POINT OPERATIONS, STRING MANIPULATIONS, SORTING AND SEARCHING Aim To write an Assembly Language Program (ALP) to copy a string, sorting and searching. Apparatus required "SNe [ITEM ‘SPECIFICATION ‘QUANTITY dy Microprocessor kit 8086 kit T =! 2.__| Power Supply. +5:-V de T 1 String Manipulation Copying a string Algorithm Step 1: Initialize destination address Step 2: Initialize starting address Step 3: Initialize array size Step 4: Clear direction flag Step 5: Copy the contents of source into destination until count reaches zero Step 6: Stop the program Program Memory | Label Mnemonics Ga Address MOV SI,1200H Initialize destination address MOV DI,1300H7-_ | Initialize starting address MOV CX,00ys__ | Initialize array size CLD Clear direction flag MOVSB Copy the contents of source into destination LOOP LI Repeat the loop HLT Stop Output ‘Address: 1300H Moz Ht t ch ee ee Scarching a character inastring Algorithm Step 1: Initialize the extra segment. (ES) Step 2: Initialize the start of string in the BS. (D1) Step 3: ‘Move the number of elements in the string in CX register. Step 4: Move the byte to be searched in the AL register, Step: Scan forthe byte in ES. If the byte is found ZF=0, move the address pointed by ES: DI toBX. Program a Mnemonics Comment MOV DI,1300H Initialize destination address MOV SI, 1200H _| Initialize source address MOV CX, 0006H | Initialize array size CLD Clear direction flag MOV AL,06 Store the character to be found in AL SCASB Find AL, starting at DI INZLOOPI Repeat tll the value was found DECDI 7 _| Decrement DI MOV BL, [DI] aries to BL MOV (STI, BL ire itin squree indexed register LOOP BACK Continue thé Toop HLT End of the program Output ‘Address 1300H “i —} 1k 180SH Find and Replace a character in the strine Algorithm Program Step 1: Step 2: Step 3: Step 4: Initialize the extra segment. (ES) Initialize the start of string in the ES. (DI) ‘Move the number of elements in the string in CX regster. 1 to be searched in the AL register. Move the byt Store the ASCII code o' f the character that has to replace the scanned byte in BL Scan forthe byte in ES. Ifthe byte is not found, ZF#1 and repeat scanning. the byte is found, ZF=1.Move the content of BL register to ES:DI. Memory | Label Mnemonics Comment Address MOV DILI300NT | Initialize destination index 1300 MOV SI.1400 Initialize source index 1400 MOV CX.0006 | Initialize count value 6 CLD Clear direction flag MOV ALO® Store the content to AL (search) Store the content to BH (replace) BH30 BACK _| [Scan for the data [Repeat till the value was found Move to the address found data to BL ae LOOPI [Loop to the label BACK {End of the program Address 1300, Bow ei 1304 H 1305-41 ee ee ee ee ee _ Largest and smallest number in-an.attay ori ao Load starting address of array in to SI reg, Step2: Load length of array in CL reg: Step 3: Get the I" element into Accumulator Step 4: Update SI and CL registers Step 5: Compare Accumulator with next clement Step 6: Check carry flag, ifnot set skip next line Step 7: Swap accumulator with SI reg. Step 8: Decrement counter Step9: If not zero,go to step before Step 10: Else, store result. Step 11: Halt Program rie | te Mnemonics Comment MOV SI, 2000H Tnitialization of Input register MOV CL, [SI] Move the content of SI to CL INC SI r Tnorement SI MOV AL, [SI] fove\\he content of SI to AL DEC CL. Decrement CL, 2 INC SI Increment SI CMP AL, [SI] ‘Compate the AL content with SL INBIIB LI INB fof largest and JB for smallest MOV AL, [SJf Move the content of SI to AL LI DEC CL\ Decrement CL INZ12 Jump no zero L2 MOV DI.1300 Move 1300 address to DI MOV [DI], AL Move the result to the address 1300 HLT End of the program Ascending/ Descending order Algorithm Step 1: Load SI reg with pointer to array Step 2: Load array length to CL & CH for two counters Step 3: REPEAT: Get anelement into accurnulator Step 4: ‘NEXT: Compare with next element Step 5: Check carry flag, if set goto SKIP Step 6; ‘Swap elements of array Step 7: Decrement CL, ifnot zero go to REPEAT Step 8: Halt Program Memory agar Mnemonics Comtuaat MOV SI, 1200H _| initialize 1200 as Source Index MOVCL,[SI]__| Move Slio CL MOV 'SI.1200 | Move 1200 to ST MOVDL, [SI] | Move content of SIto DL INCSI Increment SI MOV AL, [SI]____| Move content of Sito AL INCSI Increment SI MOV BL, [Sify | Move Content of SIto BL CMP AL, BL ‘Compare AL, BL INBIIB LI INB for ascending and JB descending DEC SI Decrement SI MOV [SI], AL | Move AL to content of SI MOV AL, BL | Move BX content to AL IMP 12 amp to label L2 DEC SI Decremeht SI MOV [SI]. BL /_| Move BL to content of SI INCST Tncrement SI DEC DL\ Decrement DI INZI3 Result is not zero, jump to label L3 MOV SI, AL___| Move AL to content of SI DECCL Decrement CL INZIA Result is not zero, jump to label L4 HLT End of the program ExNo.s PASSWORD CHECKING, PRINT RAM SIZE AND SYSTEM DATE 20/ 10) 20> | Aim To write an Assembly Language Program (ALP) to password checking, print RAM size and system date Apparatus required canon eae TTEM ‘SPECIFICATION ‘QUANTITY, 1 T.__| Microprocessor kit 8086 kit 2._| Power Supply 5,V de T Program: Address Mnemonics PASSWORD IS MASM1234 DATA SEGMENT PASSWORD DB 'MASM1234" LEN EQU (S-PASSWORD) MSGI DB 10,i3,ENTER YOUR PASSWORD: $ MSG2 DB 10,13,";WELCOME TO ELECTRONICS WORLD!!$' MSG3 DB 10,13," INCORRECT PASSWORD!S" NEW DB 10,133" INST DB 10 DUP (0) DATA ENDS CODE SEGMENT CS: CODE, DS:DATA START: MOV AX, DATA MOV DS, AX. LEA DX, MSGI MOV AH.O9H INT 21H. MOV S1,00. UPI: MOV AH,08H INT 21H CMP AL,ODH JE DOWN: MOV [INST#SI, AL_ MOV DL, **" MOV AHH IMP UPL DOWN: MOV BX,00_ MOV CX,LEN, CHECK: MOV AL,INST+BX] MOV DL,[PASSWORD#BX] CMP AL, DL. INE FAIL. INC BX. LOOP CHECK, LEA DX,MSG2 MOV AH,09H INT2IH, IMP FINISH, FAIL: LEA DX,MSG3 MOV AH,009H INT 21H, FINISH: INT3 (CODE ENDS, END START END. =Today.asm Display month/day/year Feb Ist, 2012 A sCIS 206 Ken Howard. N -MODEL small e \ STACK 100h. DATA mess] DB 10, 13, "Today is8': 10=LF, 13=CR. CODE. Today PROC MOV AX, @data MOV DS.AX. MOV DX, OFFSET messl ; Move string to DX. MOV AH, 09h ; 09h call to display string (DX > AH> DOS) INT 21H ; Send to DOS =X year, DH month, DL da MOV AH, 2AH ; Get the date (appendix D) INT 21H ; Send to DOS, PUSH CX ; Move year to the stack MOV CX,0; Clear CX. ‘MOV CL, DL PUSH CX ; Move day to stack MOV CL, DH ; Move month > CL PUSH CX ; Move month to stack 0; Clear DH ET TILL LLARRREEEEAEED PLAY MONTH ###¥0040008eeeeunOSerO® division, 3 be in DX// —s Divide] DIV BX Divide (will be word sized) PUSH DX j Save remainder to stack ‘ADD CX, Li ‘Add one to counter_ MOV DX, 0 ; Clear the remainder CMP AX.0; SNE divider Ir quofen isnot 7er0, go 19 dividem™ POP DX ; Remove top of stack into DX ‘ADD DL01K; ADD 30h @) to DL MOV AI, 02h ; 02h to display AH (DL) INT 21H; Send to DOS LOOP divaispm ; If mote to do, divdispm again SLOOP subtracts | from CX. If non-zero, I MOV DL, ‘7; Character to display goes in DL ‘MOV AH, 02h ; 02h to display AH (DL) INT 21H ; Send to DOS —avecsnvovevorrseseecoteees DISPLAY DAY s#tsseoessenessenesnane Set up for division ; Dividend will be in DX/AX pair (4 bytes) = Quotient will be in AX ; Remainder will be in DX MOV DX, 0; Clear DX POP AX; Remove month from stack into AX MOV CX, 0: Initialize the counter ‘MOV BX, 10); Set up the divisor Divider: DIV BX ; Divide (will be word sized) PUSH DX ; Save remainder to stack ADD CX, 1 ; Add onto coyfiter MOV DX, 0 ; Clear théretfainder CMP AX.0; Compare quotient to zero INE divided ; If quoient is not zero, go to “divided.” divdispm: POP DX ; Remove top of stack ‘ADD DL, 30h ; ADD 30h (2) to DE MOV AH, 02h ; 02h to display AH (DL) INT 21H ; Send to DOS LOOP divdispd ; If more to do, divdispd again {LOOP subtracts | from CX. If non-zero, to MOV DL, ‘/ ; Character to display goes AH (DL) MOV AH, 02H ; 02h to display AH (DL) INT 21H; Send to DOS Taastoaanaswnassneanieaee® DISPLAY VEAR PPeenewavetnsnenenseeee ; Set up for division i id will be in DX/AX pair (4 bytes) it will be in AX, ler will be in DX 0; Clear DX , Remove mor 5 Set Dividem:, DIV BX ; Divide (will be word sized) PUSH DX ; Save remainder to stack ‘ADD CX, 1 Add one to counter MOV DX, the remainder CMP AX, 0 Compare quotient to 2er0 TNE divide; If quotient isnot zero , go to Dividem: POP DX; Remove top of slack DX "ADD DL,30h; ADD 30h (2) to DL. MOV AN, 02h ; 02h to display AH (DL) ‘CMP AX, 0; Compare qui LOOP divdispy ; If more to do, divdisp again LOOP substracts from CX. If non-zero, loop. MOV DL, ‘7 ; Character to display goes in DL. MOV AH, 2h ; 02h to display AH (DL) INT 21H ; Send to DOS MOV AH, 4ch ; INT21H ‘Today ENDP END Today MVIA.8OH OUT 83H(CR) MVIA,09H OUT 80H(PA) MVIA24H ‘OUT 81H(PB) MVIC28H, CALL DELAY MVIA, 12H OUT (SIH) PA, ‘OUT (81H) PB MVIC, OAH DELAY MVIA, 24H ‘OUT (80H) PA MVIA, 09H ‘OUT (81H) PB MVIC, 28H CALL DELAY, MVIA, 12H OUT PA. ‘OUT PB. MVIC, OAH CALL DELAY JMP START LXL Di Ram size: ‘ORG 0000H CLR PSW3, CLR PSW4 CPLA ‘ADD A, #O1H. MOV A.R3 ‘AGAIN: | SIMP AGAIN. Ex.No.:6 rol20r4 COUNTERS AND TIME DELAY Aim: To write an assembly language program in 8086 to Counters and Time Delay TTEM, ‘SPECIFICATION QUANTITY “Microprocessor kit 8086 kit I Power Supply 45 V de T Stepper Motor Mnemonics MODEL SMALL. DATA MSGIN DB ‘Enter delay duration (0-50): $' MSGI DB 'This is Microprocessor!’ DELAYTIME DW 0000H ‘CODE MOV DX,@DATA MOV DS. DX LEA DX.MSGIN MOV AH,O9H INT 21H. MOV AHOIH INT2IH, CMP ALDH; JENXT SUB AL,30H MOV DL,AL MOV AX,BX MOV CL,0AH MUL CL MOV BX,AX AND DX,00FFH ‘ADD BX,DX MOV DELAYTIME,BX ‘Counters and Time Delay ‘MOV CX,DELAY TIME MOV DL,10 ‘MOV AH,02H SWCOOKCKCHOHOHKOVLLVVTH VV VY HY ew eH — i ee PERE a ee MOV DL{SI] CMP DL'S” JENXT2 MOV AH,02H INT, ADD Sh POP DX MOV DI,DELAYTIME, MOV AHO INT IAh MOV BX,DX DELAY: MOV AHO INT IAh ‘SUB DX.BX ‘CMP DI,DX JA Delay LOOP LP NXT2: MOV AH.ACH INT 21H END pw RESULT: ‘Thus the output for the Counters gndf Time Delay was executed successfully. 41 BASIC ARITHMETIC AND LOGIC OPERATIONS | To write a program for basic arithmetic and logic operations 1 Apparatus required SNo-] TTEM SPECIFICATION QUANTITY —] T,__| Microprocessor kit BOSTKit T , 2._| Power Supply 45 V de T , ‘Addition f Algorithm } Step 1: Move the first value into register A. ' Step 2: Add the Accumulator with immediate value Step 3: Moye amemory location to DPTR Step 4: Display the result into the content of memory location | Step 5: Stop the program ' } Program f Meme | opende | tae | Mnemonis [| Comment TaD MOV A, #0 __| Mote fist value to Accumulator ' 2403 ‘ADD A, #05 ‘Addjaccumulator with second value » 90 4500 MOV DPTR, #4500) Mové a memory location to DPTR_ FO (OVX @DPTR, A} Move the aecumulaior vale to he memory , T03E TERE SIMP HERE | Shor jump to current locaton infinitely ‘Subtraction Algorithm Step 1: Move the first value into register A. Memory Topeade | Label | _ Mnemonics Comment 7403 ‘MOV A, #03 Move first value to Accumulator ao ‘ADD A, #02 “Add accumulator with second value 90 45 00) MOV DPTR, #4500 | Move a memory location to DPTR_ e MOVX @DPTR, A_| Move the accumulator value tothe memory 80 FE | HERE | SIMP HERE ‘Short jump to current location infinitely Step 1: Step 2: Step 3: Step 4: Get the multiplier in the accumulator. Get the multiplicand in the B register. Multiply A with B. Store the product in memory. Memory Memory | opcode | Label Mnemonics. Comment Fa05 MOV A, FOS [ior data accumulator 75 F002 MOV B02 ore daia2 in Brew Aa MULAB Multiply both 90.45 00 MSV DPTR, #9500 Initialize memory location FO (OVX @DFTR, A Store lower order result a INC DPTR Go to next memory location SFO MOVA,B Move the value in B to Accumulator and thea FO MOVX @DPTR,A ‘The value in accumulator to the location pointed by the external pointer SIMP Stop Division Algorithm Step 1: Get the Dividend in the accumulator, Step 2: Get the Divisor in the B register. Step 3: Divide A by B. Step 4: Store the Quotient and Remainder in memory. Program peers |Opcode Label. Mne Comm Address |OP* i a s TE) MOV A, #20 Store datal fn aeeumulator TFS MOV B, #10 Store data in B reg u DIVAB Divide 304500 MOV DPTR, #4300 Thitalize memory location FD MOVX @DPIRA Store reminder AB INC DPTR Go to next memory location ESFO MOVA.B Store quolient FO MOVX @DPTR, A FE ‘STOP [SMP Siop Losic operation Algorithm Step 1: Move value to accumulator Step2: Perform OR/AND with Of0/0F operat Step 3: Move memory location to DPTR Step 4: Store the result in memory locatjoh er order bits Program: Setting the higher order bits | Opeode | Label Mnemo Comment nies 7400 MOV A, #00 Move data 320A 4401 ‘ORLA, #01 Sciting the higher order bits using t 90.45.00 MOV DPTR, #4500 Move memory location to DPTR | FO ‘MOVX@DPTR, A ‘Move result to memory location ‘80FE SY Wwe BF ar Oe ae ae ae Gy Oe BH eee ee teem Masking Higher order bits ‘Opeode| Label 7400 ‘Mnemonics ‘MOV A, #00 ‘Comment Move data 320A 3407 90.85 00 "ANE A, #07 ‘MOV DPTR, #4500 Masking the higher order bits using Move memory location o DPTR FO MOVX @DPTR, A ‘Move result to memory location 0FE ‘Short jump here ap The above program was SIMP HERE wi ‘SQUARE AND CUBE PROGRAM, FIND 2S COMPLEMENT OF A NUMBER To write a program for square, cube and 2's complement of a number Apparatus required S.No] TTEM ‘SPECIFICATION QUANTITY ip ‘Microprocessor kit BOSTKIt I 2. Power Suppl 45 -Vde Square of the number Algorithm Initialize the data pointer Move the contents of A and B to respective registers, Multiply the same. Increment the data pointer Move the result to the data pointer End Mnemonics Comment MOV A, #05 Move a value fo accumulator MOVB,A Copy the value to B MUL AB ‘Square iby multiplying MOV DPTR, #4500 ‘Move a memory location to DPTR MOVX @DPTR, A ove Dg lower onder Byes ta mEMORy INC DPR Tneremen DPTR MOVA,B Move valilpinB tA MOVX @OPTR,A Slore higher order bytes to another location SINPAERE Loop here infinitely Initialize the data pointer Move the contents of A and B to respective registers Multiply the same. Increment the data pointer ‘Mnemonics ‘Comment Address MOV RO, #2. Thitialize the count MOV A, #05 ‘Move a data tobe cubed into A START _| MOV B, #05 Move the same data to B MUL AB ‘Multiply AB and store result in A DINZ RO, START Decrement and Jump it not equal to zero for MOV DPTR, #4500, Move memory location into DPTR MOVX @DPTR. A Move the result into memory location INC DPTR Tnerement DPTR NOVA.B Move BintoA MOVX @DPTR.A ‘Move higher order bytes to another memory HERE | SMP HERE Loop here infinitely 2s. Complement of a number Algorithm Step 1: Get the number Step 2: Complement it Step 3: Add one to it Step 4: Get the output Program ca Memory] Opeode | Label Mnemor i | \ Comment 7a05 MOV A, #05 Mowe avalucto A OLA Compliment A or ADD Aw Taerement the result of compliment 304500 MOV DPTRC 73500 Move a memory lation to DPTR 70 MOVK@DPTR,A ove the esl tothe memory Tosaion WIE | HERE | SIMP HERE Toop here infinitely ane Result ‘Thus the above program was. Ex. no: 9 24/11 [202f Aim ASCII TO PACKED BCD AND PACKED BCD TO ASCII To write a program for ASCII to BCD and BCD to ASCII Apparatus required " S.No] TTEM. SPECIFICATION ‘QUANTITY T.__| Microprocessor kit 80STKit T 2 [Power Suppl 45.V de T ASCIl to Packed BCD. Algorithm Step 1: Move ascii numbers to A and RI registers Step 2: AND operate with OF Step 3: Perform rotate right by 4 bits on one value ‘Step 4: Perform OR operation on the two values Step 5: Store the result in destination register Step6: HLT Program penny) lemonics jae a oa TOWRA owe ASCII anew MOV RI, #37 Move another ASCH value to RI "ANE A, FOF "AND Togie A with OF ANCRI, HOF ‘SWAPA ‘Swap the content of A ORLA RY OR the two value MOYBPTR, #4500 yo IX @DPTR, A Move the BCD value to memory location ‘SIMP HERE Loop infinitely AND logie RI with OF Move the memory address to DPT az Packed BCD to ASCH Initialize the memory location to the data pointer. Convert Packed BCD to Unpacked by performing AND operation with OF Perform ADD operation on one v ith 30 Perform ROL operation 0 e and ADD with 30 Store the ASCII numb Stop the program ee ee i wwvvw~vevevvvnvvvvev uve r were re Proj pnt Result gram Meany | Lave Mnemonics Comment MOV A.HAT Move BCD number A MOVE, FOA Move vale Ato B DIVAB Divide BCD number by A ORLA. AIO OR wih 30 MOV DPTR, F500 ‘Movea memory location wo DPTR MOVXG@DPTR, A Move one ASCII value to memory location MOVAB Move the second BCD number to A ORLA, #30 INCDPTR nen DPTR MOVK@DPTR, A ‘Move te sekond ASCIT namber to another HERE | SIMP HERE Loop here infinitely ‘Thus the above program is written, and the desired output is obtained Ex.No.:10 Jol { ‘TRAFFIC LIGHT CONTROL Aim Apparatus required ‘To write an assembly language program in 8051 to Traffic light control SNo. TTEM SPECIFICATION QUANTITY Microprocessor kit 8086 kit T Power Supply +5 Vide 1 N G 2. Bi 1 Algorithm Step 1: Step 2: Step 3: Step 4: Step 5: Step 6: Step 7: Step 8: Step 9: Step 10: Program: Traffic Light Control Board Initialize the ports as output for LEDS Set all square in stop mode Delay for 10ms Set go straight LED to glow Delay for 10ms Set stat LED N&S and Go Straight LED to glow Delay for Sms r Set stop LED of N&S, Go left LED of N&S and Clear start LED of N&S Set start LED of N&S and Clear Go left LED of N&S Delay for Sms and repeat step 6 to 10 for E-W Va Memory Address ‘Mnemonics \ YOv DFR WORT | MOV A, AOE MOVX@DPTR, A SeUANI Ports as Output MOV A, IIH MOV DPIR, FOFFOOH MOVX@DPTR, A ‘SAAT Square Red (Stop) MOV DPIR, #OFFO2H MOVX@DPIR, A ‘SEAN Square Red (Siop) TCALLDELAYI Call Delay TOMSEC MOV A, HET ‘MOV DPTR, fOFFOOIT MOVX@DPTR, A Set Green (Go Led) ofN ES TCALL DELAY! Call Delay TOMSEC MOV A, #22 MOVX@DPIR, A ‘Set Yellow (Start Led) of Nas. LCALL DELAY? Call Delay 5 MSEC MOV A, #991 FEDCBA9876543218 600058060606 ek ee > MOVX@DPIRA Ser All Square Red (StOp b LCALL DELAY Call Delay 1OMSEC. MOV A, #2241 » MOV X @DPTR, A oe ee of » LGALL DELAY? Call Delay MSEC MOVA, #iH > MOV X @DPTR,A Set ATI Square Red (St0p) MOV A, Haat > MOV DPTR, #0FFO2H MOV X @DPTR,A Set Green (Go Led) of FAW > TCALL DELAY Call Delay 1OMSEG > MOV A, #224 MOVX @DPTR, A SeYelow Gan Led TER > GALL DELAY2 Call Delay 5 MSEC MOV A, 99H > MOVX @DPTR,A Set All Square Red (Stop) > CALL DELAY Call Delay 1OMSEC MOV A, #22H > Soe St Ylow San ad) oTE 5 TCALL DELAY? Call Delay MSEC MOWA, HDI » MOVX@DPTR, A ‘Set All Square Red (Stop) LMP LOOP ump © Loop > MOV Ri, #251 10 MSEC Delay Routine MOV R2, 40H » MOV 3, #0H DINZ R3, DLI » DINZ R2, DL? i DINZ RI, DL3 DINZRI, DLA > RET MOV RI, #05H 'SMSEC Delay Routine » MOV R2, #011 MOV R3, #04 , DINZRS, DLA DINZR2, DLS » DINZ RI, DLE RET , , , , ‘The ALP was written, executed and the eSired output was obtained. 7 * r mare rere wee o- a | STEPPER MOTOR CONTROL fee Luft os “To write an assembly language program in 8051 to Stepper motor control ‘Apparatus required SPECIFICATION | — QUANTITY T._| Microprocessor kit 8086 kit. ii 2._| Power Supply. +5 V de 1 3.__| Stepper motor E 1 Algorithm Step 1: Initialize the port as output using CWR Step 2: Give output data as FA,F6,F5,F9 step sequence for clockwise rotation by step Step 3: Give delay between each data for step movement Step 4: Reduce the delay to see speed variation (continuous movement) Program Address Label Mnemonics. ‘ Comments MOV DPTR, HOFFOSH MOV A, #80 Set all poris as output MOVX @DPTR, A INIT Ports of 8255. Sars | MOV DPTR, #OFFOOH MOV A, #OFAH ‘Duxpat code Tor step MOVX @DPTR,A___—| Set PAI & PAS coil high ‘ACALL DELAY _> ‘Delay between two steps MOV A, #OFGH, ‘Quiput code for step MOVX @DPTR, A Set PAI & PAZ coil high "ACALL DELAY Delay between two steps ‘MOV A/#OFSH ‘Gutput code for step2. MQUX @DPTR, A ‘Set PAO & PA2 coil high ‘ACALL DELAY Delay between two steps MOV A, #0F9H ‘Output code for step3. MOVX @DPTR, A Set PAO & PAS coll high "ACALL DELAY Delay between two steps SJMP START Jump to start Delay: MOV R7, #03FH_ Delay Count, Dela: MOV R6, #03FH Delal: NOP NOP NOP DJNZ R6, DELAL DJNZ R7,DELA. RET Ww Result: ‘Thus the program is written executed and the desired output was obtained | ~~ vyvyvvyr vere veve ere veer vs ; RUNS DIGITAL CLOCK fulrort Ai : To display the digital clock specifically by displaying the hours, minutes and seconds using 8086 kit Apparat ired (ene “TEM SPECIFICATION ‘QUANTITY T.__| Microprocessor kit 8086 kit T 2,_| Power Suppl +5.V de T Program: Label Mnemonics START. ‘Address CALL CONVERT CALL DISPLAY DELAY MOV AL,0BOH, OUT 16H, AL MOV CL.07H 32 MOV AL,S8H ‘OUT 14H, AL ST MOV AL,S0H ‘OUT 16H, AL \_[ Nop |_| NOP 1 if [_ | Nop, [_ [Nor (NAL Ta, MOV DL, AL IN AL 4H ORAL, DL INZSI DECCL INZSI MOV S1,1500H MOV AL, [SI] INCAL MOV Si], AL ‘CMP AL3CH INZ START MOV AL,00H MOV{SI], AL INCSI MOV AL, [Si] INCAL ?7PPrrrrre ITTV TTR eo a od MOV SI], AL CMP ALSCH INZSTART MOV ALO. MOV {SI}, AL INCSI MOV AL, [SI] INCAL MOV ISI], AL CMP AL, sit INZ START MOV ALO MOV TSI), AL, IMP START DISPLAY, MOV AHH MOV DX, 16004 MOV CHOI MOV CLOH INTS RET CONVERT MOV SI, 1500 MOV BX, 16081 L241 MOV|(BX], AL ‘SECONDS MOVIAL, [SI] MOV|AH.O MOV|DH,0AH DIV DH ADD AH30H DEC BX ‘MOV [BX], AH DECBX ADD AL,30H MOV [BX], AL DECBX MOV ALSAH MOV [BX]. AL DECBX MINUTES) INCSI MOV AL (St MOV ARO MOV DH,0AH 7 [DIV DH MOV [BX], AL DECBX MOV ALAN MOV [BX], AL. DEC BX INCSI MOV AL, [Si] MOV ATO MOV DHLOATL bIVDI ADD Ail,30mT MOV BX], AH DEC BX ‘ADD AL,30H MOV [BX]. AL RET GETC INAL,O2H AND AL OFFA ‘CMP AL.OFOH INE GETC r-wrrerwrryere ~wwywry~rrrwyrrrrr rr wer ee KEYBOARD AND DISPLAY To interface the keyboard with 8086 and to obtain the digital output according to the given analog signal Apparatus required S.No. ITEM SPECIFICATION. QUANTITY T.__| Microprocessor kit 8086 kit 1 2.__ | Power Suppl #5 V de 1 Algorithm Step 1: Clear display using CALL LCD function by passing 01 Step 2: Letter blinking cursor ON/OFF using CALL LCD function by passing 0D Step3: Read keyboard data Step4: Transfer the keyboard data to LCD function Step5: Wait until key pressed on keyboard Step6: HLT , Program EO PEO abet Ryecehies | Comments Address MOVALO1 Clear display command CALL FOO0FO44 Calling instruction is input MOV ALD Letter blinking cursor OFF ‘CALL FO00:F044 Call for write-in instruction Loop, 7 | CALL F000:F050 Call for the read key-in CALL F000:F058 Call the alphabetical key code IB Loop Ignore the alphabetical key= CALL F000:F048 Key-in code enter into LCD IMP Loop Tump to Toop HLT Flalt ow Result Thus the above program was written, exs Ex.No:14 fof} 24 PRINTER STATUS Aim Apparatus required To display the Printer Status in the display No. TTEM SPECIFICATION ‘QUANTITY. T.__| Microprocessor kit 8086 kit 1 2._| Power Supply $5 V de I Program = Address Label Mnemonics ‘Comments: XORAX, AX This divides my 3 digit by giving me my hundredth XOR BX, BX MOV AX, RES MOV BX, 100 Prints the hundredth digit [ADD AL, 0" MOV DL, AL PUSH AX Save AX on the stack | MOV AH, 024 INT 21h POP AX Restore AX, divides ye | the remainder by 10 A \ giving me my tens digit MOV BX, 10 DIV BX Prints my tens digit EV. ADD AL, “0” MOV DL, AL PUSH AX Save AX on the stack MOV AH,02h INT2Ih POP AX Restore ax, print my last remainder which is my ones ‘ADD AH, ‘0° MOV DL, AH, MOV AH, 02h INT2Ih fea 15 [1 lrors SERIAL INTERFACE AND PARALLEL INTERFACE Aim To connect two 8086 microprocessor kits and to serially communicate with each other by considering transmitter and receiver kits. ‘Apparatus required S.No. TTEM SPECIFICATION ‘QUANTITY TE Microprocessor kit 8086 kit T a +5.Vide T Power Supply Algorithm Step 1 Step 2: Step 3: Step 4: Step 5: Step 6: Step 7: Step &: Step 9: Take two no of 8086 microprocessor kits. Enter the transmitter program in transmitter kit, Enter the receiver program in receiver kit Interface the two kits with 9-9 serial cable in the serial port of the microprocessor kits. (LCD kit means PC-PC cable. LED kit means kit-kit cable) Enter the data in transmitter kit use the memory location 1500. Execute the receiver kit. Execute the transmitter kit Result will be available in receiver kit memory location 1500. Program: Transmitter Address | Opcode Mnemonics MOV SI,1500 MOV AL36 OUT 16, AL MOV AL40 OUT 10, AL MOC AL,OL OUT 10, AL MOV CL,05 IN AL,OA ‘AND AL,04 JZ LOOP. MOV AL [SI] ‘OUT 08, AL INCSI CMP AL,3F INZ LOOPI Program: Transmitter ade Mnemonics sii ee MOV SI,1500 MOV AL36 ‘OUTI6,AL MOV AL.40 OUTIOAL MOC AL,OI OUT 10,AL MOV CL05 IN ALOA "AND ALO2 JZLOOP, INALOS MOV (SIAL INCSI CMP ALF INZ LOOPI DECCL INZ LOOP INT O2 INTO2 rtV IF 77 2 - Se Ex.No:16 "AID AND D/A INTERFACE AND WAVEFORM GENERATION fe fufot Aim ‘To connect two 8086 microprocessor Kits and to serially communicate with each other by considering transmitter and receiver kits Apparatus required SNo. TTEM SPECIFICATION (QUANTITY T.__| Microprocessor kit uu Hie T 2._| Power Supply e ! Analog to Digital Converter Algorithm Step |: Initialize 8255 by sending control word to control reg. Step2: Initialize measurement and get input to ADC Siep3; Close measurement and call delay Step4; Read the digital output Step 5: End Program Memory] Label Mnemonics Comments MOV AL, 98TT Tnalize 253 Out TH, AL PA & PC upperas input PB & Sian | MOV AL, OOH [ [Select Channel ‘Ou TAH A” | [lowtar Port MOV ALZO0m | [Give SOC a ALE Pulkeas0 Out 7, AL [[ourarPor-c MOV AL, O3ff Give SOC & ALE Pulse as 1 “Sa TAH, AL Outat Pon-C MOV AL, OOF Give SOC & ALE Puke as Out 74H, AL Outat Pore FOOT [iva 7a Read EOC fromPortC AND AL, 1017 Cheek EOC at POH Bit 1Z0C Tump TILL EOC=1 MOV AL, OFF Give Ouiput Enable ws 1 Out 74H, AL Out at Port-C INAL, 70H, Read 8 Bit ADCData rom Port A Call FOOO:FOTC Call Clear Disphy MOV AH, OOH Move REG AH=00 MOV BL, 80H Display Ram Location of LCD Call F000:F094 Call Display Routine MOV CX, OFOOH Move CX REG AS OFOOH_ Tre | DECC Decrement CX REG INZLPs Jump TILOL CX=0 IMP Sit Jump o Start Tite ee a ea Initialize 8255 by. sending Control Word to Control Reg. Cal delay sub routine Ger igh into acoumulator send t0 DAC through output port Gat “Low into accumulator; send to DAC through output port Continue cycle Mnemonics Comments MVIA, 8011 Initialize 8255 ‘OUT 03H PA & PB as output MVIA, 00H Select A as Data 00 QUT 00H Out at X-Out OUT OI” (Out at Y-Out INR AZ Increment A. IMPLoop!

You might also like