mp manual programs
-
Upload
sriramachandran2011 -
Category
Documents
-
view
217 -
download
2
description
Transcript of mp manual programs
SYLLABUSCS6412 MICROPROCESSOR AND MICROCONTROLLER LABORATOR OBJECTIVES:The student should be made to: Introduce ALP concepts and features Write ALP for arithmetic and logical operations in 8086 and 8051 Differentiate Serial and Parallel Interface Interface different I/Os with Microprocessors Be familiar with MASMLIST OF EXPERIMENTS:8086 Programs using kits and MASM1. Basic arithmetic and Logical operations2. Move a data block without overlap3. Code conversion, decimal arithmetic and Matrix operations.4. Floating point operations, string manipulations, sorting and searching5. Password checking, Print RAM size and system date6. Counters and Time DelayPeripherals and Interfacing Experiments7. Traffic light control8. Stepper motor control9. Digital clock10. Key board and Display11. Printer status12. Serial interface and Parallel interface13. A/D and D/A interface and Waveform Generation8051 Experiments using kits and MASM14. Basic arithmetic and Logical operations15. Square and Cube program, Find 2s complement of a number16. Unpacked BCD to ASCII TOTAL: 45 PERIODSOUTCOMES:At the end of the course, the student should be able to: Write ALP Programmes for fixed and Floating Point and Arithmetic nterface different I/Os with processor Generate waveforms using Microprocessors Execute Programs in 8051 Explain the difference between simulator and Emulator
https://sites.google.com/site/ecerjt/tutorials/the-8051-microcontroller-and-embedded-systems-
LAB EQUIPMENT FOR A BATCH OF 30 STUDENTS:HARDWARE:8086 development kits - 30 nosInterfacing Units - Each 10 nosMicrocontroller - 30 nosSOFTWARE:Intel Desktop Systems with MASM - 30 nos8086 Assembler8051 Cross Assembler
INTRODUCTION TO MASMProgramming of a microprocessor usually takes several iterations before the rightsequence of machine code instruction is written. The process, how machine code isfacilitated casing a special program called an assembler. The assembler allows the userto write alphanumeric instructions (or) mnemonics called assembly language instructions.An assembler takes the written assembly code and converts it into machine code. Often itwill come with a linker that links the assembled file and produces an executable fromit.Window executables have the extension. Here are some of the popular onesMASM:- Microsofts macro assembler(MASM) is an integrated software packagewritten by Microsoft co-operation for professional software developers. It consists of aneditor, an assembler, a linker and a debugger the programmers work bench combinesthese four path into a user friendly programming environment with built in online help.FAMILIARITY WITH MASM:- Available since the beginning of the IBM compatible PCS Works in MS-DOS and windows environments. Its free: Microsoft no longer sells MASM as a standalone product. Bundled with the Microsoft visual studio product Numerous tutorials, books and samples floating around, many are free or low costTASM:- Another popular assembler made by Borland but it is still a commercialproduct.ASSEMBLING THE PROGRAM:-The assembler is used to convert the assembly language instructions to machinecode. It is used immediately after writing the assembly language program. The assemblerstarts by checking the syntax or validity of the structure of each instruction in the sourcefile. If any errors are found the assembler displays a report on these errors along withbrief explanation of their nature. However, if the program does not contain any errors.The assembler produces an object file that the same name as original file but with the.obj extension.LINKING THE PROGRAM:-The linker is used to convert the object file to an executable file the executablefile is the final set of machine code instructions that can directly be executed bymicroprocessor. It is difficult and different than the object file on the sense that it is selfcontained and locatable. An object file may represent on segment of long program. Thisprogram cannot operate by itself and must be integrated with other object filerepresenting the rest of the program in order to produce the final self contained exactablefile.DEBUGGING THE PROGRAM:-The debugger can also be used to find logical errors in the program. Even if aprogram does not contain syntax errors. It may not produce the desired result afterexecution. Logical errors may be found by tracing the action of the program. Once foundthe source file called Debugger is designed for that purpose.The debugger allows the user to trace the action of the program by single steppingthrough the program (or) executing the program up to a desired point called breakpoint. Itallows the user to inspect (or) change the contents of MP internal register (or) thecontents of any memory location.EXECUTING THE PROGRAM:-The executable file contains the machine language code. It can be based on the RAM andbe executed by the micro processor. Simply by typing from the DOS prompt. It theprogram produces an output on the screen or a sequence of control a piece of onhardware, if the programming manipulates data in memory nothing would seem to havehappened as a result of executing the program.THE DOS-DEBUGGER:-THE DOS-Debug program is an example of a simple debugger that comes with MSDOS. Hence it will available on any pc. It was initially designed to give the usercapability to trace logical errors in executable files. It allows the user to take an existingexecutable file and unassembled it i.e., convert into assembly language also it allows theuser to write assembly language instructions directly and then convert them to machinelanguage.MS-PWB:-The PWB allows the user to define a project that means it contains one or more files thenthe user may select and save all the necessary assembly linking and debugging option forthat project the PWB allows the leaving the PWB environment it also allows the user toget help on any keyword by pointing to the keyboard a
Exp No : 1 DATE: Programs for 16 bit Arithmetic operations (Using 8086).(a) ADDITION OF TWO 16-BIT NUMBERS AIM: To write an assembly language program to add the two 16-bit numbers residing in memory and store the result in memory using 8086.APPARATUS REQUIRED:i.8086 Microprocessor kit with key board ii. Power chord.ALGORITHM:1. Load the Addend data to accumulator.2. Get the Augends and Add with Accumulator content.3. Store the result.
FLOW CHART:
STARTGet the Augend and Add with Accumulator contentSTOPStore the resultLoad theAddend data to accumulator
PROGRAM:ADDRESSLABELMNEMONICSOPCODECOMMENT
1000MOV AX,[2000]8B, 06,00,20Move addend to accumulator
1003ADD AX,[2002]03,06,02,20Add addend with augends
1007MOV [2004],AX89,06,04,20Move accumulator content to memory
100AHLTF4Stop
OBSERVATION:16 BIT ADDITIONSINPUTADDRESS BYTESET I (Hex)SET II(Hex)
16-bit Data 12000hLB13FF
2001hHB12D1
16-bit Data22002hLB107F
2003hHB11CF
OUTPUTADDRESS BYTESET I (Hex)Without carrySET II(Hex)With carry
16 bit Sum2004hLB
2005hHB
Carry2006hLB
RESULT: Thus the assembly language program to add the two 16-bit numbers is Written and executed successfully.
(b) SUBTRACTION OF TWO 16-BIT NUMBERS USING 8086AIM: To write an assembly language program to subtract two 16-bit numbers residing in memory and store the result in memory using 8086.APPARATUS REQUIRED:i. 8086 Microprocessor kit with key board,ii. Power chord.ALGORITHM:1. Load the Minuend data to accumulator.2. Get the Subtrahend and subtract with Accumulator content.3. Store the result.
FLOW CHART:
STARTGet the Subtrahend and subtract with Accumulator contentSTOPStore the resultLoad the Minuend data to accumulator
PROGRAM:ADDRESSLABELMNEMONICSOPCODECOMMENT
1000MOV AX,[2000]8B,06,00,20Move minuend to accumulator
1003SUB AX,[2002]2B,06,22,20Subtract minuend with subtrahend
1007MOV [2004],AX89,06,04,20Move accumulator content to memory.
100AHLTF4Stop
OBSERVATION:16 BIT SUBTRACTIONSINPUTADDRESS BYTESET I (Hex)SET II(Hex)
Minuend2000hLB15FD
2001hHB13DE
Subtrahend2002hLB136A
2003hHB1418
OUTPUTADDRESS BYTESET I (Hex)Without BorrowSET II(Hex) with Borrow
16 bitDifference2004hLB
2005hHB
Borrow 2006hLB
RESULT: Thus the assembly language program to subtract the two 16-bit Numbers is written and executed successfully.
(C) MULTIPLICATION OF TWO 16-BIT NUMBERS
AIM: To write an assembly language program to multiply two 16 bit numbers andstore the result in memory using 8086.
APPARATUS REQUIRED:i.8086 Microprocessor kit with key board,ii. Power chord.
ALGORITHM:1. Get the multiplier and multiplicand.2. Multiply the given two numbers.3. Store the result in consecutive memory locations.
FLOW CHART:
Get the multiplier and multiplicandSTART [Multiplier] x [multiplicand]STOPStore the result
PROGRAM:ADDRESSLABELMNEMONICSOPCODECOMMENT
1000MOV AX,[2000]8B,06,00,20Move the data to accumulator
1003MUL[2002]F7,26,02,11Multiply memory content with accumulator
1007MOV [2004],DX8B,1E,02,20Store MSW
100BMOV[2006],AX89,16,02,20Store LSW
100EHLTF4Stop
OBSERVATION:16 BIT MULTIPLICATIONINPUTADDRESS BYTESET I (Hex)SET II(Hex)
Multiplicand2000hLB1223
2001hHB12FD
Multiplier2002hLB131C
2003hHB141F
OUTPUTADDRESS BYTESET I (Hex)
SET II(Hex)
32 bitResult
2004hLB
2005hHB
2006hLB
2007HB
RESULT: Thus the assembly language program to multiply the two 16-bit numbers is written and executed successfully.
(D) DIVISION OF TWO 16-BIT NUMBERS
AIM: To write an assembly language program to divide two 16 bit numbers and store the result in memory using 8086.
APPARATUS REQUIRED:i. 8086 Microprocessor kit with key board, ii. Power chord.ALGORITHM:
1. Get the dividend and divisor.2. Divide the given two numbers.3. Store the result in consecutive memory locations.
FLOW CHART:
Get the Dividend and Divisor START [Dividend] / [Divisor]STOPStore the result
PROGRAM:ADDRESSLABELMNEMONICSOPCODECOMMENT
1000MOV AX,[1100]8B,06,02,00Move the data to accumulator
1003DIV AX, [1102]F7,36,02,11divide memory content with accumulator
1007MOV [1200],AX8D,1E,02,20Store MSW
100BMOV[1202],DXA3,02,12Store LSW
100EHLTF4Stop
OBSERVATION:16 BIT DIVISIONINPUTADDRESS BYTESET I (Hex)SET II(Hex)
Dividend2000hLB23AD
2001hHB43AE
Divisor2002hLB12CB
2003hHB14CA
OUTPUTADDRESS BYTESET I (Hex)
SET II(Hex)
16 bitQuotient 2004hLB
2005hHB
Remainder2006hLB
RESULT: Thus the assembly language program to divide the two 16-bit numbers is written and executed successfully. (E) SUM OF N NUMBERS IN AN ARRAY
AIM: To write an assembly language program to add a given numbers in an Array and store the result in memory.APPARATUS REQUIRED:i.8086 Microprocessor kit with key board ii. Power chord.ALGORITHM:1. Get the count in register for number of data.2. Initialize the array address.3. Add the given N numbers.4. Continue the addition till the count becomes zero.5. Store the result in consecutive memory locations. 6. Stop the program.
Get the count to count register from first location of sourceSTARTGet the first and second data by increment the pointerIncrement the pointerSTOPStore the resultIs count value 0 ?Add the two numbers and decrement the count value by 1FLOW CHART:
No
yes
Yes
PROGRAM:ADDRESSLABELMNEMONICSOPCODECOMMENT
1000MOV SI, 2000C7,C6,00,20Initialize the memory pointer
1003MOV CL,[SI]8A,0CMove the content of 2000 to count register CL.
1007INC SI46increment the memory pointer
100BMOV AH,[SI]8A,24Move the content of SIie 2001 to AH register.
100ENEXT:INC SIFE,09increment the memory pointer
1010ADD AH, [SI]46Add the content of AH and content of 2002.
1014DEC CL02,24Decrement the count value by 1.
1018JNZ :NEXT75,79If the count is non zero go to the address specify by the label NEXT. if count is zero continue with next instruction.
110BINC SI46Increment the SI for store result.
101CMOV [SI],AH88,24Finally sum in AH is store in the memory specify by SI.
101DHLTF4Stop the program.
OBSERVATION: SUM OF N DATA IN AN ARRAY
INPUTADDRESS BYTESET I (Hex)SET II(Hex)
Count (N) value2000h050A
Data 12001hLB7723
Data 22002hLB5653
Data 32003hLB5476
Data 42004hLB12FA
Data 52005hLB09CD
Data 62006hLB23
Data 72007hLB65
Data 82008hLB98
Data 92009hLBFC
Data 10200AhLBBC
OUTPUTADDRESS BYTESET I (Hex)
SET II(Hex)
Sum of N Numbers2004hLB
2005hHB
RESULT: Thus the assembly language program to add N numbers in a given array is written and executed successfully.
Ex.No : 2 DATE: Programs for Sorting and Searching (Using 8086).
(a)Largest Number in an array
AIM: To write an assembly language program to find a largest value in a given array and store the result in memory.
APPARATUS REQUIRED:i. 8086 Microprocessor kit with key board, ii. Power chord.ALGORITHM:
1. Get the count in register for number of data.1. Initialize the array address.1. Compare the selected two numbers and check carry.1. If bigger, store the largest value in accumulator. 1. Otherwise interchange the contents with register.1. Decrement the count.1. Continue the same operation till the count becomes zero.1. Store the result in memory locations.
FLOW CHART:
PROGRAM:ADDRESSLABELMNEMONICSOPCODECOMMENT
1000MOV SI, 2000Initialize the memory pointer.
MOV CL,[SI]Move the content of 2000 to count register CL.
INC SIIncrement the memory pointer as 2001.
MOV AL,[SI]Move the content of 2001 to the AL register.
NEXT:INC SIIncrement the memory pointer
DEC CLAfter getting the first data decrement the count value by 1.
INC SIIncrement the memory pointer
MOV BL,[SI]Move the content of SI to register BL.
CMP AL,BLCompare the content of AL,BL
JNC: SKIPIf no carry occur jump to the address specify by SKIP.if carry occur continue the next instruction.
MOV AL,BLMove the content of BL to AL register.
SKIP:DEC CLDecrement the count value in CL by 1.
JNZ: NEXTIf count is not zero jump to address specify by NEXT. otherwise continue the next instruction.
INC SIIncrement the memory pointer to store the result.
MOV [SI],ALMove the largest no hold by AL to the address hold by SI.
HLTStop the program
OBSERVATION :LARGEST OF N DATA IN AN ARRAYINPUTADDRESS BYTESET I (Hex)SET II(Hex)
Count (N) value2000hLB050A
Data 12001hLB1612
Data 22002hLBFD34
Data 32003hLBDC56
Data 42004hLBCD75
Data 52005hLB1489
Data 62006hLB9F
Data 72007hLBFC
Data 82008hLBAD
Data 92009hLBBC
Data 10200AhLBBB
OUTPUTADDRESS BYTESET I (Hex)
SET II(Hex)
Largest Value 2006hLB
200BhLB
RESULT: Thus an assembly language program to find the largest value in a given array is written and executed successfully. (b) Smallest Number in an array
AIM: To write an assembly language program to find a smallest value in a given array and store the result in memory.
APPARATUS REQUIRED:i. 8086 Microprocessor kit with key board,ii .Power chord.ALGORITHM:1. Get the count in register for number of data.1. Initialize the array address.1. Compare the selected two numbers and check carry.1. If smaller, store the largest value in accumulator. 1. Otherwise interchange the contents with register.1. Decrement the count.1. Continue the same operation till the count becomes zero.1. Store the result in memory locations.
FLOW CHART:
PROGRAM:ADDRESSLABELMNEMONICSOPCODECOMMENT
1000MOV SI, 2000SI 2000
MOV CL,[SI]CL [SI]
INC SIIncrement the content of SI by one.
MOV AL,[SI] AL [SI]
NEXT:INC SIIncrement the content of SI by one.
DEC CLDecrement the content of CL by one.
INC SIIncrement the content of SI one
MOV BL,[SI]BL [SI]
CMP AL,BL Compare the content of AL,BL
JC SKIPIf have carry jump to skip.
MOV AL,BLAL BL
SKIP:DEC CLDecrement the content of CL by one.
JNZ NEXTIf CL is not zero go to next
INC SIIncrement the content of SI by one
MOV [SI],AL[SI] AL
HLTTerminate the program
OBSERVATION:SMALLEST OF N DATA IN AN ARRAYINPUTADDRESS BYTESET I (Hex)SET II(Hex)
Count (N) value2000hLB050A
Data 12001hLB1612
Data 22002hFD34
Data 32003hDC56
Data 42004hCD75
Data 52005h1489
Data 62006h9F
Data 72007hFC
Data 82008hAD
Data 92009hBC
Data 10200AhBB
OUTPUTADDRESS BYTESET I (Hex)
SET II(Hex)
Smallest Value 2006hLB
200BhLB
RESULT: Thus an assembly language program to find the smallest value in a given array is written and executed successfully.
(c) Arranging the given numbers in ascending order
AIM: To write and execute an assembly language program to arrange in ascending order in a given array of memory.
APPARATUS REQUIRED:i. 8086 Microprocessor kit with key board,ii. Power chord.ALGORITHM:1. Get the count in register for number of data.2. Initialize the array address.3. Compare the first two numbers and if the first number is larger than second then interchange the number.4. If the first number is smaller, go to step 55. Repeat steps 2 and 3 until the numbers are in required order
FLOW CHART:
PROGRAM:ADDRESSLABELMNEMONICSOPCODE CODECOMMENT
1000MOV SI, 2000Initialize the memory pointer.
MOV CL,[SI]Move the content SI to CL.
DEC CLDecrement the count value
REPEAT:MOV SI,2000Move 2000 to SI.
MOV CH,[SI]Move the content of to CH.
DEC CHDecrement the CH by one.
INC SIIncrement the memory pointer
RECMP:MOV AL,[SI]Move the content of SI to AL.
INC SIincrement the memory pointer
CMP AL,[SI]Compare the content of AL and content of address hold by SI.
JC :AHEADIf carry occur jump to the address specify by the label AHEAD.
XCHG AL,[SI]Exchange the content of AL and the content hold by the address specify in SI.
XCHG AL,[SI-1]Exchange the content of AL and the content hold by the address specify in SI-1.
AHEAD:DEC CHDecrement the CH register by 1.
JNZ: RECMPIn the count value not reach to zero jump to address specify by RECMP.
DEC CLDecrement the content of CL.
JNZ: REPEATIn the count value not reach to zero jump to address specify by REPEAT.
HLTStop the program.
OBSERVATION:ASCENDING ORDERINPUTADDRESS BYTESET I (Hex)OUTPUTAscendingSETII(Hex)OUTPUTAscending
Count(N) value2000hLB050A
Data 12001hLB34AD
Data 22002h56DC
Data 32003h78EB
Data 42004h87EE
Data 52005hDB12
Data 62006h76
Data 72007h31
Data 82008h58
Data 92009h89
Data 10200Ah90
RESULT: Thus an assembly language program to arrange the numbers of an array in ascending order is written and executed successfully.
(d) Arranging the given numbers in descending order
AIM: To write and execute an assembly language program to arrange in descending order in a given array of memory.
APPARATUS REQUIRED:i.8086 Microprocessor kit with key board,ii. Power chord.ALGORITHM:
1. Get the count in register for number of data.2. Initialize the array address.3. Compare the first two numbers and if the first number is smaller than second then interchange the number.4. If the first number is smaller, go to step 55. Repeat steps 2 and 3 until the numbers are in required order
FLOW CHART:
PROGRAM:ADDRESSLABELMNEMONICSOPCODECOMMENT
1000MOV SI, 2000Initialize the memory pointer.
MOV CL,[SI]Move the content SI to CL.
DEC CLDecrement the count value
REPEAT:MOV SI,2000Move 2000 to SI.
MOV CH,[SI]Move the content of to CH.
DEC CHDecrement the CH by one.
INC SIIncrement the memory pointer
RECMP:MOV AL,[SI]Move the content of SI to AL.
INC SIincrement the memory pointer
CMP AL,[SI]Compare the content of AL and content of address hold by SI.
JNC :AHEADIf carry occur jump to the address specify by the label AHEAD.
XCHG AL,[SI]Exchange the content of AL and the content hold by the address specify in SI.
XCHG AL,[SI-1]Exchange the content of AL and the content hold by the address specify in SI-1.
AHEAD:DEC CHDecrement the CH register by 1.
JNZ :RECMPIn the count value not reach to zero jumps to address specify by RECMP.
DEC CLDecrement the content of CL.
JNZ: REPEATIn the count value not reach to zero jump to address specify by REPEAT.
HLTStop the program.
OBSERVATION :DESCENDING ORDERINPUTADDRESS BYTESET I (Hex)OUTPUTAscendingSETII(Hex)OUTPUTAscending
Count (N) value2000hLB050A
Data 12001hLB3316
Data 22002h4567
Data 32003hDB56
Data 42004hFD88
Data 52005hEA90
Data 62006h64
Data 72007h32
Data 82008h11
Data 92009hAD
Data 10200AhEB
RESULT: Thus an assembly language program to arrange the numbers of an array in descending order is written and executed successfully.
Ex.no.3 Date:Programs for String manipulation operations (Using 8086). (a) 8086 STRING MANIPULATION FILL A STRING
AIM: To fill a given string byte to a given destination location.
APPARATUS REQUIRED:i.8086 Microprocessor kit with key board,ii. Power chord.
ALGORITHM:1. Load the destination index register with starting and the ending address respectively.2. Initialize the counter with the total number of words to be copied.3. Clear the direction flag for auto incrementing mode of transfer.4. Use the string manipulation instruction STOSB with the prefix REP to fill a string to destination.
FLOW CHART:
PROGRAM:ADDRESSLABELMNEMONICSOPCODECOMMENT
1000MOV CX,0100Move 0100 to CX register.
1003MOV DI,1FFFMove 1FFF to DI register.
1007MOV AH,FFMove FF to AH register.
100BNOPNo operation
100EREPEAT:CLDClear the direction flag.
100FSTOSBStore the string byte
1010LOOP: REPEATUnconditional loop to address specified by the label REPEAT.
1013HLTstop the program
OBSERVATION:ADDRESSDATA
1FFFFF
2000FF
2001FF
2002FF
2003FF
2005FF
2006FF
RESULT: Thus the assembly language program to fill a given string in a selected array is written and executed successfully.
(b) 8086 COPY A STRINGAIM: To copy a string of data words from one location to the other.
APPARATUS REQUIRED:i.8086 Microprocessor kit with key board, ii. Power chord.
ALGORITHM:1. Load the source and destination index register with starting and the ending address respectively.2. Initialize the counter with the total number of words to be copied.3. Clear the direction flag for auto incrementing mode of transfer.4. Use the string manipulation instruction MOVSW with the prefix REP to copy a string from source to destination.
FLOW CHART:
PROGRAM:ADDRESSLABELMNEMONICSOPCODECOMMENT
1000MOV SI,2000HInitialize the source address.
1003MOV DI,2100HInitialize the destination address.
1007MOV CX,0006 HInitialize count value to the count register.
100BMOV AH,55HMove 55 to AH register.
100EREPEAT:CLDClear the direction flag.
100FMOVSBMove the string byte.
1010LOOP:REPEATUnconditional loop to address specified by the label REPEAT.
1013HLTStop the program.
OBSERVATION:INPUTSOUTPUTS
ADDRESSDATAADDRESSDATA
200055210055
200155210155
220255210255
220355210355
220455210455
220555210555
RESULT: Thus the assembly language program to copy a string of data byte from one location to other is written and executed successfully. (c) 8086 FINDING STRING LENGTHAIM: To write & execute an ALP to find the length of a given string using 8086 Microprocessor kit.
APPARATUS REQUIRED:i. 8086 Microprocessor kit with key board, ii. Power chordALGORITHM:1. Load the source and destination index register with starting and the ending address respectively.2. Load the terminate data value as FF.3. Load the content of source index to the AL register.4. Increment SI register and compare with register AH.5. If it is non- zero value, increment the memory location by using the control instruction to store the data.6. Compare the string byte with FF, if it is not equal, repeat.7. Count the string byte till zero flag is set. If zero flag is set then store the count value to the memory.8. Terminate the program when FF is matched.
FLOW CHART:
PROGRAM:ADDRESSLABELMNEMONICSOP CODECOMMENT
1000MOV SI,2000hC7,C6,00,12SI 1200
1004MOV DX,FFFFhC7,C7,FF,FFDXFFFF
1008MOV AH,FFhC6,C4,FFAH FF, check FF
100BNOENDINC DX42Increment the DX reg. by 1
100CMOV AL,[SI]8A,04AL [SI]
100EINC SI46Increment the SI reg. by 1
100FCMP AH,AL38,C4Compare the content of AH & AL
1011JNZ : NOEND75,FBIf the Compared result is not 0 go to by the address specified label NOEND.
1013MOV [1100],DX89,16,00,11[1100] DXie. store the result
1017HLTF4Terminate the program
OBSERVATION: INPUT ADDRESS (Hex)Data (Hex)
1200E3
1201F4
120254
120366
120488
120599
120610
1207FF
OUTPUT :ADDRESS (Hex)String length (Hex)
110008
110100
RESULT: Thus the assembly language program to find length of a given string of data bytes in an array is written and executed successfully.EX. NO.4 DATE:PROGRAMS FOR DIGITAL CLOCK (USING 8086)ADDRESSLABELMNEMONICSOP-CODECOMMANDS
1000STARTCALL CONVERTE8 00 60
1003CALL DISPLAYE8 00 51
1006DELAYMOV AL,B0B0 B0
1008OUT 16H,ALE6 16
100AMOV CL,07HB1 07
100CS2MOV AL,88HB0 88
100EOUT 14H,ALE6 14
1010MOV AL,80HB0 80
1012OUT 14H,ALE6 18
1014S1MOV AL,80HB0 80
1016OUT 16H,ALE6 16
1018NOP90
1019NOP90
101ANOP90
101BNOP90
101CIN AL,14HE4 14
101EMOV DL,AL8A D0
1020IN AL,14HE4 14
1022OR AL,DL0A C2
1024JNZ S175 F2
1026DEC CLFE C9
1028JNZ S275 E6
102AMOV SI,1500HBE 00 15
102DMOV AL,[SI]8A 04
102FINC AL FE C0
1031MOV [SI],AL88 04
1033CMP AL,3CH3C 3C
1035JNZ START75 CD
1037MOV AL,00B0 00
1039MOV [SI],AL88 04
103BINC SI46
103CMOV AL,[SI]8A 04
103EINC ALFE C0
1040MOV [SI],AL88 04
1042CMP AL,3CH3C 3C
1044JNZ START75 BE
1046MOV AL,00B0 00
1048MOV [SI],AL88 04
104AINC SI46
104BMOV AL,[SI]8A 04
104DINC ALFE C0
104FMOV [SI],AL88 04
ADDRESSLABELMNEMONICSOP-CODECOMMANDS
1051CMP AL,18H3C 18
1053JNZ START75 AF
1055MOV AL,00B0 00
1057MOV [SI],AL88 04
1059JMP STARTEB A9
105BDISPLAYMOV AH,06HB4 06
105DMOV DX,1600HBA 00 16
1060MOV CH,01HB5 01
1062MOV CL,00HB1 00
1064INT 5CD 05
1066RETC3
1067CONVERTMOV SI,1500HBE 00 15
106AMOV BX,1608HBB 08 16
106DMOV AL,24HB0 24
106FMOV[BX],AL88 07
1071MOV AL,[SI]8A 04
1073MOV AH,00B4 00
1075MOV DH,0AHB6 0A
1077DIV DHF6 F6
1079ADD AH,30H80 C4 30
107CDEC BX4B
107DMOV[BX],AH88 27
107FDEC BX4B
1080ADD AL,30H04 30
1082MOV[BX],AL88 07
1084DEC BX4B
1085MOV AL,3AHB0 3A
1087MOV[BX],AL88 07
1089DEC BX 4B
108AINC SI (minutes)46
108BMOV AL.[SI]8A 04
108DMOV AH,00B4 00
108FMOV DH,0AHB6 0A
1091DIV DHF6 F6
1093ADD AH,30H80 C4 30
1096MOV [BX],AH88 27
1098DECBX4B
1099ADD AL,30H04 30
109BMOV[BX],AL88 07
109DDEC BX4B
109EMOV AL,3AHB0 3A
10A0MOV [BX],AL88 07
10A2DEC BX4B
10A3INC SI(hours)46
ADDRESSLABELMNEMONICSOP-CODECOMMANDS
10A4MOV AL,[SI]8A 04
10A6MOV AH,00B4 00
10A8MOV DH,0AHB6 0A
10AADIV DH F6 F6
10ACADD AH,30H80 C4 30
10AFMOV[BX],AH88 27
10B1DEC BX4B
10B2ADD AL,30H04 30
10B4MOV [BX],AL88 07
10B6RETC3
10B7GETCIN AL,02HE4 02
10B9AND AL,FFH24 FF
10BBCMP AL,F0H3C F0
10BDJNE GETC75 F8
TIMING DISPLAYADDRESSSPECIFICATION VALUE
1500SECONDS 32
1501MINUTES0F
1502HOURS05
Result: Thus the ALP for digital clock was written and executted succesfully
BIOS/DOS CALLS2.a.i 16 bit Addition/Subtraction .MODEL TINY .CODE MOV BX,1234h MOV CX,7698h MOV AL,BL ; for subtraction replace with ADD AL,CL ; SUB AL,CL DAA ; DAS MOV DL,AL MOV AL,BL ADC AL,CH ; SBB AL,CH DAA ; DAS MOV DH,AL MOV AH,4Ch INT 21h END
2.c.i 16 bit Multiplication/Division .MODEL TINY .CODE MOV AX,1234h MOV BX,7698h ADD AL,31h ; for Division replace with MUL BX ; DIV BX MOV AH,4Ch INT 21h END1.(A).DISPLAY A MESSAGE
AIM: To display a message on CRT screen of computer using DOS calls
PROCEDURE:Step1: Switch on computerStep2: Go to start menu and select run prompt, type cmdStep3: Then type edit and open MASM windowStep4: Type your programme and save filename.asmStep5: Go to command prompt and then compile the programmeStep6: Run the programme and see the output in the memory window and register windows
PROGRAMME:ASSUME CS:CODE,DS:DATADATA SEGMENTMSG DB 0DH,0AH,GOOD MORNING,0DH,0AH,$DATA ENDSCODE SEGMENTSTART:MOV AX,DATAMOV DS,AXMOV AH,09HMOV DX,OFFSET MSGINT 21HMOV AH,4CHINT 21HCODE ENDSEND START
OUTPUT: GOOD MORNING
RESULT: Thus the above bios/dos-> display a message program has been successfully executed & the output is verified.
1(B).FILE CREATION
AIM: To create a file using DOS calls
PROCEDURE:
Step1: Switch on computerStep2: Go to start menu and select run prompt, type cmdStep3: Then type edit and open MASM windowStep4: Type your programme and save filename.asmStep5: Go to command prompt and then compile the programmeStep6: Run the programme and see the output in the memory window and register windows
PROGRAMME:ASSUME CS: CODE, DS:DATADATA SEGMENTFILENAME DB SAMPLE.DAT,$DATA ENDSCODE SEGMENTSTART:MOV AX,DATAMOV DS,AXMOV DX,OFFSET FILENAMEMOV AH,3CHINT 21HMOV AH,4CHINT 21HCODE ENDSEND START
OUTPUT:
SAMPLE.DAT file was created( in documents and settings folder )
RESULT: Thus the above program has been successfully executed and the output is verified
1( C).ASCII EQUIVALENT OF A TEXT
AIM: To display ASCII equivalent of a text
PROCEDURE:Step1: Switch on computerStep2: Go to start menu and select run prompt, type cmdStep3: Then type edit and open MASM windowStep4: Type your programme and save filename.asmStep5: Go to command prompt and then compile the programmeStep6: Run the programme and see the output in the memory window and register windows
PROGRAMME:
ASSUME CS:CODE, DS:DATADATA SEGMENTMESSAGE DB 0DH,0AH,GOOD MORNING,0DH,0AH,$DATA ENDSCODE SEGMENTSTART:MOV AX,DATAMOV DS,AXMOV AH,36HMOV DX,OFFSET MSGINT 21HMOV AH,4CHINT 21HCODE ENDSEND START
OUTPUT:
GOOD MORNING
RESULT: Thus the above program has been executed successfully and the output is verified.
1(D) .LARGEST NUMBER IN ARRAY USING MASM
AIM: To implement sorting and searching of Largest number in an array using MASM software
PROCEDURE:
Step1: Switch on computerStep2: Go to start menu and select run prompt, type cmdStep3: Then type edit and open MASM windowStep4: Type your programme and save filename.asmStep5: Go to command prompt and then compile the programmeStep6: Run the programme and see the output in the memory window and register windows
PROGRAMME:
ASSUME CS:CODE,DS:DATADATA SEGMENTLIST DW 52H, 23H, 56H, 45HCOUNT EQU 04LARGEST DB 01H DUP (?)DATA ENDSCODE SEGMENTSSTART: MOV AX,DATA MOV DS,AX MOV SI,OFFSET LISTMOV CL,COUNTMOV AL,[SI]AGAIN:CMP AL,[SI+1]JNL NEXTMOVAL,[SI+1]NEXT:INC SIDEC CLJNZ AGAINMOV SI,OFFSET LARGESTMOV [SI],ALMOV AH,4CHINT 21HCODE ENDSEND STAR
RESULT: Thus the above program has been successfully executed and the output is verified
1(E).DESCENDING ORDER OF AN UNSORTED ARRAY USING MASM
AIM: To implement sorting and searching of Largest number in an array using MASM software
PROCEDURE:
Step1: Switch on computerStep2: Go to start menu and select run prompt, type cmdStep3: Then type edit and open MASM windowStep4: Type your programme and save filename.asmStep5: Go to command prompt and then compile the programmeStep6: Run the programme and see the output in the memory window and register windows
PROGRAMME:
ASSUME CS:CODE,DS:DATADATA SEGMENTLIST DW 53H,25H,19H,02HCOUNT EQU 04DATA ENDSCODE SEGMENTSTART:MOV AX,DATAMOV DS,AXMOV DX,COUNT-1AGAIN0:MOV CX,DXMOV SI,OFFSET LISTAGAIN1:MOV AX,[SI]CMP AX,[SI+2]JNL PR1XCHG [SI+2],AXXCHG [SI],AXPR1:ADD SI,02LOOP AGAIN1DEC DXJNZ AGAIN0MOV AH,4CHINT 21HCODE ENDSEND START
RESULT: Thus the above program has been successfully executed and the output is verified.
1(F).DISPLAY THE STRING
AIM: To implement string display using MASM software and verify result
PROCEDURE:Step1: Switch on computerStep2: Go to start menu and select run prompt, type cmdStep3: Then type edit and open MASM windowStep4: Type your programme and save filename.asmStep5: Go to command prompt and then compile the programmeStep6: Run the programme and see the output in the memory window and register windows
PROGRAMME:
ASSUME CS: CODE, DS:DATADATA SEGMENTMESSAGE DB 0DH, 0AH,MICROPROCESSOR,$DATA ENDSCODE SEGMENTSTART:MOV AX,DATAMOV DS,AXMOV AH,09HMOV DX,OFFSET MESSAGEINC 21HMOV AH,4CHINT 21HCODE ENDSEND START
OUTPUT: MICROPROCESSOR
RESULT: Thus the MASM programme is executed successfully and output verified
1.8086 STRING MANIPULATION SEARCH A WORD
AIM:To search a word from a string.
ALGORITHM:5. Load the source and destination index register with starting and the ending address respectively.6. Initialize the counter with the total number of words to be copied.7. Clear the direction flag for auto incrementing mode of transfer.8. Use the string manipulation instruction SCASW with the prefix REP to search a word from string.9. If a match is found (z=1), display 01 in destination address. Otherwise, display 00 in destination address. RESULT:A word is searched and the count of number of appearances is displayed.
PROGRAM:ASSUME CS: CODE, DS: DATA DATA SEGMENTLIST DW 53H, 15H, 19H, 02H DEST EQU 3000HCOUNT EQU 05HDATA ENDSCODE SEGMENT START:MOV AX, DATAMOV DS, AXMOV AX, 15HMOV SI, OFFSET LISTMOV DI, DESTMOV CX, COUNTMOV AX, 00CLDREPSCASWJZ LOOPMOV AX, 01LOOPMOV [DI], AXMOV AH, 4CHINT 21HCODE ENDSEND START
INPUT:LIST: 53H, 15H, 19H, 02H
OUTPUT:300001
2.8086 STRING MANIPULATION FIND AND REPLACE A WORD
AIM:To find and replace a word from a string.
ALGORITHM:1. Load the source and destination index register with starting and the ending address respectively.2. Initialize the counter with the total number of words to be copied.3. Clear the direction flag for auto incrementing mode of transfer.4. Use the string manipulation instruction SCASW with the prefix REP to search a word from string.5. If a match is found (z=1), replace the old word with the current word in destination address. Otherwise, stop.
RESULT:A word is found and replaced from a string.
PROGRAM:ASSUME CS: CODE, DS: DATA DATA SEGMENTLIST DW 53H, 15H, 19H, 02H REPLACE EQU 30HCOUNT EQU 05HDATA ENDSCODE SEGMENT START:MOV AX, DATAMOV DS, AXMOV AX, 15HMOV SI, OFFSET LISTMOV CX, COUNTMOV AX, 00CLDREPSCASWJNZ LOOPMOV DI, LABEL LISTMOV [DI], REPLACELOOPMOV AH, 4CHINT 21HCODE ENDSEND START
INPUT:LIST: 53H, 15H, 19H, 02H
OUTPUT:LIST: 53H, 30H, 19H, 02H
3. 8086 STRING MANIPULATION COPY A STRING
AIM:To copy a string of data words from one location to the other.
ALGORITHM:10. Load the source and destination index register with starting and the ending address respectively.11. Initialize the counter with the total number of words to be copied.12. Clear the direction flag for auto incrementing mode of transfer.13. Use the string manipulation instruction MOVSW with the prefix REP to copy a string from source to destination.RESULT:A string of data words is copied from one location to other.
PROGRAM:ASSUME CS: CODE, DS: DATA DATA SEGMENTSOURCE EQU 2000HDEST EQU 3000HCOUNT EQU 05HDATA ENDSCODE SEGMENT START:MOV AX, DATAMOV DS, AXMOV ES, AXMOV SI, SOURCEMOV DI, DESTMOV CX, COUNTCLDREPMOVSWMOV AH, 4CHINT 21HCODE ENDSEND START
INPUT:OUTPUT:2000 483000482001843001842002 67300267200390300390200421300421
4.8086 STRING MANIPULATION SORTING
AIM:To sort a group of data bytes.
ALGORITHM: Place all the elements of an array named list (in the consecutive memory locations). Initialize two counters DX & CX with the total number of elements in the array. Do the following steps until the counter B reaches 0. Load the first element in the accumulator Do the following steps until the counter C reaches 0.1. Compare the accumulator content with the next element present in the next memory location. If the accumulator content is smaller go to next step; otherwise, swap the content of accumulator with the content of memory location.2. Increment the memory pointer to point to the next element.3. Decrement the counter C by 1. Stop the execution.
RESULT: A group of data bytes are arranged in ascending order.
PROGRAM:ASSUME CS: CODE, DS: DATA DATA SEGMENTLIST DW 53H, 25H, 19H, 02H COUNT EQU 04HDATA ENDSCODE SEGMENT START:MOV AX, DATAMOV DS, AXMOV DX, COUNT-1LOOP2:MOV CX, DXMOV SI, OFFSET LISTAGAIN:MOV AX, [SI]CMP AX, [SI+2]JC LOOP1XCHG [SI +2], AXXCHG [SI], AXLOOP1:ADD SI, 02LOOP AGAINDEC DXJNZ LOOP2MOV AH, 4CHINT 21HCODE ENDSEND START
INPUT:LIST: 53H, 25H, 19H, 02H
OUTPUT:LIST: 02H, 19H, 25H, 53H
1(G).ARITHMETIC OPERATIONS USING MASM
AIM: To Implement the programme for arithmetic operations using MASM software
PROCEDURE:
Step1: Switch on computerStep2: Go to start menu and select run prompt, type cmdStep3: Then type edit and open MASM windowStep4: Type your programme and save filename.asmStep5: Go to command prompt and then compile the programmeStep6: Run the programme and see the output in the memory window and register windows
PROGRAMME:
ASSUME CS:CODE,DS:DATADATA SEGMENTOPR1 EQU 98HOPR2 EQU 49HSUM DW 01 DUP(00)SUBT DW 01 DUP(00)PROD DW 01 DUP(00)DIVS DW 01 DUP(00)DATA ENDSCODE SEGMENTSTART:MOV AX,DATAMOV DS,AXMOV BL,OPR2XOR AL,ALMOV AL,OPR1ADD AL,BLDAAMOV BYTE PTR SUM,ALJNC MSB0INC [SUM+1]MSB0:XOR AL,ALMOV AL,OPR1SUB AL,BLDASMOV BYTE PTR SUBT,ALJNB MSB1INC [SUBT+1]MSB1:XOR AL,ALMOV AL,OPR1MUL BLMOV WORD PTR PROD,AXXOR AH,AHMOV AL,OPR1DIV BLMOV WORD PTR DIVS,AXMOV AH,4CHINT 21HCODE ENDSEND START
RESULT: Thus the MASM programme is executed successfully and output is verified.
8086/Masm Program To Multiply Two Matrices .DATA SEGMENTAR1 DB 1H,2H,-3HAR2 DB 4H,5H,6HAR3 DB 2H,-1H,3HBC1 DB 2H,4H,-4HBC2 DB 3H,-2H,5HBC3 DB 1H,5H,2HC DB 9 DUP (?)L2 DB (?)L1 DB (?)DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART: MOV AX,DATAMOV DS,AXMOV ES,AXMOV BP,0HMOV L2,3HLEA SI,AR1REPEAT2: LEA DI,BC1MOV L1,3HREPEAT1: MOV CX,3HMOV BX,0HMOV DL,0HAGAIN: MOV AL,[SI][BX]IMUL BYTE PTR[DI][BX]ADD DL,ALINC BXLOOP AGAINMOV DS:C[BP],DLINC BPADD DI,3HDEC L1JNE REPEAT1ADD SI,3HDEC L2JNE REPEAT2MOV AH,4CHINT 21HCODE ENDSEND START
2.f.i Binary to BCD conversion .MODEL SMALL .DATA Binary DB 63h Ans DB 00h, 00h, 00h .CODE MOV AX,@DATA MOV DS, AX MOV AX, 00h MOV AL, Binary MOV CL, 64h DIV CL MOV BCD, AL MOV AL, AH MOV AH, 00h MOV CL, 0Ah DIV CL MOV Ans+ 1, AL MOV Ans+2, AH OR Ans, 30h OR Ans+ l,30h OR Ans+2,30h MOV AH, 4Ch INT 21h END
BCD to Binary conversion .MODEL SMALL .DATA BCD DB 15h Ans DB 00h .CODE MOV AX,@DATA MOV DS, AX MOV AL, BCD AND AL, 0Fh MOV BL, AL MOV AL, BCD AND AL, 0F0h MOV CL, 04h ROR AL, CL MOV CL, 0Ah MUL CL ADD AL, BL MOV Ans, AL MOV AH, 4Ch INT 21h END
Bit manupilation to check if the data is positive or negative .MODEL SMALL .DATA Msg1 DB ENTERED NUMBER IS POSITIVE. $ Msg2 DB ENTERED NUMBER IS NEGATIVE. $ Input DB ? .STACK .CODE MOV AX, @Data MOV DS, AX MOV AL, Input ROL AL, 01h JC NEXT LEA DX, Msg1 MOV AH, 09h INT 21h JMP LAST NEXT: LEA DX, Msg2 MOV AH, 09h INT 21h LAST: MOV AH, 4Ch INT 21h END
Bit manupilation to check if the data is odd or even .MODEL SMALL .DATA Msg1 DB ENTERED NUMBER IS ODD. $ Msg2 DB ENTERED NUMBER IS EVEN. $ Input DB ? .STACK .CODE MOV AX, @Data MOV DS, AX MOV AL, Input SAR AL, 01h JC NEXT LEA DX, Msg2 MOV AH, 09h INT 21h JMP LAST NEXT: LEA DX, Msg1 MOV AH, 09h INT 21h LAST: MOV AH, 4Ch INT 21h END
Bit manupilation to count the number of 1s and 0s in given data .MODEL SMALL .CODE MOV CX, 0008h MOV AL, 24h MOV BL, 00h MOV DL, BL NEXT: SAR AL, 01h JC DOWN INC BL LOOP NEXT JMP LAST DOWN: INC DL LOOP NEXT LAST: MOV AH, 4Ch INT 21h END
7(b) .CUBE OF NUMBERAIM: WRITE AN ASSEMBLY LANGUAGE PROGRAM TO FIND THE CUBE OFTHE GIVEN NUMBER.SOFTWARE REQUIRED: MASM 611ASSEMBLY LANGUAGE PROGRAM:ASSUME CS: CODE, DS: DATADATA SEGMENTNO1 DB 06HAD1 DW 5000HDATA ENDSCODE SEGMENTSTART:ORG 600HMOV AX, DATAMOV DS, AXXOR AX, AXMOV SI, AD1MOV CL, NO1ABC: MOV AL, [SI]MOV BL, ALMUL BLMUL BLMOV [SI], AL,INC SIDEC CLJNZ ABCINT 21HCODE ENDSEND STARTRESULT: CUBE OPERATION IS PERFORMED USING MASM SOFTWARE.7(c).AVERAGE OF NUMBERAIM: WRITE AN ASSEMBLY LANGUAGE PROGRAM TO FIND THE CUBE OFTHE GIVEN NUMBER.SOFTWARE REQUIRED: MASM 611ASSEMBLY LANGUAGE PROGRAM:ASSUME CS: CODE, DS: DATADATA SEGMENTNO1 DW 7000HDATA ENDSCODE SEGMENTSTART:ORG 600HMOV AX, DATAMOV DS, AXXOR CX, CXMOV AX,[BX]MOV CL, 06HDEC CXABC: INC SIADD AX,[BX]DEC CXJNZ ABCDIV BXINT 21HCODE ENDSEND STARTRESULT: AVERAGE OF NUMBERS OPERATION IS PERFORMED USING MASMSOFTWARE.
7(a) SQUARE OF NUMBERAIM: WRITE AN ASSEMBLY LANGUAGE PROGRAM TO FIND THE SQUARE OFTHE GIVEN NUMBER.SOFTWARE REQUIRED: MASM 611ASSEMBLY LANGUAGE PROGRAM:ASSUME CS: CODE, DS: DATADATA SEGMENTNO1 DB 06HAD1 DW 5000HDATA ENDSCODE SEGMENTSTART:ORG 600HMOV AX, DATAMOV DS, AXXOV AX, AXMOV SI, AD1MOV CL, NO1ABC: MOV AL, [SI]MOV BL, ALMUL BLMOV [SI], AL,INC SIDEC CLJNZ ABCINT 21HCODE ENDSEND STARTRESULT: SQUARING OPERATION IS PERFORMED USING MASM SOFTWARE.
1.b.i Block transfer without overlap .MODEL SMALL .DATA Array1 DW 1111h,2222h,3333h,4444h,5555h Array2 DW 5 DUP (0) Count DW 0005H .CODE MOV AX,@DATA MOV DS,AX LEA SI,Array1 LEA DI,Array2 MOV CX,Count NEXT: MOV AX,[SI] MOV [DI],AX INC SI INC SI INC DI INC DI LOOP NEXT MOV AH,4Ch INT 21h END
1.b.ii Block transfer with overlap .MODEL SMALL .DATA Array DB 11h,22h,33h,44h,55h Count DW 0005h .CODE MOV AX,@DATA MOV ES,AX MOV DS,AX LEA SI,Array ADD SI,Count MOV CX,Count DEC SI MOV DI,SI ADD DI,2h STD REP MOVSB MOV AH,4Ch INT 21h END
5.i String transfer .MODEL SMALL .DATA String1 DB 'BMSCE DEPT OF ECE$' Length EQU ($-String1) String2 DB LEN DUP (0) .CODE MOV AX, @DATA MOV DS, AX MOV ES, AX MOV CX, Length CLD LEA SI, String1 LEA DI, String2 REP MOVSB MOV AH, 4Ch INT 21h END
String reverse .MODEL SMALL .DATA String DB 'BMSCE$' Length EQU ($-String) Rvrs DB Length DUP (0) .CODE MOV AX,@DATA MOV DS, AX MOV ES, AX MOV CX, Length LEA SI, String+Length-1 LEA DI, Rvrs REPEAT: MOV AL, [SI] MOV [DI], AL DEC SI INC DI LOOP REPEAT MOV AH, 4Ch INT 21h END
Character search in a string .MODEL SMALL .DATA String DB 'BMS COLLEGE' Length EQU ($-String) Key DB 'X' Dis1 DB '-IS PRESENT IN GIVEN STRING$' Dis2 DB '-IS NOT PRESENT IN GIVEN STRING$' .CODE MOV AX,@DATA MOV DS, AX MOV ES, AX MOV DL, Key MOV AH, 02h INT 21h LEA DI, String MOV AL, Key MOV CX, Length REPNE SCASB JE PRESENT LEA DX, Dis2 CALL Display JMP OVER PRESENT: LEA DX, Dis1 CALL Display OVER: MOV AH, 4Ch INT 21h Display PROC NEAR MOV AH, 09h INT 21h RET Display ENDP END
Matrix Keyboard Interfacing CODE SEGMENT ASSUME CS:code,DS:code,ES:code,SS:code CWR EQU 46h PORTA EQU 40h PORTB EQU 42h PORTC EQU 44h ORG 0400h MOV AL, 88h ; port a and port c high as output OUT CWR,AL ; port b and port c low as output READKEY: MOV DL,0 ; clear e/dl register MOV AL,0F0h ; output all one's to pc high OUT PORTC,AL LP: IN AL,PORTC AND AL,0F0h CMP AL,0F0h JNZ LP CALL FAR PTR ONEMS KEYCHK: IN AL,PORTC AND AL,0F0h CMP AL,0F0h JZ KEYCHK ;wait for key press CALL FAR PTR ONEMS MOV AL,7Fh MOV BH,04h NXTCOLM: ROL AL, 01h ; scan each column MOV DH,AL ; and wait for the data OUT PORTC,AL ; in any of the four IN AL,PORTC ; rows AND AL,0F0h MOV CL,04h NXTROW: ROL AL,01h ; scan each column JNC CODEN ; scan each column INC DL ; in any of the four DEC CL ; rows JNZ NXTROW MOV AL,DH DEC BH JNZ NXTCOLM JMP KEYCHK
CODEN: MOV AL,DL MOV DH,0h MOV BX,OFFSET LOOKUP+8000h ADD BX,DX MOV AL,BYTE PTR[BX] OUT PORTB,AL JMP READKEYONEMS: ; delay routine PUSH AX MOV AL,0FFh LOP: DEC AL JNZ LOP POP AX RETFLOOKUP: DB 00h,04h,08h,0Ch,01h,05h,09h,0Dh DB 02h,06h,0Ah,0Eh,03h,07h,0Bh,0Fh CODE ENDS END
1. ADDITION OF TWO 8-BIT BCD
DATA SEGMENT MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER:','$' MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER:','$' MESS3 DB 0AH,0DH,'SUM OF TWO 8-BIT NUMBER IS:','$'DATA ENDS
CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX LEA DX,MESS1 MOV AH,09H INT 21H CALL READ MOV BL,DL LEA DX,MESS2 MOV AH,09H INT 21H CALL READ MOV CL,00H MOV AL,BL ADD AL,DL DAA JNC NEXT INC CL NEXT:MOV BL,AL CALL DISP MOV AH,4CH INT 21H
READ PROC NEAR PUBLIC READ
MOV AH,01H INT 21H MOV DL,AL MOV CL,04H SUB DL,30H CMP DL,0AH JC R1 SUB DL,07H R1:SHL DL,CL MOV AH,01H INT 21H SUB AL,30H CMP AL,0AH JC R2 SUB AL,07H R2:AND AL,0FH OR DL,AL RET READ ENDP
DISP PROC NEAR PUBLIC DISP LEA DX,MESS3 MOV AH,09H INT 21H MOV DL,CL ADD DL,30H MOV AH,06H INT 21H MOV CL,04H MOV DL,BL SHR DL,CL CMP DL,0AH JC L1 ADD DL,07H L1:ADD DL,30H MOV AH,06H INT 21H AND BL,0FH CMP BL,0AH JC L2 ADD BL,07H L2:ADD BL,30H MOV DL,BL MOV AH,06H INT 21H RET
DISP ENDPCODE ENDSEND STARTOUTPUT:
ENTER FIRST NUMBER : 97ENTER SECOND NUMBER : 56SUM OF TWO 8-BIT NUMBER IS : 153
ENTER FIRST NUMBER : 82ENTER SECOND NUMBER : 19SUM OF TWO 8-BIT NUMBER IS : 101
2. SUBTRACTION OF TWO 8-BIT BCD NUMBERS
DATA SEGMENT MESS1 DB 0AH,0DH,'ENTER FIRST NO:','$' MESS2 DB 0AH,0DH,'ENTER SECOND NO:','$' MESS3 DB 0AH,0DH,'SUBTRACTION OF TWO 8-BIT NO IS:','$'DATA ENDS
CODE SEGMENT ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA MOV DS,AX LEA DX,MESS1 MOV AH,09H INT 21H CALL READ MOV BL,DL LEA DX,MESS2 MOV AH,09H INT 21H CALL READ MOV CL,00H MOV AL,BL SUB AL,DL DAS JNC NEXT MOV CH,99H SUB CH,AL MOV AL,CH ADD AL,01H DAA MOV CL,'-' NEXT: MOV BL,AL CALL DISP MOV AH,4CH INT 21H
READ PROC NEAR PUBLIC READ
MOV AH,01H INT 21H MOV DL,AL MOV CL,04H SUB DL,30H CMP DL,0AH JC R1 SUB DL,07H R1:SHL DL,CL MOV AH,01H INT 21H SUB AL,30H CMP AL,0AH JC R2 SUB AL,07H R2:AND AL,0FH OR DL,AL RET READ ENDP
DISP PROC NEAR PUBLIC DISP
LEA DX,MESS3 MOV AH,09H INT 21H MOV DL,CL ADD DL,30H MOV AH,06H INT 21H MOV CL,04H MOV DL,BL SHR DL,CL CMP DL,0AH JC L1 ADD DL,07H L1:ADD DL,30H MOV AH,06H INT 21H AND BL,0FH CMP BL,0AH JC L2 ADD BL,07H L2:ADD BL,30H MOV DL,BL MOV AH,06H INT 21H RET
DISP ENDPCODE ENDSEND START
OUTPUT:
ENTER FIRST NUMBER : 98ENTER SECOND NUMBER : 54SUBTRACTION OF TWO 8-BIT NUMBER IS : 044
ENTER FIRST NUMBER : 87ENTER SECOND NUMBER : 98SUBTRACTION OF TWO 8-BIT NUMBER IS : -11
23.TRANSPOSE OF THE MATRIX
DATA SEGMENT M1 DB 'ENTER THE ORDER OF THE MATRIX:','$' M2 DB 0AH,0DH,0AH,'ENTER THE ORDER OF SECOND MATRIX:','$' M3 DB 0AH,0DH,0AH,'TRANSPOSE MATRIX:',0AH,0DH,'$' MAT1 DB 10 DUP(0) MAT2 DB 10 DUP(0) ROW DB 00H COL DB 00H DATA ENDS
MESSAGE MACRO MESS LEA DX,MESS MOV AH,09H INT 21H ENDM
BSPCE MACRO ASC MOV DL,ASC MOV AH,06H INT 21H ENDM
CODE SEGMENT ASSUME CS:CODE,DS:DATA START:MOV AX,DATAMOV DS,AXMESSAGE M1CALL READOMOV BX,DXMOV ROW,DHMOV COL,DLMESSAGE M2LEA SI,MAT1CALL READ1LEA DI,MAT1LEA SI,MAT2MOV DH,00HMOV DL,COLMOV AH,COLL3:MOV AL,ROWMOV BX,DIL1:MOV CL,[BX]MOV [SI],CLADD BX,DXINC SIDEC ALJNZ L1INC DIDEC AHJNZ L3LEA SI,MAT2CALL DISPMOV AH,4CHINT 21H
READO PROC NEAR PUBLIC READO MOV AH,01H INT 21H MOV DH,AL SUB DH,30H BSPCE ' ' MOV AH,01H INT 21H MOV DL,AL SUB DL,30H RET READO ENDP
READ1 PROC NEAR BSPCE 0AH MOV CH,ROW N2:MOV BH,COL N1:CALL READ MOV [SI],DL INC SI BSPCE ' ' DEC BH JNZ N1 DEC CH JZ N3 BSPCE 0AH BSPCE 0DH JMP N2 N3:RET READ1 ENDP
READ PROC NEAR PUBLIC READ
MOV AH,01HINT 21HMOV CL,04HMOV DL,ALSUB DL,30HCMP DL,0AHJC R1SUB DL,07HAND DL,0FHR1:SHL DL,CLMOV AH,01HINT 21HSUB AL,30HCMP AL, 0AHJC R2SUB AL,07HAND AL,0FHR2:OR DL,ALRET READ ENDP
DISP PROC NEAR PUBLIC DISP MESSAGE M3BSPCE 0AHMOV DH,COLD4:MOV BH,ROWLOP:MOV CL,04HMOV DL,[SI]SHR DL,CLCMP DL,0AHJC D1ADD DL,07HD1: ADD DL,30HMOV AH,06HINT 21HMOV DL,[SI]AND DL,0FHCMP DL,0AHJC D2ADD DL,07HD2: ADD DL,30HMOV AH,06HINT 21HINC SIBSPCE ' 'DEC BHJNZ LOPDEC DHJZ D3BSPCE 0AHBSPCE 0DHJMP D4 D3: RET DISP ENDP CODE ENDS END START
OUTPUT :
ENTER THE ORDER OF THE MATRIX : 2 3
ENTER THE ELEMENTS OF THE MATRIX:11 55 9922 74 51
TRANSPOSE MATRIX :11 2255 7499 51
3. SUBTRACTION OF TWO 16-BIT BCD NUMBERS
DATA SEGMENT MESS1 DB 0AH,0DH,'ENTER FIRST NO:','$' MESS2 DB 0AH,0DH,'ENTER SECOND NO:','$' MESS3 DB 0AH,0DH,'SUBTRACTION OF TWO 16-BIT NO IS:','$'DATA ENDS
CODE SEGMENT ASSUME CS:CODE,DS:DATASTART: MOV AX,DATAMOV DS,AXLEA DX,MESS1MOV AH,09HINT 21HCALL READMOV BX,DXLEA DX,MESS2MOV AH,09HINT 21HCALL READMOV AX,BXMOV CL,' 'MOV AL,BLSUB AL,DLDASMOV BL,ALMOV AL,BHSBB AL,DHDASMOV BH,ALJNC NEXTMOV AX,0000HSUB AL,BLADD DL,01HDASMOV BL,ALMOV AL,AHSBB AL,BHDASMOV BH,ALMOV CL,'-'NEXT: CALL DISPMOV AH,4CHINT 21H
READ PROC NEAR PUBLIC READMOV CH,02HR3: MOV AH,01HINT 21HMOV CL,04HMOV DL,ALSUB DL,30HCMP DL,0AHJC R1SUB DL,07HR1:SHL DL,CLMOV AH,01HINT 21HSUB AL,30HCMP AL,0AHJC R2SUB AL,07HR2: AND AL,0FHOR DL,ALDEC CHJZ R4MOV DH,DLJMP R3R4:RETREAD ENDP
DISP PROC NEAR PUBLIC DISPLEA DX,MESS3MOV AH,09HINT 21HMOV DL,CLMOV AH,06HINT 21HMOV CH,02HL3:MOV CL,04HMOV DL,BHSHR DL,CLCMP DL,0AHJC L1ADD DL,07HL1:ADD DL,30HMOV AH,06H INT 21H AND BH,0FH CMP BH,0AH JC L2 ADD BH,07HL2:ADD BH,30H MOV DL,BH MOV AH,06H INT 21H DEC CH JZ L4 MOV BH,BL JMP L3 L4:RET DISP ENDPCODE ENDSEND START
OUTPUT:
ENTER FIRST NUMBER : 9873ENTER SECOND NUMBER : 8642SUBTRACTION OF TWO 8-BIT NUMBER IS : 01231
ENTER FIRST NUMBER : 2431ENTER SECOND NUMBER : 9247SUBTRACTION OF TWO 8-BIT NUMBER IS : -681640.TO DISPLAY CURRENT TIME.DATA SEGMENT MESS1 DB 0AH,0DH,'TIME IS:'0AH,0DH,'$'DATA ENDS
CODE SEGMENT ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA MOV DS,AX LEA DX,MESS1 MOV AH,09H INT 21H L1:MOV AH,2CH INT 21H MOV AL,CH CALL CONV CALL DISP MOV DL,':' MOV AH,06H INT 21H MOV AL,CL CALL CONV CALL DISP MOV DL,':' MOV AH,06H INT 21H MOV DL,0DH MOV AH,06H INT 21H JMP L1 MOV AH,4CH INT 21H
DISP PROC NEAR PUBLIC DISP
MOV BL,AH MOV DL,AL ADD DL,30H MOV AH,06H INT 21H MOV DL,BL ADD DL,30H MOV AH,06H INT 21H RET
DISP ENDP
CONV PROC NEAR PUBLIC CONV
MOV AH,00H MOV BH,0AH DIV BH RET
CONV ENDP CODE ENDS END START
OUTPUT:
THE CURRENT TIME IS: 23:37:23.85
41.TO DISPLAY CURRENT DATE.
DATA SEGMENT MESS1 DB 0AH,0DH,'THE CURRENT DATE IS:'$'DATA ENDS
CODE SEGMENT ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA MOV DS,AX LEA DX,MESS1 MOV AH,09H INT 21H MOV AH,2AH INT 21H MOV SI,CX MOV BL,DH MOV BH,DL CALL DISP MOV DL,'-' MOV AH,06H INT 21H MOV BL,BH CALL DISP MOV DL,'-' MOV AH,06H INT 21H XOR DX,DX MOV AX,SI MOV CX,0064H DIV CX MOV DH,DL MOV BL,AL CALL DISP MOV BL,DH MOV AH,4CH INT 21H
CONV PROC NEAR PUBLIC CONV
MOV CL,04H XOR AH,AH MOV AL,BL MOV BL,0AH DIV BL SHL AL,CL ADD AL,AH DAA MOV BL,AL RET
CONV ENDP
DISP PROC NEAR PUBLIC DISP
MOV CL,04H CALL CONV MOV DL,BL SHR DL,CL ADD DL,30H MOV AH,06H INT 21H AND BL,0FH ADD BL,30H MOV DL,BL MOV AH,06H INT 21H RET
DISP ENDP CODE ENDS END START
OUTPUT:
THE CURRENT DATE IS: MON 07/11/2011
14. AVERAGE OF 8-BIT NUMBERS (BCD)
DATA SEGMENT MESS1 DB 0AH,0DH,'ENTER THE LIMIT: ''$' MESS2 DB 0AH,0DH,'ENTER THE NUMBER:','$' MESS3 DB 0AH,0DH,'AVERAGE IS : ', '$' QUO DB 00H DATA ENDS
CODE SEGMENT ASSUME CS:CODE,DS:DATA START :MOV AX,DATA MOV DS,AX LEA DX,MESS1 MOV AH,09H INT 21H CALL READ MOV CH,DL LEA DX,MESS2 MOV AH,09H INT 21H CALL READ MOV BL,DL MOV DH,CH MOV BH,00H N1:MOV AL,CH SUB AL,01H DAS MOV CH,AL JZ N2 MOV DL,',' MOV AH,06H INT 21H CALL READ MOV AL,BL ADD AL,DL DAA MOV BL,AL JNC N3 MOV AL,BH ADD AL,01H DAA MOV BH,AL N3:JMP N1 N2:MOV CH,02H MOV DL,DH MOV DH,00H MOV CL,00H N4: MOV AX,BX SUB AL,DL DAS MOV BL,AL MOV AL,BH SBB AL,00H DAS MOV BH,AL MOV AL,CL ADD AL,01H DAA MOV CL,AL CMP BX,DX JAE N4 DEC CH JZ N5 MOV QUO,CL MOV CL,00H MOV BH,BL JMP N4 N5: MOV BL,QUO MOV BH,CL CALL DISP MOV AH,4CH INT 21HREAD PROC NEARPUBLIC READ
MOV AH,01H INT 21H MOV CL,04H SHL AL,CL MOV DL,AL MOV AH,01H INT 21H AND AL,0FH OR DL,AL RET
READ ENDP
DISP PROC NEAR PUBLIC DISP
LEA DX,MESS3 MOV AH,09H INT 21H MOV CH,02H LOP:MOV CL,04H MOV DL,BL SHR DL,CL ADD DL,30H MOV AH,06H INT 21H AND BL,0FH ADD BL,30H MOV DL,BL MOV AH,06H INT 21H DEC CH JZ RT CMP CH,01H JNZ L3 MOV DL,'.' MOV AH,06H INT 21H L3:MOV BL,BH JMP LOP RT:RET
DISP ENDP
CODE ENDS END START
OUPTUT:
ENTER THE LIMIT: 05ENTER THE NUMBERS: 34,45,56,67,78THE AVERAGE IS : 56
19.ADDITION OF TWO MATRICES (HEXADECIMAL)
DATA SEGMENT M1 DB 'ENTER THE ORDER OF FIRST MATRIX:','$' M2 DB 0AH,0DH,0AH,'ENTER THE ORDER OF SECOND MATRIX:','$' M3 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF FIRST MATRIX:',0AH,0DH,'$' M4 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF SECOND MATRIX:',0AH,0DH,'$' M5 DB 0AH,0DH,0AH,' SUM OF TWO MATRICES: ',0AH,0DH, '$' M6 DB 0AH,0DH,0AH,' MATRICES CANNOT BE ADDED: ','$' MAT1 DB 10 DUP(0) MAT2 DB 10 DUP(0) MAT3 DB 30 DUP(0) ROW DB 00H COL DB 00H DATA ENDS
MESSAGE MACRO MESS LEA DX,MESS MOV AH,09H INT 21H ENDM
BSPCE MACRO ASC MOV DL,ASC MOV AH,06H INT 21H ENDM
CODE SEGMENT ASSUME CS:CODE,DS:DATA START:MOV AX,DATA MOV DS,AX MESSAGE M1 CALL READO MOV BX,DX MOV ROW,DH MOV COL,DL MESSAGE M2 CALL READO CMP BX,DX JZ L1 MESSAGE M6 JMP L7 L1:MESSAGE M3 LEA SI,MAT1 CALL READ1 MESSAGE M4 LEA SI,MAT2 CALL READ1 MESSAGE M5 BSPCE 0AH LEA DI,MAT1 LEA SI,MAT2 LEA BX,MAT3 MOV CH,ROW L6:MOV CL,COL L2:MOV DH,00H MOV DL,[SI] ADD DL,[DI] JNC L5 INC DH L5:MOV [BX],DH INC BX MOV [BX],DL INC DI INC SI INC BX DEC CL JNZ L2 DEC CH JZ L3 JMP L6 L3: CALL DISP L7: MOV AH,4CH INT 21H
READO PROC NEAR PUBLIC READO MOV AH,01H INT 21H MOV DH,AL SUB DH,30H BSPCE ' ' MOV AH,01H INT 21H MOV DL,AL SUB DL,30H RET READO ENDP READ1 PROC NEARPUBLIC READ1 BSPCE 0AH MOV CH,ROW N2:MOV BH,COL N1:CALL READ MOV [SI],DL INC SI BSPCE ' ' DEC BH JNZ N1 DEC CH JZ N3 BSPCE 0AH BSPCE 0DH JMP N2 N3:RET READ1 ENDP
READ PROC NEAR PUBLIC READMOV AH,01HINT 21HMOV CL,04HMOV DL,ALSUB DL,30HCMP DL,0AHJC R1SUB DL,07HR1:SHL DL,CLMOV AH,01HINT 21HSUB AL,30HCMP AL, 0AHJC R2SUB AL,07HAND AL,0FHR2:OR DL,ALRET READ ENDP
DISP PROC NEAR PUBLIC DISP LEA BX,MAT3 MOV CH,ROW D4:MOV DH,COL LOP:MOV CL,04H MOV DL,[BX] ADD DL,30H MOV AH,06H INT 21H INC BX MOV CL,04H MOV DL,[BX] SHR DL,CL CMP DL,0AH JC D1 ADD DL,07H D1: ADD DL,30H MOV AH,06H INT 21H MOV DL,[BX] AND DL,0FH CMP DL,0AH JC D2 ADD DL,07H D2: ADD DL,30H MOV AH,06H INT 21H INC BX BSPCE ' ' DEC DH JNZ LOP DEC CH JZ D3 BSPCE 0AH BSPCE 0DH JMP D4 D3: RETDISP ENDP CODE ENDS END START
OUTPUT 1:
ENTER THE ORDER OF FIRST MATRIX : 2 2
ENTER THE ORDER OF SECOND MATRIX : 2 2
ENTER THE ELEMENTS OF FIRST MATRIX:11 1111 11
ENTER THE ORDER OF SECOND MATRIX02 0202 02
SUM OF TWO MATRICES:013 013014 014
OUTPUT 2:ENTER THE ORDER OF FIRST MATRIX : 2 3
ENTER THE ORDER OF SECOND MATRIX : 2 2
MATRICES CANNOT BE ADDED
4.(A)TRAFFIC SIGNAL CONTROLLER USING 8255 PPI
AIM: To Implement Traffic signal controller using 8255 PPI
Apparatus:1.8086 trainer kit2. Traffic signal controller board3.power connectionProcedure:Step 1: Start the processStep 2: Connect the traffic controller interface kit along with the system using SMPSStep 3: Program the operation in system by program-> Assessories-> Communication-> Hyper Terminals-> Enter okStep 4: Enter the GND 1 serial in 8086 kitStep 5:Enter the 1205 for setup motorStep 6: Stop the program PROGRAMME:MEMORY ADDRESSLABELMNEMONICOPCODECOMMENTS
0100STRT:JMP SKIP DATAEB,01,90
0103SKIP DATA:MOV AX,11FFB8,FF
STRT1:MOV SP,AX8B,E0
PUSH CSBE
POP DS1F
NOP90
NOP90
NOP90
MOV AL,80B0,80
MOV DX,8006BA,80,06
OUT DX,ALEE
START:MOV AL,61HB0,61
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,68HB0,68
MOV DX,8002HBA,80,02
OUT DX,ALEE
MOV AL,86HB0,86
MOV DX,8004HBA,80,04
OUT DX,ALEE
MOV AL,60HB0,60
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,48HB0,48
MOV DX,8002HBA,80,02
OUT DX,ALEE
MOV AL,64HB0,64
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,58HB0,58
MOV DX,8002HBA,80,02
OUT DX,ALEE
CALL DELAY1E8,01,27
MOV AL,60HB0,60
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,48HB0,48
MOV DX,8002HBA,80,02
OUT DX,ALEE
MOV AL,62HB0,62
MOV DX,8000HBA,80,00
OUT DX,ALEE
CALL DELAY2E8,01,0B
MOV AL,60HB0,60
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,61HB0,61
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,68HB0,68
MOV DX,8002HBA,80,02
OUT DX,ALEE
CALL DELAY3E8,00,F6
MOV AL,41HB0,41
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,06HB0,06
MOV DX,8004HBA,80,04
OUT DX,ALEE
MOV AL,49HB0,49
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,26HB0,26
MOV DX,8004BA,80,04
OUT DX,ALEE
CALL DELAY1E8,00,E2
MOV AL,41HB0,41
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,06HB0,06
MOV DX,8004HBA,80,04
OUT DX,ALEE
MOV AL,51HB0,51
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,46HB0,46
MOV DX,8004HBA,80,04
OUT DX,ALEE
CALL DELAY2E8,00,C0
MOV AL,41HB0,41
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,06HB0,06
MOV DX,8004BA,80,04
OUT DX,ALEE
MOV AL,61HB0,61
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,86B0,86
MOV DX,8004HBA,80,04
OUT DX,ALEE
CALL DELAY2E8,00,AS
MOV AL,60HB0,60
MOV DX,8002HBA,80,02
OUT DX,ALEE
MOV AL,82HB0,82
MOV DX,8004HBA,80,04
OUT DX,ALEE
MOV AL,62HB0,62
MOV DX,8002HBA,80,02
OUT DX,ALEE
MOV AL,92HB0,92
MOV DX,8004HBA,80,04
OUT DX,ALEE
CALL DELAY1E8,00,91
MOV AL,60HB0,60
MOV DX,8002HBA,80,02
OUT DX,ALEE
MOV AL,82HB0,82
MOV DX,8004HBA,80,04
OUT DX,ALEE
MOV AL,64HB0,64
MOV DX,8002HBA,80,02
OUT DX,ALEE
MOV AL,8AHB0,8A
MOV DX,8004HBA,80,04
OUT DX,ALEE
CALL DELAY2E8,00,6F
MOV AL,60HB0,60
MOV DX,8002HBA,80,02
OUT DX,ALEE
MOV AL,82HB0,82
MOV DX,8004HBA,80,04
OUT DX,ALEE
MOV AL,68HB0,68
MOV DX,8002HBA,80,02
OUT DX,ALEE
MOV AL,86HB0,86
MOV DX,8004HBA,80,04
OUT DX,ALEE
CALL DELAY2E8,00,54
MOV AL,21HB0,21
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,28HB0,28
MOV DX,8002HBA,80,02
OUT DX,ALEE
MOV AL,29HB0,29
MOV DX,8002HBA,80,02
OUT DX,ALEE
MOV AL,87HB0,87
MOV DX,8004HBA,80,04
OUT DX,ALEE
CALL DELAY1E8,00,40
MOV AL,21HB0,21
MOV DX,8002HBA,80,02
OUT DX,ALEE
MOV AL,86HB0,86
MOV DX,8004HBA,80,04
OUT DX,ALEE
MOV AL,0A1B0,A1
MOV DX,8000BA,80,00
OUT DX,ALEE
MOV AL,0A8B0,A8
MOV DX,8002BA,80,02
OUT DX,ALEE
CALL DELAY2E8,00,1E
MOV AL,21HB0,21
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,28HB0,28
MOV DX,8002BA,80,02
OUT DX,ALEE
MOV AL,61HB0,61
MOV DX,8000HBA,80,00
OUT DX,ALEE
MOV AL,68HB0,68
MOV DX,8002BA,80,02
OUT DX,ALEE
JMP STARTE9,FE,B3
CALL DELAY2CD,AA
INT 0AACD,AA
INT OAACD,AA
RETC3
DELAY1:CALL DELAY2E8,FF,F6
CALL DELAY2E8,FF,F3
CALL DELAY2E8,FF,F0
CALL DELAY2E8,FF,ED
CALL DELAY2E8,FF,EA
RETC3
RESULT : Thus the interface was successfully executed and the output has been verified
4(B). STEPPER MOTOR SPEED CONTROLLER USING8255 PPI
AIM: To Implement the programme for Stepper motor controller using 8255 PPI to interface 8086
Apparatus:1.8086 trainer kit2. Stepper motor
PROCEDURE:
Step1: Start the programmeStep2: Connect the kit to the system.The kit connects one separate keyboardStep3: After connecting the kit ,in kit press R then enter,it shows the kit name in monitorStep4: Press I write then E038 start & ending address givenStep5: Then menu has transfer->send dataStep6: See the output in kit through the monitorStep7: Stop the programme
PROGRAMME:MEMORYADDRESSLABELMNEMONICOPCODECOMMENTS
0100MOV AX,0000B8,00,00
0103MOV ES,AX8E,C0
0105MOV SS,AX8E,D0
0107MOV AX,11F0B8,11,F0
010AMOV SP,AX89,C4
010CPUSH CSBE
010DPOP DS1F
010EMOV AL,80B0,80
0110MOV DX,CR 55BA,80,06
0113OUT DX,ALEE
0114MOV AL,00B0,00
0116MOV DX,OFFSET CODEBA,01,C0
0119OUT DX,ALEE
011AMOV DX,OFFSET CODEBA,01,C0
011DMOV CL,40B1,40
011FMOV CH,80B5,80
0121MOV BH,10B7,10
0123SPEED: MOV BL,08B3,08
0125BACK: CALL STPRE8,00,58
0128INT 0A AHCD,AA
012ADEC BLFE,CB
012CJNZ BACK75,F7
012EDEC CHFE,CD
0130DEC BHFE,CF
0132JNZ SPEED 75,EF
0134MOV BL,11B3,11
0136BACK1: CALL STPRE8,00,47
0139INT 0A AHCD,AA
013BDEC BLFE,CB
013DJNZ BACK175,F7
013FMOV BH,10B7,10
0141MOV BL,08B3,08
0143CALL STPRE8,00,3A,BACK2
0146INT OS 5HFD,55
0148DEC BLFE,CB
014AJNZ BACK275,E7
014CINC CHFE,C5
014EDEC BHFE,CF
0150JNZ SPDCONT75,EF
0152MOV AL,00HB0,00
0154MOV DX,PORTABA,80,00
0157OUT DX,ALEE
0158MOV AH,08B4,08
015AINT OA 1HCD,A1
015CCMP AL,1B3C,1B
015EJNZ STRT75,A0
0160INT OA 3HCD,A3
0180ORG 01 80----
0180STPR:PUSH BX53
0181NOP90
0182MOV BX,BX89,D3
0184MOV AL,[BX]8A,07
0186MOV DX,PORTABA,80,00
0189OUT DX,ALEE
018ANOP90
018BMOV AL,[0175]A0,01,75
018ECMP AL,013C,01
0190JNZ ANTICK0F
0192INC BX43
0193MOV AL,[BX]8A,07
0195CMP AL,003C,00
0197JNZ NEXT75,03
0199SUB BX,08EB,08
019CNEXT: MOV DX,BX89,DA
019ENOP90
019FPOP BX5B
01A0RETC3
01A1ANTICK:DEC BX4B
01A2MOV AL,[BX]8A,07
01A4CMP AL,00BC,00
01A6JNZ NEXT75,FH
01A8ADD BX,0883,C3,08
01ABJMP NEXTEB,FF
01BFDUM: DB 0000
01C0CODE:DB 00H 02H 06H 04H 0CH 00,02,06,04,0C
01C5DB08H 09H 01H 03H 00H08,09,01,03,00
RESULT : Thus the interface was successfully executed and the output has been verified
4.(C)1. ADC INTERFACE
AIM: To interface an ADC to 8086
Apparatus: 8086 trainer kitADC kit
PROCEDURE:
Step1: Start the processStep2: Connect 8086 with ADC connectionStep3: Give the required opcode for the programme in the memory address 1000Step4: Give the input voltage and press reset key in the convertersStep5: compile the ProgrammeStep6: Execute the programme and view the result is the output memoryStep7: Stop the process
PROGRAMME:
MEMORYADDRESSLABELMNEMONICOPCODECOMMENTS
1000MOV AL,03B0,03
1002OUT C8,ALE6,C8
1004MOV AL,23B0,23
1006OUT C8,ALE6,C8
1008MOV AL,03B0,03
100AOUT C8,ALE6,C8
100CMOV AL,01B0,01
100EOUT 00,ALE6,00
1010MOV AL,00B0,00
1012OUT D0,ALE6,00
1014IN AL,E6E4,E6
1016AND AL,013C,01
1018CMP AL,013C,01
101AJNZ LOOP75,F8
101CIN AL,C0E4,C0
101EMOV BX,1100BB,00,11
1021MOV [BX],AL88,07,F4
1023INTCD,A5
RESULT: Thus the above program has been successfully executed and the output is verified.
4(C) 2.DAC INTERFACE(TRIANGULAR WAVEFORM)
AIM: To Perform DAC using 8086 and verify the output waveform
Apparatus: 8086 trainer kitDAC kit
PROCEDURE:Step1: Start the processStep2: Connect 8086 with DAC connectionStep3: Give the required opcode for the programme in the memory address 1000Step4: Give the input voltage and press reset key in the convertersStep5: compile the ProgrammeStep6: Execute the programme and view the result is the output memoryStep7: Stop the process
Program:MEMORYADDRESSLABELMNEMONICOPCODECOMMENTS
1000L1MOV BL,0DB3,0D
1002MOV AL,BL88,DB
1004OUT DAC ALE6,C0
1006INC BLFE,C3
1008JNZ L175,FA
100AL2MOV AL,BL88,DB
100COUT DAC,ALE6,C0
100EDEC BLFE,CB
1010JNZ L275,F8
1012JMP STARTEB,FA
RESULT: Thus the above program has been successfully executed and the output is verified.4(C) 3.DAC INTERFACE(SAWTOOTH WAVEFORM)
AIM: To Perform DAC using 8086 and verify the output waveform
Apparatus: 8086 trainer kitDAC kit
PROCEDURE:Step1: Start the processStep2: Connect 8086 with DAC connectionStep3: Give the required opcode for the programme in the memory address 1000Step4: Give the input voltage and press reset key in the convertersStep5: compile the ProgrammeStep6: Execute the programme and view the result is the output memoryStep7: Stop the process
Program:MEMORY ADDRESSLABELMNEMONICOPCODECOMMENTS
1000L1MOV AL,00B0,00
1002OUT DAC ALE6,C0
1004INC ALFE,C0
1006JNZ L175,FA
1008JMP STARTEB,F6
RESULT: Thus the above program has been successfully executed and the output is verified.
4.(D) WAVEFORM GENERATION USING 8253 TIMERS
AIM: To implement programme for Waveform Generation using 8253 Timer.
Apparatus :8086 trainer kit8253 counterPower supply
Procedure:Step 1: Start the programStep 2: Connect the 8086 trainer kit and generate the waveformStep 3: Enter OPCODE in the memory address 0100Step 4: Memory segment for this 12 DCStep 5: Compile the programStep 6: Check out the add and even counterStep 7: Stop the program
THEORY: The programmable timer device 8253 contains 3 independent 16 bit counters, each with a maximum count rate of 2.6mhz
It is thus possible to generate three totally independent delays or maximum three independent counters simultaneously all the 3 counters may be independently controlled by programming the 3 word registersPROGRAM:
MEMORYADDRESSLABELMNEMONICOPCODECOMMENTS
0100STARTEB,01,90
0103MOV AX,10FFB8,FF,10
0106MOV SP,AX8B,E0
0108PUSH CS0E
0109POP DS1F
010ANOP90
010BNOP90
010CNOP90
010DMOV AL,96B0,96
010FMOV DX,01E6BA,E6,01
0112OUT DX,ALEE
0113MOV AL,08B0,08
0115MOV DX,01E4BA,E4,01
0118OUT DX,ALEF
0119MOV DX,01E6BA,E6,01
011CIN AL,DXEC
011DIN AL,DXEC
011EUP: MOV DX,01E4BA,E4,01
0121IN AL,DXEC
0122JMP UPEB,FA
OUTPUT: ODD COUNT
STEPSDATAOUT2OUT1OUT0A1A0RDWRCS
STEP196--------------11-----LL
STEP2051---------10----LL
STEP3FF1---------11L---L
STEP4FF1--------11L---L
STEP5051--------10L---L
STEP6041--------10L---L
STEP7021--------10L---L
STEP8050--------10L---L
STEP9020--------10L---L
STEP10051--------10L---L
CONNECTIONS: Make a connection to pin D to out2, then make a connection from clk/src to clk2
Memory segment -------- 12DCMemory segment -------- 0100
FOR EVEN COUNT:
STEPSDATA BUSOUT2OUT1OUT0A1A0WRRDCS
START96---------11L---L
STEP1081------10L---L
STEP2FF1------11---LL
STEP3FF1------11---LL
STEP4081------10---LL
STEP5061------10---LL
RESULT: Thus the above program has been successfully executed and the output is verified.
4.(E) DC MOTOR SPEED CONTROLLER
AIM: To Implement the program for DC motor speed controller using 8253
Apparatus:1.8086 trainer kit2. DC motor
PROCEDURE:
Step1: Start the programStep2: Connect the kit to the system.The kit connects one separate keyboardStep3: After connecting the kit ,in kit press R then enter,it shows the kit name in monitorStep4: Press I write then E038 start & ending address givenStep5: Then menu has transfer->send dataStep6: See the output in kit through the monitorStep7: Stop the program
PROGRAMME:
MEMORYADDRESSLABELMNEMONICOPCODECOMMENTS
0100STRT:JMP SKIP-DATAEB,01,90
SKIP-DATA:MOV AX,11FFEB,11,FF
STRT1:MOV SP,AX3B,E0
PUSH CSBE
POP DS1F
NOP90
NOP90
NOP90
MOV AL,80B0,80
MOV DX,8006BA,80,06
OUT DX,ALEE
START:INT 0ACCD,AC
MOV BX,OFFSET DIRBB,01,C9,R
INT 0AFCD,AF
MOV AH,08B4,08
INT 0A1CD,A1
MOV BL,AL8A,D8
MOV CL,46B1,46
CMP AL,CL3A,C1
JNE RVD75,0A
MOV AL,01B0,01
MOV DI,OFFSET DIRFRBF,02,30,R
MOV [DI[,AL88,05
JMP DISPLAYEB,1C,90
RVD:MOV AL,BL8A,C3
MOV CL,52B1,52
CMP AL,CL3A,C1
JE L174,0C
CMP AL,1B3C,1B
JNE START75,D7
MOV AL,80B0,80
MOV DX,8006BA,80,06
OUT DX,ALEF
INT 0A3CD,A3
L1:MOV AL,02B0,02
MOV DI,OFFSET DIRFRBF,02,30,R
MOV [DI],AL88,05
DISPLAY: INT 0ACCD,AC
MOV BX,OFFSET SPEEDBB,01,D1,R
INT 0AFCD,AF
MOV AL,02B0,02
MOV AH,0AB4,0A
INT 0ADCD,AD
AND AX,400025,40,00
CMP AX,40003D,40,00
JNE DISPLAY75,EB
PUSH DX52
MOV AL,DL8A,C2
MOV CL,50B1,50
CMP AL,CL3A,C1
JC INVERT72,11
MOV DI,OFFSET DIRFRBF,02,30,R
MOV BX,[DI]8B,1D
OR BL,0880,CB,08
MOV AL,BL8A,C3
MOV DX,8004BA,80,04
OUT DX,ALEE
JMP WAVEE8,0C,90
INVERT:MOV DI,OFFSET DIRFRBF,02,30,R
MOV BX,[DI]8B,1D
MOV AL,BL8A,C3
MOV DX,8004BA,80,04
OUT DX,ALEE
WAVE:MOV AL,36B0,3
MOV DX,8C07BA,8C,07
OUT DX,ALEE
POP DX5A
MOV AL,00B0,00
CMP AL,DL3A,C2
JNE 0D275,05
MOV AL,90B0,90
JMP MOD1EB,03,90
MOD2:MOV AL,94B0,94
MOD1:PUSH DX52
MOV DX,8C07BA,8C,07
OUT DX,ALEE
MOV BX,OFFSET TABLEBB,01,D8,R
POP DX5A
BACK:MOV AL,CS[BX]2E,8A,07
CMP AL,DL3A,C2
JC NEXT72,08
JZ NEXT74,06
INC BX43
INC BX43
INC BX43
INC BX43
JMP BACKEB,F1
NEXT:INC BX43
MOV AL,CS[BX]2E,8A,07
MOV DX,8C01BA,8C,01
OUT DX,ALEE
INC BX43
MOV AL,CS[BX]2E,8A,07
OUT DX,ALEE
INC BX43
MOV AL.CS[BX]2E,8A,07
MOV DX,8C05BA,8C,05
OUT DX,ALEE
JMP STARTE9,01,13,R
DIR: DB 44H,49H,52H,20H,46H,2FH,52H,03H44H,49H,52H,20H,46H,2FH,52H,03H
SPEED:DB 53H,50H,45H,45H,44H,20H,03H53H,50H,45H,45H,44H,20H,03H
TABLE:DB 98H,9BH,00H,30H,96H98H,9BH,00H,30H,96H
DB 0FAH,00H,1CH,94H,77H,01H0FAH,00H,1CH,94H,77H,01H
DB:13H,92H,0F4H,01H,0EH,89H,80H,02H,0BH13H,92H,0F4H,01H,0EH,89H,80H,02H,0BH
DB 86H,0E8H,03H,07H,83H,65H,04H,06H,80H86H,0E8H,03H,07H,83H,65H,04H,06H,80H
DB 0E2H,04H,05H,75H,0D0H,06H,04H,66H,0D0H0E2H,04H,05H,75H,0D0H,06H,04H,66H,0D0H
DB 08H,03H,50H,0B8H,0BH,02H,34H,0D0H,08H,03H08H,03H,50H,0B8H,0BH,02H,34H,0D0H,08H,03H
DB 25H,0D0H,06H,04H,20H,0E2H,04H,05H,17H,65H,04H25H,0D0H,06H,04H,20H,0E2H,04H,05H,17H,65H,04H
DB 06H,14H,0E8H,03H,07H,11H,80H,02H,0BH,08H06H,14H,0E8H,03H,07H,11H,80H,02H,0BH,08H
DB 0F4H,01H,0EH,06H,77H,01H,13H,04H,0FAH,00H,1CH0F4H,01H,0EH,06H,77H,01H,13H,04H,0FAH,00H,1CH
DB 02H,9BH,00H,30H,00H,9BH,00H,50H02H,9BH,00H,30H,00H,9BH,00H,50H
RESULT : Thus the interface was successfully executed and the output has been verified
4.(F) KEYBOARD DISPLAY INTERFACE
AIM: To perform the program for keyboard display interfaces and drives the output
Apparatus required:1.8086 microprocessor trainer kit2.8279 keyboard display interface
Procedure:Step1: Connect the microprocessor 8086 trainer kit with SMPSStep2: First reset and press S (substitute) to type the starting address Step3: Then type the opcode and press ESCStep4: Then press S followed by the loading addressStep5: Then press enter and get the input dataStep6: Then press ESC and then GO and execute restore and finally SubstituteStep7: Store it in the output address and get the output data
Theory: 1. The INTEL 8279 is a general purpose keyboard/display controller that simultaneously drives the display of a system and interfaces a keyboard with the CPU leaving it free for its routine task2. The keyboard display interface scans the keyboard to identify if any key has been pressed and serves the code of the pressed key to the CPU3. It also transmits the data received from the CPU to the display device. Both of these functions are performed by the controller bin respective fashion without involving the CPU4. The keyboard is interfaced either in the interrupt or parallel mode. In Interrupt mode the processor is requested service only if any key is pressed, otherwise the CPU periodically reads an internal flag of 8279 to check for a key press
Procedure:Step1: Connect the microprocessor 8086 trainer kit with SMPSStep2: First reset and press S (substitute) to type the starting address Step3: Then type the opcode and press ESCStep4: Then press S followed by the loading addressStep5: Then press enter and get the input dataStep6: Then press ESC and then GO and execute restore and finally SubstituteStep7: Store it in the output address and get the output data
PROGRAMME:
MEMORYADDRESSLABELMNEMONICSOPCODECOMMENTS
0100STARTEB,01,90
0103MOV AX,10FFB8,10,FF
0106MOV SP,AX8B,E0
0108PUSH CS0E
0109POP AX58
010AMOV DS,AX8E,D8
010CNOP90
010DNOP90
010ENOP90
010FSTART:
010FMOV AL,18HB0,18
0111MOV DX,01E2HBA,01,E2
0114OUT DX,ALEE
0115MOV AL,DFB0,DF
0117OUT DX,ALEE
0118MOV AL,8FB0,8F
011AOUT DX,ALEE
011BMOV CL,0FB1,0F
011DCALL DISPLAYE8,02,00
SUBPROGRAMME:
0120JMP STARTEB,ED
0122DISPLAY PROC NEARFB,ED
0122MOV BX,OFFSET DATABB,01,31 R
0125NEXT
0125MOV AL,[BX]8A,07
0127MOV DX,01E0BA,O1,E0
012AOUT DX,ALEE
012BINC BX43
012CDEC CLFE,C9
012EJNS NEXT79,F5
0130RETC3
0131DISPLAY ENDPDATA:DB 0C0,0F9,0A4,0B0,99,92,82,0F8,80,900C0,0F9,0A4,0B0,99,92,82,0F8,80,90
013BDB 88,83,0C6,0A1,86,8E88,83,0C6,0A1,86,8E
OUTPUT:
STEPDATA BUSDISPLAYWRRDCSA0INT
START18------L---L1---
STEP 1DF------L---L1---
STEP 28FBLOCKL---L1---
STEP 3C0BLOCKL---L------
STEP 4F90L---L------
STEP 5A41L---L------
STEP 6B02---------------
STEP 7993L---L------
STEP 8924L---L------
STEP 9825L---L------
STEP 10E26L---L------
STEP 11807L---L------
STEP 12908L---L------
STEP 13880L---L------
STEP 1483AL---L------
STEP 15C6BL---L------
STEP 16A1CL---L------
STEP 1786DL---L------
STEP 188EEL---L------
STEP 1918FL---L------
RESULT : The keyboard interface was successfully executed and the output has been verified
EXP.NO: 7 DATE:(a)Interfacing Programmable Keyboard and Display Controller- 8279 ( With 8086)AIM: To display the rolling message in the display.
APPARATUS REQUIRED:
(i)8086 Microprocessor kit (ii)Power supply (iii) interfacing board.
ALGORITHM: ( Display of rolling message HELP US)
1. Initialize the counter2. Set 8279 for 8 digit character display, right entry3. Set 8279 for clearing the display4. Write the command to display5. Load the character into accumulator and display it6. Introduce the delay7. Repeat from step 1.
INTERFACE - BLOCK DIAGRAM:
K/DISPLAY 8279INTERFACE BOARDMICROPROCESSORKIT 8086
CABLE
ROLLING DISPLAY (DISPLAY MESSAGE IS ECE- b) USINGH 8051ADDRESSLABELMNEMONICSOP-CODECOMMANDS
4000MOV DPTR,#FFC290 FF C2
4003MOV R0,#0078 00
4005MOV R1,#4479 44
4007MOV A,#1074 10
4009MOVX@DPTR,AF0
400AMOV A,#CC74 CC
400CMOVX@DPTR,AF0
400DMOV A,#9074 90
401FMOVX@DPTR,AF0
4010LOOPMOV DPH,R189 83
4012MOV DPL,R088 82
4014MOVX@DPTRE0
4015MOV DPTR,FFC090 FF C0
4018MOVX@DPTR,AF0
4019LCALL DELAY12 45 00
401CINC R008
401DCJNE R0,#0F,LOOPB8 0F F0
401ALJMP START02 81 00
ORG 4500ADDRESSLABELMNEMONICSOP-CODECOMMANDS
4500MOV R4,#A07C A04500
4502LOOP2MOV R5,#FF7D FF4502
4504LOOP1NOP004504
4505DJNZ R5,LOOP1DD FD4505
4507DJNZ R4,LOOP2DC F94507
4509RET224509
LOOK-UP TABLEADDRESSDATA
4400FF,FF,FF,FF
4404FF,FF,FF,FF
440868,6C,68,FF
440CFF,38,FF,FF
The above program initializes 8279 in scanned keyboard 2 key lock-out. Press two keys simultaneously and verify that only one key is accepted by 8279
RESULT: Thus the rolling message is displayed using 8279 interface kit.
EXP. NO: 8 DATE:
SERIAL COMMUNICATION INTERFACING USART 8251
AIM: To study interfacing technique of 8251 (USART) with microprocessor 8086 and write an 8086 ALP to transmit and receive data between two serial ports with RS-232 cable.
APPARATUS REQUIRED:(i)8086 kit with keyboard (2 Nos),(ii) RS232 cable.
THEORY:
The 8251 is used as a peripheral device for serial communication and isprogrammed by the CPU to operate using virtually any serial data transmission technique.The USART accepts data characters from the CPU in parallel format and then converts theminto a continuous serial data stream for transmission. Simultaneously, it can receive serialdata streams and convert them into parallel data characters for the CPU. The CPU canreadthe status of the USART at any time. These include data transmission errors and controlsignals. The control signals define the complete functional definition of the 8251. Controlwords should be written into the control register of 8251.
These control words are split intotwo formats: 1) Mode instruction word &2) Command instruction word. Status word formats used to examine the error during functional operation.
Command instruction:
TRANSMITTER PROGRAMADDRESSMNEMONICSOP-CODECOMMANDS
1000MOV AL,36BO 36MOVE THE VALUE TOACCUMULATOR
1002OUT CE,ALE6 CESEND DATA TO OUTPUT PORT
1004MOV AL,10B0 10MOVE THE VALUE TOACCUMULATOR
1006OUT C8,ALE6 C8SEND DATA TO OUTPUT PORT
1008MOV AL,00B0 00MOVE THE VALUE TOACCUMULATOR
100AOUT C8,ALE6 C8 SEND DATA TO OUTPUT PORT
100CMOV AL,4EB0 4EMOVE THE VALUE TOACCUMULATOR
100EOUT C2,ALE6 C2SEND DATA TO OUTPUT PORT
1010MOV AL,37B0 37MOVE THE VALUE TOACCUMULATOR
1012OUT C2,ALE6 C2SEND DATA TO OUTPUT PORT
1014MOV AL,AABO AAMOVE THE VALUE TOACCUMULATOR
1016OUT CO,ALE6 COSEND DATA TO OUTPUT PORT
1018INT 02CD 02INTERUPT
RECEIVER PROGRAMADDRESSMNEMONICSOP-CODECOMMANDS
1200IN AL,C0E4 C0INTERUPT
1202MOV BX[1250]BB 50 12MOVE THE VALUE TO ADDRESS
1205MOV BX,AL88 07MOVE ACCUMULATORDATA TO BX
1207INT 02CD 02INTERUPT
RESULT:Thus ALP for serial data communication using USART 8251 is written and the equivalent ASCII 41 for character A is been tx&rx ed
EXP.NO:9 DATE: (a) STEPPER MOTOR INTERFACING
AIM: To write an assembly language program in 8086 to rotate the motor at different speeds in clock wise and anti-clock directions .
APPARATUS REQUIRED:1. Microprocessor kit 8086 -1No2. Power Supply +5 V, dc,+12 V dc-1No 3. Stepper Motor Interface board- 1No 4. Stepper Motor - 1No
PROBLEM STATEMENT:
Write a code for achieving a specific angle of rotation in a given time and particular number of rotations in a specific time.
THEORY:A motor in which the rotor is able to assume only discrete stationary angular position is a stepper motor. The rotary motion occurs in a stepwise manner from one equilibrium position to the next. Two-phase scheme: Any two adjacent stator windings are energized. There are two magnetic fields active in quadrature and none of the rotor pole faces can be in direct alignment with the stator poles. A partial but symmetric alignment of the rotor poles is of course possible.
ALGORITHM:For running stepper motor clockwise and anticlockwise directions(i) Get the first data from the lookup table.(ii) Initialize the counter and move data into accumulator.(iii) Drive the stepper motor circuitry and introduce delay(iv) Decrement the counter is not zero repeat from step(iii)(v) Repeat the above procedure both for backward and forward directions.
SWITCHING SEQUENCE OF STEPPER MOTOR:MEMORY LOCATION A1 A2 B1 B2 HEX CODE4500 1 0 0 0 09 H4501 0 1 0 105 H4502 0 1 1 0 06 H4503 1 0 1 0 0A H
INTERFACE - BLOCK DIAGRAM:
STEPPER MOTOR INTERFACE BOARDMICROPROCESSORKIT 8086
CABLE
PROGRAM:
A-TO RUN STEPPER MOTOR AT DIFFERENT SPEED
MEMORY ADDRESSLABELMNEMONICSOPCODECOMMENTS
1000STARTMOV D1 offset table (1014)BF,14,10
1003MOV CL, 04
B1,04
1005LOOP1MOV AL,[D1]
8A,05
1007OUT PORT1,AL
E6,C0
1009MOV DX,1010
BA,10,10
100CDELAYDEC DX
4A
100DJNZ DELAY
75,FD
100FINC D1
47
1010LOOP LOOP1
E2,F3
1012JMP START
EB,EC
1014TABLEDB
09,05,06,0A
note: for anti-clock direction only change the order of the input data.
RESULT: Thus the assembly language program for rotating stepper motor in Clockwise and anti-clock directions were written and verified.(b)INTERFACING AND PROGRAMMING OF DC MOTOR SPEED CONTROL
AIM: To interface and control the speed of a DC motor using 8253 and 8086 microprocessor kit.
APPARATUS REQUIRED:ApparatusSpecification/modelQuantity
Microcontrolle