Mpmc

6,142
-1

Published on

about microcontroller and microprocessor

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,142
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
228
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Mpmc

  1. 1. ELECTRONICS & COMMUNICATION ENGINEERING 1. Introduction to MASMIntroduction:The aim of this experiment is to introduce the student to assembly languageprogramming and the use of the tools that he will need throughout the labexperiments. This first experiment let the student use the Dos Debugger and theMicrosoft Macro Assembler (MASM). Editing, Assembling, Linking, Execute up canbe done using MASM softwareObjectives: 1. Introduction to Microsoft Macro Assembler (MASM) 2. General structure of an assembly language program 3. Use of the Dos Debugger programOverview:In general, programming of microprocessor usually takes several iterations beforethe right sequence of machine code instruction is written. The process, however isfacilitated using a special program called an “Assembler”. The Assembler allows theuser to write alphanumeric instructions. The Assembler, in turn, generates thedesired machine instructions from the assembly language instructions.Assembly language programming consists of following steps: STEP PRODUCES 1 Editing Source file 2 Assembling Object file 3 Linking Executable file 4 Executing Results Table1.1: Assembly Language Programming PhasesMICROPROCESSORS LAB 1
  2. 2. ELECTRONICS & COMMUNICATION ENGINEERINGAssembling the program:The assembler is used to convert the assembly language instructions to machinecode. It is used immediately after writing the Assembly language program. Theassembler starts by checking the syntax or validity of the structure of each instructionin the source file .if any errors are found, the assemblers displays a report on theseerrors along with brief explanation of their nature. HoweverIf the program does contain any errors ,the assembler produces an object file thathas the same name as the original file but with the “obj” extensionLinking the program:The Linker is used convert the object file to an executable file. The executable file isthe final set of machine code instructions that can directly be executed by themicroprocessor. It is the different than the object file in the sense that it is self-contained and re-locatable. An object file may represent one segment of a longprogram. This segment can not operate by itself, and must be integrated with otherobject files representing the rest of the program ,in order to produce the final self-contained executable fileIn addition to the executable file, the linker can also generate a special file called the“map”file.this file contains information about the start, end, length of the stack, code,and data segments. it also lists the entry point of the programExecuting the programThe executable contains the machine language code .it can be loaded in the RAMand executed by the microprocessor simply by typing ,from the DOS prompt ,thename of the file followed by the carriage Return Key (Enter Key). If the programproduces an output on the screen or sequence of control signals to control a piece ofhard ware, the effect should be noticed almost immediately.However,if the programmanipulates data in memory, nothing would seem to have happened as a result ofexecuting the program.MICROPROCESSORS LAB 2
  3. 3. ELECTRONICS & COMMUNICATION ENGINEERINGDebugging the programThe 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 results afterexecution. Logical errors may be found by tracing the action of the program. oncefound, the source file should be rewrite to fix the problem, then the re-assembled andre-linked. A special program called the 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. It also allows the user to inspect or change the contents of the microprocessorinternal registers or the contents of any memory location.The DOS –Debugger:The DOS “Debug” program is an example of simple debugger that comes with MS-DOS.Hence, it is available on any PC .it was initially designed to give the user thecapability to trace logical errors in executable file. It allows the user to take anexisting executable file and unassembled it,i.e convert it to assemblylanguage.Also,it allows the user to write assembly language instructions directly,and then convert them to machine language. The program is simple and easy touse. But offers limited capabilities, which make it unsuitable for serious assemblylanguage programming.Below, are summarized the basic DOS – Debugger commands COMMAND SYNTAX Assemble A [address] Compare C range address Dump D [range] Enter E address[list] Fill F range list Go G [=address] [addresses]MICROPROCESSORS LAB 3
  4. 4. ELECTRONICS & COMMUNICATION ENGINEERING Hex H value1 value2 Input I port Load L[address] [drive][first sector][number] Move M range address Name N[pathname][argument list] Output O port byte Proceed P[=address][number] Quit Q Register R[register] Search S range list Trace T[=address][value] Unassembler u[range] Write W[address}[drive][first sector][number]MS-MASM:Microsoft’s Macro Assembler (MASM) is an integrated software package written byMicrosoft Corporation for professional software developers. it consists of an editor,an assembler, a linker and a debugger(Code View). The programmer’s workbenchcombines these four parts into a user-friendly programming environment with built inon line help.The following are the steps used if you are to run MASM from DOS COMMAND FILE NAME 1 Edit, any editor will do Name.asm 2 Masm Filename Name.obj 3 Filename Table1.3: Assembly language programming phasesMICROPROCESSORS LAB 4
  5. 5. ELECTRONICS & COMMUNICATION ENGINEERINGProcedure to enter a program using MASM software Start ↓ Run ↓ Type CMD ↓ Ok Display shows ↓ C :> D: (Change to D drive because MASM is in D drive) ↓ Press ENTER ↓ D :> CD MASM ↓ Press ENTER ↓ D: MASM> DEBUG ↓ Press ENTER ↓ __? [Help] ↓ Press ENTER ↓ Then the display shows the main menu. ↓ Press ‘A’ and starting address of your program Ex: A 1000 ↓ Press ENTERMICROPROCESSORS LAB 5
  6. 6. ELECTRONICS & COMMUNICATION ENGINEERING ↓ Then the display shows 0B19: 1000__ ↓ Type your instructions Ex: Mov al, 20 ↓ Press ENTER then the display next address i.e. 0B19:1002__ ↓ Then type next instruction Ex: Mov bl, 30 ↓ After typing of every instruction press ENTER ↓ After typing of last instruction i.e. HLT then press ENTER and again press ENTER ↓ Display shows (__) blinking cursor______________________________________________________________________Procedure to enter the data into memory location. Sample program Mov al, [2000] Mov bl, [3000] Add al, bl Mov [4000], al HLTFor the above sample program we have to enter the data into memory locations. For that the procedure is given belowStep1: Type the sample program by using the above procedure.Step2: Then type ‘e’ 2000 (← address of the memory location)Step3: Then press ENTERMICROPROCESSORS LAB 6
  7. 7. ELECTRONICS & COMMUNICATION ENGINEERINGStep4: Display shows 0b19:2000 20 ← ( previous data in 2000 memory location)Step5: Type new data in that particular memory location. If you want to continue that memory location (i.e.2001, 2002------) then presses SPACE BAR KEY.Step6: If you want to exit from that memory location after typing the data then press ENTER.Step7: Then the display shows __Step8: Uses the same procedure for enter the data into 3000 memory location.Procedure to execute the program & to see the results a) register b) memory locations.Step1: After entered the data into memory locations by using the above procedure __ then the display shows __ ( blinking cursor)Step2: Type G=Starting address Ending address (Ex:G =1000 1020 ,starting address:1000 & ending address :1020)Step3: Then press ENTER.Step4: Then the display shows the REGISTERS with RESULTS.Step5: To see the results in memory locations press D 4000 (4000 is the address of the memory location where the result is stored. D is the command for displaying the data in memory locations)Step6: Then press ENTER.Step7: Then the display shows the data in 4000 location.MICROPROCESSORS LAB 7
  8. 8. ELECTRONICS & COMMUNICATION ENGINEERINGProcedure to edit the program.Step1: Press A 1007 ( 1007 is the address where you want to change the instruction)Step2: Then press ENTER.Step3: Then the display shows 0B19:1007 __Step4: Type the instruction which you want to change.Step5: Then press ENTER.Procedure to un assemble the program .Step1: Press U starting address ending address (U is the command to unassemble the program with Opcodes)Step2: Then press ENTER.Step3: Then the display shows the program with opcodes. 0B19: 1000 A00010 Mov al, [2000] ↓ ↓ ↓ ↓ (Starting address) (Opcode) (Mnemonic) (Operand)MICROPROCESSORS LAB 8
  9. 9. ELECTRONICS & COMMUNICATION ENGINEERING 2. Arithmetic Operation: Additiona) Aim: Write an ALP to add ‘n’ 8-bit numbers and store the result in any of the memory location.b) Appartus/Software: 1.8086 microprocessor kit/MASM-- 1 2.RPS(+5V). --1c) Algorithm:Step1: load CL with 03Step2 : Initialize the source IndexStep3: Initialize the AL with ‘00’Step4: Add the contents of the AL with the contents of the SI and the result is stored in ALStep5: Increment SIStep6: Decrement the content in CLStep7: If CL is not equal to zero, go to step4Step8: Store the contents of the Al into any memory location.Step9: Stopd) Assembly Language Program before execution:Label Mnemonic operand Comments MOV CL,03 Load CLl with 03; count initialized MOV SI,2000 initialize source index at 2000;memory pointer MOV AL,00 load AL with 00UP ADD AL,[SI] add content of SI with AL INC SI increment SI next memory location. DEC CL decrement count JNZ UP if it is non zero jump up MOV [3000],AL move the content of AL to 3000memory location HALT End of the programMICROPROCESSORS LAB 9
  10. 10. ELECTRONICS & COMMUNICATION ENGINEERINGe) Expected results:Input: 10h Output: 60H 20h 30hf)Assembly Language Program after execution: Address Opcode Mnemonic Operand 1000 B1,03 MOV CL,03 1002 BE,00,20 MOV SI,2000 1005 B0,00 MOV AL,00 1007 02,04 ADD AL,[SI] 1009 46 INC SI 100A FE,C9 DEC CL 100C 75,F9 JNZ UP 100E A2,00,30 MOV [3000],AL 1011 F4 HLTg) Results:Input : output:Address data Address data2000: 10h 3000: 60H2001: 20h2002: 30h CL : 03h AL: 00hh) Viva–Voce: i) Write instructions which perform addition operation in direct addressing, indirect addressing? A: Direct addressing mode : ADD AL,[2000], Indirect Addressing mode : ADD AL,[BX] ii) What are the flags effected after executing ADD instruction? A: All Flags effected (S,Z,A,P,C flags)MICROPROCESSORS LAB 10
  11. 11. ELECTRONICS & COMMUNICATION ENGINEERING 2. Arithmetic Operation: Multibyte additiona) Aim: Write an ALP to add two 32 bit operands which are in memory and store the data & result in the memory including carry. Use base + index addressing mode to read and store data in memory.b) Apparatus/Software:1. 8086 microprocessor kit/MASM ---1 2.RPS+5V). -- 1c) Algorithm:Step1: Load BX with 1230Step2: Load SI with Specific offset valueStep3: Add the contents of BX with SI load the content of memory location whoseaddress is Specified by sum of BX and SI and displacement into DXStep4: Add the contents of BX, SI with Displacement and load the content in DXStep5: Repeat Step4Step6: Add the contents of BX, SI with Displacement and load the content in DX Also carryStep7: Initialize CX registerStep8: Add with carryStep9: Load BX with 1440Step10: the contents of Ax loaded with memory location whose address is specifiedby sum of BX and SIStep11: the contents of DX loaded with memory location whose address is specifiedby sum of BX and SI with Displacement and load the content in DXStep12: Add the contents of BX, SI with Displacement and load the content in DXStep13: StopMICROPROCESSORS LAB 11
  12. 12. ELECTRONICS & COMMUNICATION ENGINEERINGd) Assembly language program before execution: Mnemonic Operand Comments MOV BX,1230 Load BX with 1230 MOV SI,0002 Load SI with Offset value MOV AX,[BX+SI] Add the contents of BX with SI load the content of memory location whose address is specified by sum of BX and SI and displacement into DX MOV DX,[BX+SI+02] Load the content of memory location whose address is specified by BX and SI and displacement into DX ADD AX,[BX+SI+04] add the contents of BX ,SI with Displacement and load the content in DX ADC DX,[BX+SI+06] add the contents of BX ,SI with Displacement and load the content in DX Also carry MOV CX,0000 Initialize CX register ADC CH,CL Add with carry MOV BX,1440 Load BX with 1440 MOV [BX+SI],AX Add the contents of BX with SI load the content in AX MOV [BX+SI+02],DX add the contents of BX ,SI with Displacement and load the content in DX MOV [BX+SI+04],CH add the contents of BX ,SI with Displacement and load the content in DX HLT End of the programe) Expected results:Input: 12 32 12 32: 1st number 23 21 23 21: 2nd numberOutput : 35 53 35 53 hMICROPROCESSORS LAB 12
  13. 13. ELECTRONICS & COMMUNICATION ENGINEERINGf) Assembly language program after execution: Address Opcode mnemonic operands 1000 BB,30,12 MOV BX,1230 1003 BE,02,00 MOV SI,0002 1006 8B,00 MOV AX,[BX+SI] 1008 8B,50,02 MOV DX,[BX+SI+02] 100B 34,004 ADD AX,[BX+SI+04] 100E 13,50,06 ADC DX,[BX+SI+06] 1011 B9,00,00 MOV CX,0000 1014 10,CD ADC CH,CL 1016 BB,40,14 MOV BX,1440 1019 89,00 MOV [BX+SI],AX 101B 89,50,02 MOV [BX+SI+02],DX 101E 88,68,04 MOV [BX+SI+04],CH 1021 F4 HLTg) Results:Input: OutputAddress Data Address Data1232: 32 1442: 531233 12 1443: 351234: 34 1444: 531235: 12 1445: 351236: 21 1446: 001237: 231238: 211239: 23h) Viva–Voice: i)What is the difference between ADD&ADC instruction? A: ADD instruction adds two opernds,ADC instruction adds two operads and the carry iii) What are the flags effected after executing MOV BX, 1230 instruction? A : No flags are effectedMICROPROCESSORS LAB 13
  14. 14. ELECTRONICS & COMMUNICATION ENGINEERING 2. Arithmetic Operation: Subtractiona) Aim: Write an ALP in 8086 to perform the subtraction of two numbers.b) Apparatus/Software:1. 8086 microprocessor kit/MASM,--1 2. RPS (+5V). --2c) Algorithm:Step1: Initialize AL with the contents of the memory location say 2000.Step2: Initialize the BL with the contents of the memory location say 2001.Step3: Subtract the contents of the AL with the contents of the BL And the result is stored in AL.Step4: Result is stored in one more location say 3000.Step6: Stop.d) Assembly language program before execution: Mnemonic Operand comments Load AL with the contents of given memory MOV AL,[2000] location Load BL with the contents of given memory MOV BL,[2000] location Subtract the contents of AL with the contents SUB AL,BL of BL MOV [3000],AL Copy the AL contents to the 3000 location HLT End of the programe) Expected result:Input: 30 _ 20 _______________ 10 _______________MICROPROCESSORS LAB 14
  15. 15. ELECTRONICS & COMMUNICATION ENGINEERINGf) Assembly language program after execution: Address Opcode Mnemonic Operand 1000 A0,00,20 MOV AL,[2000] 1003 8A,1E,01,20 MOV BL,[2000] 1007 28,D8 SUB AL,BL 1009 S2,00,30 MOV [3000],AL 100C F4 HLTg) Results:Input: Output:Address Data Address Data2000: 302001: 20 3000: 10h) Viva -Voice: i ) What is the difference between SUB,SBB instruction? A: SUB instruction subtracts two operands,SBB instruction subtracts two operands along with the borrow/carry ii) What are the flags effected after execution of HLT instruction ? A: No flags are effectedMICROPROCESSORS LAB 15
  16. 16. ELECTRONICS & COMMUNICATION ENGINEERING 2. Arithmetic Operation: Multiplicationa) Aim: Write an assembly language program in 8086 to perform multiplication of given two numbers by using ADD and SHIFT method.b) Appartus/Software:1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1.c) Algorithm: Step1: Clear AX, DX Register. Step2: Initialise DL and BL register with some data. Step3: Load count register with 08, because number of bit’s in Multiplicand is equal to number of shifts. Step4: Rotate BL register by one time to right . Step5: If there is no carry skip addition and shift DL register by one time . To left and go to step4. Step6: If there is a carry then add AX register with DX and shift DL Register by one time left and repeat loop until count becomes zero Step7: Load result in AL. Step8: End of the program.MICROPROCESSORS LAB 16
  17. 17. ELECTRONICS & COMMUNICATION ENGINEERINGd) Assembly language program before execution: Label Mnemonics Comments XOR AX,AX Reset AX Register. XOR DX,DX Reset DX Register. MOV Load Dl register with data whose address DL,[1050] 1050 MOV load BL register with data available at BL,[1051] memory location MOV CL,08 load CL register with 08h UP: ROR BL,01 rotate BL register data by one time if there is no carry skip addition and jump JNB DOWN down ADD AX,DX add ax with DX store data in AX DOWN: SHL DL,01 shift dl register to left by one time to the right DEC CL Decrement CL register JNZ UP If CL is not zero ,repeat loop MOV store result from Accumulator to memory [1052],AX location HLT end programe) Expected resultsNumbers are : 65h & 2A hOutput/Result: 2B20MICROPROCESSORS LAB 17
  18. 18. ELECTRONICS & COMMUNICATION ENGINEERINGf) Assembly language program after execution: Address Opcode Mnemonic Operand 1000 31,C0 XOR AX,AX 1002 31,D2 XOR DX,DX 1004 8A,16,50,10 MOV DL,[1050] 1008 8A,1E,51,10 MOV BL,[1051] 100C B1,08 MOV CL,08 100E B0,CB ROR BL,1 1010 73,02 JNB 1014 1012 01,D0 ADD AX,DX 1014 D1,E2 SHL DL,1 1016 FE,C9 DEC CL 1018 75,F4 JNZ 100E 101A A3,52,10 MOV [1052],AX 101D F4 HLTg) Results: Input OutputAddress data address data1050: 2A h 1052: 20h1051: 65h 1053: 2Bhh) Viva –Voce:i) what are the flags effected after execute up ADD AX,DX instruction (Assume:AX=FFFFh,DX=0001h)?A:Z=1,P=1,AC=1,CY =1,S=0, other flags are not effectedii)what is the difference between MOV DX,[1050],MOV DX,1050?A: MOV DX,[1050]; the contents of memory location whose address 1050 moved toDL register,1,1051 contents moved to DH register MOV DX,[1050];50h moved to DL register 10h moved to DH registerMICROPROCESSORS LAB 18
  19. 19. ELECTRONICS & COMMUNICATION ENGINEERING2. ArithmeticOperation:Multiplication(signed numbers)a) Aim: Write an Assembly Language Program to multiply two signed numbers and store the result in memory.b) Appartus/Software:1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1c) Algorithm:Step-1: Initialize the source address.Step-2: Load AL with the contents of the source index register.Step-3: Increment the pointer.Step-4: Load BL with the content of the source index register.Step-5: Signed multiplication is takes place.Step-6: Move the result from the accumulator to the memory location.Step-7: End. of the programd) Assembly language program before execution: Mnemonic Operand Comments Initialize SI at 2000 MOV SI,2000 memory location load CL register with data available at memory MOV AL,[SI] location SI Increment memory pointer INC SI SI load BL register with data available at memory MOV BL,[SI] location SI Perform signed IMUL BL multiplication copy the data from AX to MOV [3000],AX 3000 location HLT End programMICROPROCESSORS LAB 19
  20. 20. ELECTRONICS & COMMUNICATION ENGINEERINGe) Expected results:Input OutputData DataE4 h (Decimal no is-28) 03C6h (Decimal no is -1652)3Bh (Decimal no is +59)f) Assembly language program after execution: Address Opcode Mnemonics Operand 10000 BE,00,20 MOV SI,2000 1003 8A,04 MOV AL,[SI] 1005 46 INC SI 1006 8A,1C MOV BL,[SI] 1008 F6,EB IMUL BL 100A A3,00,30 MOV [3000],AX 100D F4 HLTg) Results:Input OutputAddress Data Address Data2000: E4 h (Decimal no is-28) 3000: C6h (Decimal no is - 1652)2001: 3Bh (Decimal no is +59) 3001: 03hh) Viva- Voce: 1. After multiplying the AL with BL the result is stored in : AX Register 2. After multiplying AX with BX the result is stored in : DX.AX RegistersMICROPROCESSORS LAB 20
  21. 21. ELECTRONICS & COMMUNICATION ENGINEERING 2. Arithmetic Operation: Division (signed numbers)a) Aim: write an Assembly Language Program to perform Division of the two signed numbers and store the result in memory location.b) Appartus/Software:1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1c) Algorithm: Step1: Initialize the DX with 0000 Step2: Initialize the source index. Step3: Load AX with the contents of the source Index register. Step4: Increment the pointer SI. Step5: Increment the pointer SI. Step6: Load BL with the contents of SI. Step7: Signed division is takes place. Step8: Move the resent from the AX and DX to the memory locations. Step9: End of the programd) Assembly language program before execution: Mnemonic Operands Comments MOV DX, 0000 Load DL with 00 MOV SI, 2000 Initialize SI at 2000 memory location load AX register with data available at MOV AX, [SI] memory location SI INC SI Increment SI INC SI Increment SI load BL register with data available at MOV BL, [SI] memory location SI IDIV BL Perform signed division operation MOV [3000], AX Copy data from AX to 3000 location Copy data from DX to 3002 MOV [3002], DX Location HLT End programMICROPROCESSORS LAB 21
  22. 22. ELECTRONICS & COMMUNICATION ENGINEERINGe) Expected results:Input Output:Data Data:00E4/02 00F2f) Assembly language program after execution: Adders Opcode Mnemonic Operand DX, 1000 BA,00,00 MOV 0000 1003 BE,00,20 MOV SI, 2000 1006 SB,04 MOV AX, [SI} 1008 46 INC SI 1009 46 INC SI 100A 8A,1C MOV BL, [SI] 100C F6Fb IDIV BL [3000], 100E A30030 MOV AX [3002], 1011 89160230 MOV DX 1015 F4 HLTg) Results:Input OutputAddress Data Address Data2000: E4 3000: F22001: 00 3001: 002002: 02h)Viva- Voce: 1. What is the result of DIV BX? A: Quotient stored at AX , Remainder stored at DX register 2. What is range of signed numbers for 8 bit microprocessor? A. + 127 to -127MICROPROCESSORS LAB 22
  23. 23. ELECTRONICS & COMMUNICATION ENGINEERING 2. Arithmetic Operation: ASCII additiona) Aim: Write an Assembly Language Program to perform the ASCII addition.b) Appartus/Software:1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1c) Algorithm:Step-1: Initialize the AH with 00Step-2: Initialize the source IndexStep-3: Load the contents of the AL with contents of the SIStep-4: Increment the SIStep-5: Load the contents of the SI ti the BLStep-6Add AL and BLStep-7: Move the result from the accumulator to the memory locationStep-8: End of the programd) Assembly language program before execution: Mnemonic Operand Comments MOV AH,00 Clear the AH register Load the SI with specified MOV SI,2000 address MOV AL,[SI] Copy to AL from SI INC SI Increment SI address MOV BL,[SI] Copy to BL from SI ADD AL,BL Add AL with BL Adjust accumulator after AAA addition Copy the contents AX to MOV [3000],AX given address HLT End of the programMICROPROCESSORS LAB 23
  24. 24. ELECTRONICS & COMMUNICATION ENGINEERINGe) Expected resultsInput OutputAddress Data Address Data2000: 05 3000: 042001: 09 3001: 01f) Assembly language program after execution: Address Opcode Mnemonic Operand 1000 B4,00 MOV AH,00 1002 BE,00,20 MOV SI,2000 1005 8A,04 MOV AL,[SI] 1007 46 INC SI 1008 8A,3B MOV BL,[SI] 100A F6,E6 ADD AL,BL 100B D4,01 AAA 100D A3,00,50 MOV [3000],AX 1010 F4 HLTg) Results:Input OutputAddress Data Address Data2000: 05 3000: 042001: 09 3001: 01h) Viva- Voice: 1. Difference between CMPS&SCAS instruction 2. Difference between AAA&DAA instructionMICROPROCESSORS LAB 24
  25. 25. ELECTRONICS & COMMUNICATION ENGINEERING 2. Arithmetic Operation: ASCII Multiplicationa) Aim: Write an Assembly Language Program to perform the ASCII multiplication.b) Appartus/Software:1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1c) Algorithm:Step-1: Initialize the AH with 00Step-2: Initialize the source IndexStep-3: Load the contents of the AL with contents of the SIStep-4: Increment the SIStep-5: Load the contents of the SI to the BHStep-6: Multiply the contents of the BH with AL and result is stored in AXStep-7OR the contents of AX with 3030Step-8: Move the result from the accumulator to the memory locationStep-9: End of the programd) Assembly language program before execution: Mnemonic Operand Comments MOV AH,00 Initialize AH Load Index Register with Starting MOV SI,2000 address of array MOV AL,[SI] Load AL With First Byte of data INC SI Increment SI by one MOV BH,[SI] Load BH with second byte MUL BH Multiply BH with AL Perform ASCII adjust after AAM multiplication operation OR AX,3030 Add AX with 3030 MOV [5000],AX Move the result into memory HLT End of the programMICROPROCESSORS LAB 25
  26. 26. ELECTRONICS & COMMUNICATION ENGINEERINGe) Expected results:Input Output09*05 3435f) Assembly language program after execution: Address Opcode Mnemonic Operand 1000 B4,00 MOV AH,00 1002 BE,00,20 MOV SI,2000 1005 8A,04 MOV AL,[SI] 1007 46 INC SI 1008 8A,3C MOV BH,[SI] 110A F6,E7 MUL BH 100C D4,0A AAM 100E 0D,30,30 OR AX,3030 1011 A3,00,50 MOV [5000],AX 1014 F4 HLTg) Results:Input OutputAddress Data Address Data2000: 09 5000: 352001: 05 5001: 34MICROPROCESSORS LAB 26
  27. 27. ELECTRONICS & COMMUNICATION ENGINEERING 3. Logical Operation: shift right operationa) Aim: Write an Assembly Language Program to shift the given 8 bit data to the right and store the result in the memory.b) Appartus/Software:1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1c) Algorithm:Step-1: Initialize the AH with 00Step-2: Initialize the source IndexStep-3: Load the contents of the AL with contents of the SIStep-4: Shift the contents of the accumulator to the to the right by 1Step-5:If there is barrow increment AHStep-6: Otherwise load the contents of the AL to the memory locationStep-7: End of the programd) Assembly language program before execution: Label Mnemonics Operand Comments MOV AH,00 Load AH with 00 Initialize SI at 3050 memory MOV SI,3050 location Copy data from SI memory MOV AL,[SI] location to AL SAR AL,01 Shift AL content to right by 1 time JNB DOWN If there is no carry jump down INC AH Increment AH Copy the data from AL to 4000 DOWN MOV [4000],AL location HLT End programMICROPROCESSORS LAB 27
  28. 28. ELECTRONICS & COMMUNICATION ENGINEERINGe) Expected results:Input OutputData Data27 93f) Assembly language program after execution: 3000 B4,00 MOV AH,00 3002 BE,50,30 MOV SI,3050 3005 8A,04 MOV AL,[SI] 3007 D0,F8 SAR AL,01 3009 73,02 JNB 300D 300B FE,C4 INC AH 300D A2,00,40 MOV [4000],AL 3010 F4 HLTg) Results:Input OutputAddress Data Address Data3050: 71 4000: 93h) Viva –Voce: 1. What are the flags updated after execution of INC AH instruction? A. All flags(Zero,Parity,AC,Sign) except carry flag.MICROPROCESSORS LAB 28
  29. 29. ELECTRONICS & COMMUNICATION ENGINEERING 3. Logical Operation: shift left operationa) Aim: Write an Assembly Language Program to perform Shift the given 16 bit no to The left and the result is stored in any one of the memory locations.b)Appartus/Software:1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1c)Algorithm: Step 1: Initialize the same index Step 2: Load the BX with the contents of the SI. Step 3: Shift the contents of the BX to the left by one. Step 4: Load the contents of the BX to the memory location. Step 5: Endd) Assembly language program before execution: Mnemonic Operand Comments Initialize SI at 2000 MOV SI, 2000 memory location Copy the data from SI MOV BX, [SI] location to BX Shift BX content to left SHL BX, 01 by 1 time Copy data from BX to MOV [5000], BX specified location HLT End programMICROPROCESSORS LAB 29
  30. 30. ELECTRONICS & COMMUNICATION ENGINEERINGe) Expected results:Input OutputAddress Data Address Data2000: C3 5000: 862001: E5 5001: CBf) Assembly language program after execution: Address Opcode Mnemonic Operand 1000 BE0020 MOV SI, 20000 1003 8A04 MOV BX, [SI] 1005 00F8 SHL BX, 01 1007 A30050 MOV [5000], BX 100B F4 HLTg) Results:Input OutputAddress Data Address Data2000: C3 5000: 862001: E5 5001: CBh) Viva- Voce: 1. When microprocessor is restarted it goes to which address? A. FFF0 2. Why do we need 16 bit address to be converted in to 20 bit address? A. Physical address of the memory is 20bitMICROPROCESSORS LAB 30
  31. 31. ELECTRONICS & COMMUNICATION ENGINEERING 3. Logical Operation: Packed BCD to Unpacked BCDa) Aim:-Write an Assembly Language Program in 8086 to convert packed BCD to unpacked BCD.b) Appartus/Software:1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1c) Algorithm: Step1:Load accumulator with data. Step2:Copy the value into AH register. Step3:To get the first unpacked number mask the lower byte by F0 using AND operation and load result in AH. Step4: Shift the contents of AH register right by 4 times load result in AH. Step5:Again to get the second unpacked number, mask higher byte by 0Fand store result in AL. Step6: End of the program.MICROPROCESSORS LAB 31
  32. 32. ELECTRONICS & COMMUNICATION ENGINEERINGd) Assembly language program before execution: Mnemonic Operand Comments MOV AL,[2000] Contents of memory move to AL MOV AH,AL Copy of AL register move to AH register AND AH,F0 Mask the lower nibble of AH register SHR AH,1 Shift right AH by 1 bit position SHR AH,1 Shift right AH by 1 bit position SHR AH,1 Shift right AH by 1 bit position SHR AH,1 Shift right AH by 1 bit position AND AL,0F Mask the Higher order nibble of AL register MOV [3000],AX Unpacked BCD numbers storing at 3000 & 3001 locations HLT End of the programMICROPROCESSORS LAB 32
  33. 33. ELECTRONICS & COMMUNICATION ENGINEERINGe) Expected results:Input OutputData Data78 08 07f) Assembly language program after execution: Address Opcode Mnemonic Operand 1000 A0,00,10 MOV AL,[2000] 1003 88,C4 MOV AH,AL 1005 80,E4,F0 AND AH,F0 1008 D0,EC SHR AH,1 100A D0,EC SHR AH,1 100C D0,EC SHR AH,1 100E D0,EC SHR AH,1 1010 24,0F AND AL,0F 1012 A3,00,20 MOV [3000],AX 1015 F4 HLTg) Results: Input OutputAddress Data Address Data2000: 87 3000: 07 3001: 08h) Viva-Voce: i) What are the contents of AH Register, after executing AND AH, F0, Assume that AH contains 98h ? A: 98h ANDed with F0 ,Low order nibble of 98h is masked ,Result is 90h stored at AH Register ii)What is the addressing mode of MOV [3000],AX instruction ? A: Direct addressing modeMICROPROCESSORS LAB 33
  34. 34. ELECTRONICS & COMMUNICATION ENGINEERING 3. Operation: Packed BCD to ASCIIa) Aim: - Write an Assembly Language Program in 8086 to convert packed BCDto ASCII.b) Appartus/Software:1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1c) Algorithm: Step1:Load CH register with count value04. Step2:Initialize SI with 2000. Step3:Move value of CH to CL.. Step4:Load the contents of 3000 & 3001 into AX Step5:Load BX with the value in AX. Step6:Anded AX value with 000F. Step7:Ored AL value with 30. Step8:Load AL value to SI location. Step9:Rotate Right the contents of BX by CL number of times. Step10:Load AX with BX contents. Step11:Increment SI Step12:Decrement the CH Step13:Jump if not zero go to step6 Step 14: stop the programMICROPROCESSORS LAB 34
  35. 35. ELECTRONICS & COMMUNICATION ENGINEERINGd) Assembly language program before execution:LABLE Mnemonic Operand Comments MOV CH,04 Load CH register with count value04 MOV SI,2000 Initialize SI with 2000. MOV CL,CH Move value of CH to CL. MOV AX,[3000] Load the contents of 3000 & 3001 into AX MOV BX,AX Load BX with the value in AX.UP AND AX,000F Anded AX value with 000F OR AL,30 Ored AL value with 30. MOV [SI],AL Load AL value to SI location. ROR BX,CL Rotate Right the contents of BX by CL number of times. MOV AX,BX Load AX with BX contents. INC SI Increment SI DEC CH Decrement the CH JNZ UP Jump if not zero go to step6 HLT stop the programe) Expected results:Input OutputData Data78 38 37MICROPROCESSORS LAB 35
  36. 36. ELECTRONICS & COMMUNICATION ENGINEERINGf) Assembly language program after execution: Address Opcode Mnemonic Operand 1000 B5,04 MOV CH,04 1002 BE,00,20 MOV SI,2000 1005 B1,04 MOV CL,CH 1007 A1,00,30 MOV AX,[3000] 89,C3 MOV BX,AX 100A 25,0F,00 AND AX,000F 100C 100F 0C,30 OR AL,30 1011 88,04 MOV [SI],AL 1013 D3,C8 ROR BX,CL 1015 89,D8 MOV AX,BX 1017 46 INC SI 1018 FE,CD DEC CH 75,F0 JNZ 100C 101A HLT 101Cg) Results: Input OutputAddress Data Address Data2000: 87 3000: 37 3001: 38MICROPROCESSORS LAB 36
  37. 37. ELECTRONICS & COMMUNICATION ENGINEERING 4. String Operation: Length of the stringa) Aim:- Write an Assembly Language Program in 8086 to find the length of givenstring, and string ended with 00h.b) Appartus/Software: 1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1c) Algorithm: Step1: Load CL, DL registers with 00H. Step2: Initialise memory pointer SI. Step3: Load Accumulator with data Step4: Compare AL with DL, if it is zero, move CL value to 3000 memory location Step5: if it is not zero, increment count register and memory Pointer To get the total length of the string Step6: Repeat loop until count becomes zero Step7: End of the programd) Assembly language program before execution: Lable Mnemonic Operand Comments MOV DL,00 Load DL with zero MOV CL,00 Load CL with zero MOV SI,1050 Load SI with 1050 UP MOV AL,[SI] AL,[SI] CMP AL,DL Compare AL with DL JZ DOWN If it is zero go to down INC CL increment CL by 1 INC SI increment SI by1 JMP UP Jump to up lable copy the contents of the CL in DOWN MOV [1075],CL to1075 HLT End of the programMICROPROCESSORS LAB 37
  38. 38. ELECTRONICS & COMMUNICATION ENGINEERINGe) Expected results: Input Output 58 07 59 61 62 63 64 65 00 All the data in Hexadecimal systemf) Assembly Language Program after execution: Address Opcode Mnemonic Operand 1000 B2,00 MOV DL,00 1002 81,00 MOV CL,00 1004 BE,50,10 MOV SI,1050 1007 8A,04 MOV AL,[SI] 1009 38,D0 CMP AL,DL 100B 74,05 JZ DOWN 100D FE,CL INC CL 100F 46 INC SI 1010 EB,F5 JMP UP 1012 88.0E,75,10 MOV [1075],CL 1016 F4 HLTMICROPROCESSORS LAB 38
  39. 39. ELECTRONICS & COMMUNICATION ENGINEERINGg) Results: Input OutputAddress data Address data1050: 76 1075: 071051: 591052: 691053: 621054: 641055: 651056: 331057: 00H) Viva-Voce: i).What is the purpose of SI register in above program? A: SI register used as Memory pointer ii) What is the addressing mode of MOV AL,[SI] instruction? A: Indirect addressing mode: addressMICROPROCESSORS LAB 39
  40. 40. ELECTRONICS & COMMUNICATION ENGINEERING 4. String Operation: Reverse ordera) Aim: Write an assembly language program in 8086 to arrange the given array in reverse order.b) Appartus/Software: 1. 8086 microprocessor kit/MASM ---1 2. RPS (+5V). ---1c) Algorithm : Step 1: Load the count register with no of array elements. Step 2: Add the count with source starting address and move it to source register. So the source register now contains address of last array element. Step 3: Load the destination address into destination index. Step 4: Load first byte from source into a register, and load it into a destination Memory location. Step 5: Increment destination address to load next byte of data, and decrement source address for next byte of data. Step 6: Repeat the steps 4 and 5 until the count is zero. Step 7: end the program.MICROPROCESSORS LAB 40
  41. 41. ELECTRONICS & COMMUNICATION ENGINEERINGd) Assembly language program before execution: Lable Mnemonic Operand Comments Initialize the memory pointer MOV SI,2050 for data MOV AH,00 Initialize the AH with 00H MOV CL,[2070] Load count into CH register Copy the contents in to CH MOV CH,CL register The data from memory to al UP1 MOV AL,[SI] Register PUSH AX Save AX in to stack INC SI Go to next data DEC CL Decrement the count If count is not equal to zero JNZ UP then go to up1 MOV SI,2050 SI is loaded with 2050 UP1 POP AX Pop the valve from AX Move the Al valve to SI MOV [SI],AL Register INC SI Increment the valve in SI Decrement the cont valve CL DEC CH,CL from CH register If the valve is not equal to zero then jump to UP1,otherwise JNZ UP1 halt HLT End of the programMICROPROCESSORS LAB 41
  42. 42. ELECTRONICS & COMMUNICATION ENGINEERINGe) Expected results: Input Output Address Data Address Data2070: 042050: 09 2050: 062051: 08 2051: 072052 07 2052: 082053: 06 2053: 09f) Assembly language program after execution: 2000 BE,50,20 MOV SI,2050 2003 B4,00 MOV AH,00 2005 8A,0E,70,20 MOV CL,[2070] 2009 88,C0 MOV CH,CL 200B 8A,04 MOV AL,[SI] 200D 50 PUSH AX 200E 46 INC SI 200F FE,C9 DEC CL 2011 75,F8 JNZ UP 2013 BE,50,20 MOV SI,2050 2016 58 POP AX 2017 88,04 MOV [SI],AL 2019 46 INC SI 201A FE,CD DEC CH,CL 201C 75,F8 JNZ UP1 201E F4 HLTMICROPROCESSORS LAB 42
  43. 43. ELECTRONICS & COMMUNICATION ENGINEERINGg) Results:Input OutputAddress Data Address Data2070: 042050: 09 2050: 062051: 08 2051: 072052 07 2052: 082053: 06 2053: 09H) Viva -Voice:i)what is the addressing mode of MOV DI,2002 instruction?a) Immediate addressing mode.ii)what is the difference between CMP AX,DX and SUB AX,DX instructions? a) In CMP AX, DX instruction, perform AX-DX, but AX is not modified. b) SUB AX, DX instruction performs AX-DX.,result is stored at AX registerMICROPROCESSORS LAB 43
  44. 44. ELECTRONICS & COMMUNICATION ENGINEERING 4. String Operation: Deletea) Aim: Write an ALP to delete an element from a String using normal instructions.b) Apparatus/Software: 1.8086 microprocessor kit/MASM-- 1 2.RPS(+5V). -- 1c) Algorithm: Step1.Initialize memory pointer at 2000 location. Step2.Load counter register value. Step3.Initialize memory pointer DI at 3000 memory location. Step4.Copy data from 3000 location to DL . Step5.Subtract count value with DL. Step6.Add data register value to memory location.. Step7.Increment memory location and copy that value to AL. Step8.Again move AL value to SI. Step9.To delete element from string ,repeat this procedure until count becomes zero.d) Assembly Language Program before execution: Lable Mnemonic Operand Comments MOV SI,2000 Load the SI with specified address MOV CL,[SI] Copy data to CL from SI MOV DI,3000 Load the DI with specified address MOV DX,0000 Clear DX register MOV DL,[DI] Copy data to DL from DI SUB CL,DL Subtract content of CL from content of DL ADD SI,DX Add SI with DX UP MOV AL,[SI+1] Increment SI and copy that data to AL MOV [SI],AL Move accumulator content to SI location DEC CL Decrement CL INC SI Increment memory pointer SI JNZ UP If CL is not zero ,repeat loop HLT End of the ProgramMICROPROCESSORS LAB 44
  45. 45. ELECTRONICS & COMMUNICATION ENGINEERINGe) Expected result: Input Output 10h 10h 20h 30h 30h 40h 40h 01hf) Assembly language program after execution: Address Opcode Mnemonic Operand 1000 BE,00,20 MOV SI,2000 1003 8A,0C MOV CL,[SI] 1005 BF,00,30 MOV DI,3000 1008 BA,00,00 MOV DX,0000 100B 8A,15 MOV DL,[DI] 100D 28,D1 SUB CL,DL 100F 01,06 ADD SI,DX 1011 8A,44,01 MOV AL,[SI+1] 1014 88,04 MOV [SI],AL 1016 FE,C9 DEC CL 1018 46 INC SI 1019 75,F6 JNZ 1011 101B F4 HLTMICROPROCESSORS LAB 45
  46. 46. ELECTRONICS & COMMUNICATION ENGINEERINGg) Results: Input OutputAddress Data Address Data2000: 10H 2000: 10H2001: 20H 2001: 30H2002: 30H 2002: 40H2003: 40H3000: 01Hh) Viva –Voice: i) What are the flags effected after executing ADD SI,DX instruction? A: C,Z,AF,S,P flagsMICROPROCESSORS LAB 46
  47. 47. ELECTRONICS & COMMUNICATION ENGINEERING 4. String Operation: Inserta) Aim: Write an ALP to insert an element into a String using normal instructions.b)Appartus/Software: 1.8086 microprocessor kit/MASM-- 1 2.RPS(+5V). --1c)Algorithm: Step1.Initialize memory pointer at 2000 location. Step2.Load counter register value. Step3.Initialize memory pointer DI at 3000 memory location. Step4.Copy data from 3000 location to DL . Step5.Subtract count value with DL. Step6.ADD data register value to memory location.. Step7.Increment memory location and copy that value to AH. Step8.Increment memory pointer DI . Step9.Copy the data from SI memory location AL and AL to DI memory location. Step10.Again increment memory pointer SI Step11.Copy the data from SI memory location to Al. Step13.Copy the data from Ah to SI memory location . Step14.Copy the data from AL to AH. Step15.To insert an element into a string ,repeat this procedure until count becomes zeroMICROPROCESSORS LAB 47
  48. 48. ELECTRONICS & COMMUNICATION ENGINEERINGd) Assembly Language Program before execution: Lable Mnemonic Operand Comments MOV SI,2000 Intilise the memory pointer at SI MOV CL,[SI] Load the count into CL register MOV DI,3000 Intilise the memory pointer MOV DX,0000 Intilise DX register with 0000h MOV DL,[DI] Move contents of memory location whose address at Di to DL register SUB CL,DL Substract DL from CL register INC CL CL is incremented by 1 ADD SI,DX Move DX contents to SI register MOV AH,[SI] Move memory data to AH register INC DI Increment DI by 1 MOV AL,[DI] Move Memry data whose address DI to AL register MOV [SI],AL Move AL to memory whose address at SI UP INC SI Increment SI MOV AL,[SI] Move memory data to AL MOV [SI],AH Move AH data to memory MOV AH,AL Move AL data to AH DEC CL CL is decremented by 1 JNZ UP Whether all numbers completed or not. HLT End of the [programMICROPROCESSORS LAB 48
  49. 49. ELECTRONICS & COMMUNICATION ENGINEERINGe) Expected result: Input Output 10h 10h 20h 20h 30h 30h 50h 40h 02h 50h 30hf) Assembly language program after execution: Address Opcode Mnemonic Operand 1000 BE,00,20 MOV SI,2000 1003 8A,0C MOV CL,[SI] 1005 BF,00,30 MOV DI,3000 1008 BA,00,00 MOV DX,0000 100B 8A,75 MOV DL,[DI] 100D 28,75 SUB CL,DL 100F FE,C1 INC CL 1011 01,D6 ADD SI,DX 1013 8A,24 MOV AH,[SI] 1015 47 INC DI 1016 8A,05 MOV AL,[DI] 1018 88,04 MOV [SI],AL 101A 46 INC SI 101B 8A,04 MOV AL,[SI] 101D 88,24 MOV [SI],AH 101F 88,C4 MOV AH,AL 1021 FE,C9 DEC CL 1023 75,F5 JNZ UP 1025 F4 HLTMICROPROCESSORS LAB 49
  50. 50. ELECTRONICS & COMMUNICATION ENGINEERINGg) Results: Input Output:Address Data Address Data2000: 10h 2000: 10h2001: 20h 2001: 20h2002: 30h 2002: 30h2003: 50h 2003: 40h3000: 02h 2004: 50h3001: 30hH) Viva –Voice: i) What is the difference between MOV AX,SI and MOV AX,[SI] ? A: MOV AX,SI : Moves SI register data to AX register MOV AX,[SI] : Moves contents of memory location whose addresses at SI ,SI+1 to AX registerMICROPROCESSORS LAB 50
  51. 51. ELECTRONICS & COMMUNICATION ENGINEERING 4. Operation: sortinga) Aim: Write an Assembly Language Program to find maximum of given ‘n’ 16 bit numbers.b) Appartus /Software: 1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1c) Algorithm:Step1: Load the count into count register.Step2: Load the starting address of array into a register.Step3: Move the first word of data into AX register and second word into another Register DX.Step4: Compare these two words. If the first one, AX is greater than DX, then go toStep5: Get the next word into DX, and repeat the steps 3 and 4 until the countregister is zero.Step6: Load the final maximum 16 bit number which is at AX into memory location.MICROPROCESSORS LAB 51
  52. 52. ELECTRONICS & COMMUNICATION ENGINEERINGd) Assembly language program before execution: Lable mnemonic Operand Comments Move the valve in address of MOV CX,[2000] 2000 to register CX MOV DI,0002 Initialize the register ,DI up MOV BX,2002 Initialize the register ,BX Assign BX valve to AX register. MOV AX,[BX] again MOV DX,[BX+DI] Compare the values in CMP AX,DX registers, AX & DX. JNB up Jump if AX is greater DX Move DX register valve to MOV AX,DX AX. ADD DI,+02 Increment DI valve with 02 Decrement CX register valve DEC CX by valve in 2000 JNZ again Jump if CX register MOV [BX+DI],AX HLTe) Expected results:Input OutputData Data3003,3032,9030,0083 9030MICROPROCESSORS LAB 52
  53. 53. ELECTRONICS & COMMUNICATION ENGINEERINGf) Assembly language program after execution: Address Opcode Mnemonics Operand 1000 8B0E020 MOV CX,[2000] 1004 BF0200 MOV DI,0002 1007 BB0220 MOV BX,2002 100A 8B07 MOV AX,[BX] 100C 8B11 MOV DX,[BX+DI] 100E 3900 CMP AX,DX 1010 7302 JNB 1014 1012 89D0 MOV AX,DX 1014 83C702 ADD DI,+02 1017 49 DEC CX 1018 75F2 JNZ 100C 101A 8901F4 MOV [BX+DI],AX 101C HLTg) Results:Input OutputAddress Data Address Data1000: 031001: 301002: 321003: 301004: 901005: 831006: 00H) Viva –Voice:1.What is the addressing mode of MOV [BX+DI], AXA.Base plus Index addressing modeMICROPROCESSORS LAB 53
  54. 54. ELECTRONICS & COMMUNICATION ENGINEERING 4. String Operation: Move blocka) Aim: Write an Assembly Language Program to transfer string from one location into another location which is in memory.b) Appartus/Software: 1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1c) Algorithm:Step1: Load source register with source address.Step2: Load destination register with destination address.Step3: Choose the direction of transfer by using appropriate instruction.Step4: Move the data until the byte is equal to 99.Step5: when the byte is equal to 99, transfer this 99 to last location.Step6: End the program.d) Assembly language program before execution: Mnemonic Operand comments MOV SI,2000 Load SI with source address MOV DI,2050 Load DI with destination address load CL register with data available at MOV CL,[SI] memory location SI INC SI Increment memory pointer SI Move all bytes form one location to MOVSB another location REPZ Repeat loop until count becomes zero HLT End of the programMICROPROCESSORS LAB 54
  55. 55. ELECTRONICS & COMMUNICATION ENGINEERINGe) Expected results:Input OutputAddress Data Address Data2000: 05 2050: 012001: 01 2051: 022002: 02 2052: 032003: 03 2053: 042004: 04 2054: 052005: 05f) Assembly language program after execution: Address Opcode Mnemonic Operand 1000 BE,80,30 MOV SI,2000 1003 BF,50,30 MOV DI,2050 1006 8A,0C MOV CL,[SI] 1008 46 INC SI 1009 F3 REPZ 100A A4 MOVSB 100B F4 HLTg) Results:Input OutputAddress Data Address Data2000: 05 2050: 012001: 01 2051: 022002: 02 2052: 032003: 03 2053: 042004: 04 2054: 052005: 05H) Viva- Voice: 1. What is the purpose of REP instruction? A. Repeat the set of instructions until CX becomes zeroMICROPROCESSORS LAB 55
  56. 56. ELECTRONICS & COMMUNICATION ENGINEERING 5.Dos / Bios Programminga) Aim: write an Assembly language program Reading Key board with ECHOb)Appartus/Software:1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1c) Algorithm: Step1. Read keyboard with echo Step2. Extended Key Step3. No, plain ASCII in AL Step4. Read key board again to get extended Key code Step5. Extended Key code is returned in AL alsod) Assembly language program before execution:i) Reading Keyboard with ECHO Label Mnemonic Operand Comments key MOV AL,01 Read keyboard with echo MOV AH,01 INT 21 Extended key JNZ key no, plain ASCII in AL MOV AH,01 extended key code extended key code is returned in INT 21H AL alsoMICROPROCESSORS LAB 56
  57. 57. ELECTRONICS & COMMUNICATION ENGINEERINGf) Assembly language program after execution: Address Opcode Mnemonic Operand 1000 B0,01 MOV AL,01 1002 B4,01 MOV AH,01 1004 CD,21 INT 21 1006 75,F8 JNZ 1000 1008 B4,01 MOV AH,01 100A CD,21 INT 21Hii) Reading Keyboard without ECHO Mnemonic Operand Comments Read keyboard MOV AH,08 echo INT 21iii) Video Display Output Mnemonic Operand Comments MOV DL,0D MOV AH,02 INT 21g) Results:Input OutputKey pressed asdfg;lkjhh) viva-voce: i) What is the use of BIOS calls? A: The BIOS interacts with the system hardware, MS DOS kernel accepts requests from the application programs and passes these on to BIOS and sytem hardwareMICROPROCESSORS LAB 57
  58. 58. ELECTRONICS & COMMUNICATION ENGINEERING II. Interfacing: 1. Intel 8259 : Interrupt Generationa) Aim: Write an ALP in 8086 to generate an interrupt using Intel 8259.b) Apparatus: 8086 kit ---1 8259 module ---1 Power supply(+Vcc=5)c) Assembly language program before execution:LABEL MNEMONIC OPERAND PUSH CS POP ES CALL FAR CLRDSP MOV AX,0000H MOV DS,AX MOV BX, MOV CX,08H MOV WORD PTR [BX],00H ADD BX,4 LOOP FILL_ CS MOV BX,0200H LEA AX,CS:SERV1 MOV [BX],AX ADD BX,4 LEA AX,CS:SERV2 MOV [BX],AX ADD BX,4 LEA AX,CS:SERV3 MOV [BX],AX ADD BX,4MICROPROCESSORS LAB 58
  59. 59. ELECTRONICS & COMMUNICATION ENGINEERING LEA AX,CS:SERV4 MOV [BX],AX ADD BX,4 LEA AX,CS:SERV5 MOV [BX],AXLABEL MNEMONIC OPERAND ADD BX,4 LEA AX,CS:SERV6 MOV [BX],AX ADD BX,4 LEA AX,CS:SERV7 MOV [BX],AX ADD BX,4 LEA AX,CS:SERV8 MOV [BX],AX ADD BX,4 MOV DX,0FF30H MOV AL,13H OUT DX,AL MOV DX,0FF32H MOV AL,60 OUT DX,AL MOV AL,0FH OUT DX,AL MOV AL,00H OUT DX,AL MOV DI,80H MOV SI,OFFSET MSG CALL FAR OP STIBCK: JMP BCKSERV1: MOV DI,080H MOV SI,OFFSET MSG1 CALL FAR OPMICROPROCESSORS LAB 59
  60. 60. ELECTRONICS & COMMUNICATION ENGINEERING STI IRETSERV2: MOV DI,080H MOV SI,OFFSET MSG2 CALL FAR OPLABEL MNEMONIC OPERAND STI IRETSERV3: MOV DI,080H MOV SI,OFFSET MSG3 CALL FAR OP STI IRETSERV4: MOV DI,080H MOV SI,OFFSET MSG4 CALL FAR OP STI IRESERV5: MOV DI,080H MOV SI,OFFSET MSG5 CALL FAR OP STI IRETSERV6: MOV DI,080H MOV SI,OFFSET MSG6 CALL FAR OP STI IRETORG 0:6030HSERV7: MOV DI,080H MOV SI,OFFSET MSG7 CALL FAR OP STI IRETSERV8: MOV DI,080HMICROPROCESSORS LAB 60
  61. 61. ELECTRONICS & COMMUNICATION ENGINEERING MOV SI,OFFSET MSG8 CALL FAR OP STICSEG ENDSENDSd) Assembly language program after execution:ADDRESS OPCODE MNEMONIC OPERAND 0000:52B0 0E PUSH CS 0000:52B1 07 POP ES 0000:52B2 9A B1 4B 00 F8 CALL 4BB1,F800 0000:52B7 B8 00 00 MOV AX,0000H 0000:52BA 8E D8 MOV DS,AX 0000:52BC BB 02 02 MOV BX,0202H 0000:52BF B9 08 00 MOV CX,08H 0000:52C2 LOOP FILL_CS: 0000:52C2 C7 07 00 00 MOV WORDPTR[BX],00H;0F000H 0000:52C6 83 C3 04 ADD BX,4 0000:52C9 E2 F7 LOOP FILL_CS 0000:52CB BB 00 02 MOV BX,0200H 0000:52CE 2E 8D 06 00 60 LEA AX,CS:SERV1 0000:52D3 89 07 MOV [BX],AX 0000:52D5 83 C3 04 ADD BX,4 0000:52D8 2E 8D 06 08 60 LEA AX,CS:SERV2 0000:52DD 89 07 MOV [BX],AX 0000:52DF 83 C3 04 ADD BX,4 0000:52E2 2E 8D 06 10 60 LEA AX,CS:SERV3 0000:52E7 89 07 MOV [BX],AX 0000:52E9 83 C3 04 ADD BX,4 0000:52EC 2E 8D 06 18 60 LEA AX,CS:SERV4 0000:52F1 89 07 MOV [BX],AX 0000:52F3 83 C3 04 ADD BX,4 0000:52F6 2E 8D 06 20 60 LEA AX,CS:SERV5 0000:52FB 89 07 MOV [BX],AXMICROPROCESSORS LAB 61
  62. 62. ELECTRONICS & COMMUNICATION ENGINEERING 0000:52FD 83 C3 04 ADD BX,4 0000:5300 2E 8D 06 28 60 LEA AX,CS:SERV6 0000:5305 89 07 MOV [BX],AX 0000:5307 83 C3 04 ADD BX,4 0000:530A 2E 8D 06 30 60 LEA AX,CS:SERV7 0000:530F 89 07 MOV [BX],AX 0000:5311 83 C3 04 ADD BX,4 0000:5314 2E 8D 06 38 60 LEA AX,CS:SERV8 0000:5319 89 07 MOV [BX],AX 0000:531B 83 C3 04 ADD BX,4 0000:531E BA 30 FF MOV DX,0FF30H 0000:5321 B0 13 MOV AL,13H 0000:5323 EE OUT DX,AL 0000:5324 BA 32 FF MOV DX,0FF32H 0000:5327 B0 60 MOV AL,60H 0000:5329 EE OUT DX,AL 0000:532A B0 0F MOV AL,0FH 0000:532C EE OUT DX,AL 0000:532D B0 00 MOV AL,00H 0000:532F EE OUT DX,AL 0000:5330 BF 80 00 MOV DI,80H 0000:5333 BE 00 52 MOV SI, 5200 0000:5336 9A C0 4F 00 F8 CALL FAR OP 0000:533B FB STI 0000:533C E9 FD FF BCK: JMP BCK 0000:6000 ORG 0:6000H 0000:6000 BF 80 00 SERV1 MOV DI,080H 0000:6003 BE 11 52 MOV SI,OFFSET MSG1 0000:6006 9A C0 4F 00 F8 CALL FAR OP 0000:600B FB STI 0000:600C CF IRET 0000:6008 ORG 0:6008H 0000:6008 BF 80 00 SERV2: MOV DI,8000 0000:600E 9A C0 4F 00 F8 CALL FAR OP FB STIMICROPROCESSORS LAB 62
  63. 63. ELECTRONICS & COMMUNICATION ENGINEERING 0000:6013 0000:6014 CF IRET 0000:6010 ORG 0:6010H 0000:6010 BF 80 00 SERV3: MOV DI,080H 0000:6013 BE 33 52 MOV SI,OFFSET MSG3 0000:6016 9A C0 4F 00 F8 CALL FAR OP;F000:1000H 0000:601B FB STI 0000:601C CF IRET 0000:6018 ORG 0:6018H 0000:6018 BF 80 00 SERV4: MOV DI,080H 0000:601B BE 44 52 MOV SI,OFFSET MSG4 0000:601E 9A C0 4F 00 F8 CALL FAR OP;F000:1000H 0000:6023 FB STI 0000:6024 CF IRET 0000:6020 ORG 0:6020H 0000:6020 BF 80 00 SERV5: MOV DI,080H 0000:6023 BE 55 52 MOV SI,OFFSET MSG5 0000:6026 9A C0 4F 00 F8 CALL FAR OP;F000:1000H 0000:602B FB STI 0000:602C CF IRET 0000:6028 ORG 0:602 0000:6028 BF 80 00 SERV6: MOV DI,080H 0000:602B BE 66 52 MOV SI,OFFSET MSG6 0000:602E 9A C0 4F 00 F8 CALL FAR OP;F000:1000H 0000:6033 FB STI 0000:6034 CF IRE 0000:6030 ORG 0:6030H 0000:6030 BF 80 00 SERV7: MOV DI,080H 0000:6033 BE 77 52 MOV SI,OFFSET MSG7 0000:6036 9A C0 4F 00 F8 CALL FAR OP 0000:603B FB STI 0000:603C CF ORG IRETMICROPROCESSORS LAB 63
  64. 64. ELECTRONICS & COMMUNICATION ENGINEERING 0:6038H 0000:6038 SERV8: 0000:6038 BF 80 00 MOV DI,080H 0000:603B BE 88 52 MOV SI,OFFSET MSG8 0000:603E 9A C0 4F 00 F8 CALL FAR OP 0000:6043 FB STI 0000:6044 CF IRET CSEG ENDS ENDSe) Observations:After executing the above programThe message 8259 displayed on the address on the address field of the kitOnce the interrupt acknowledge is received displays FE on the data field of the kitFor interrupt no ’0’.MICROPROCESSORS LAB 64
  65. 65. ELECTRONICS & COMMUNICATION ENGINEERING 2 .8279 Key board displaya) Aim: Write an ALP in 8086 to display string of characters from left to right (leftentry mode) in output mode.b) Apparatus: 8086 microprocessor kit i. Intel 8279 interfacing module ii. +5v D C supply iii. Serial port communication cablec) Specifications: Keyboard and display interface module must be connectedto 8086 microprocessor kit through a 50 pin connecter.d) Description of module: Intel 8279 is a general purpose programmablekeyboard and display interface I/O device .A keyboard portion can provide scannedinterface to a 64 contact key matrix. Key board entries are debounced and strobed inan 8-character FIFO.The display portion provides a scanned display interface for LED .It has 16*8 displayRam which can be organized into a dual 16*4.Both right entry and left entry displayformats are possible.Circuit DiagramFig: Inter facing Key boardmodule to 8086 MicroprocessorMICROPROCESSORS LAB 65
  66. 66. ELECTRONICS & COMMUNICATION ENGINEERINGe) Algorithm: Step1: Load left entry 8 bit character Display Step 2:Load clock dividing factor Step3:Send command word to clear the display Step4:Introduce the wait instruction until the display is cleared Step5:Now send control word for left entry mode. Step6:Load count 8 into the count register for number of character to be. Step7:Initalize the memory pointer to store the character to be displayed. Step8Write a control word for writing to display, auto increment mode. Step9Displays 0 to 7 when both ctrl and sht is not pressed.f) Program requirements:Intel 8279 control wordsControl word for left entry 8bit character display D7 D6 D5 D4 D3 D2 D1 D0 0 0 0 0 1 0 0 1 =:09HClock dividing factor D7 D6 D5 D4 D3 D2 D1 D0 0 0 1 1 0 0 0 1 =31HTo clear the display D7 D6 D5 D4 D3 D2 D1 D0 1 1 0 1 0 0 0 0 =D0MICROPROCESSORS LAB 66

×