SlideShare a Scribd company logo
1 of 269
Download to read offline
ELECTRONICS & COMMUNICATION ENGINEERING




                           1. Introduction to MASM

Introduction:

The aim of this experiment is to introduce the student to assembly language
programming and the use of the tools that he will need throughout the lab
experiments. This first experiment let the student use the Dos Debugger and the
Microsoft Macro Assembler (MASM). Editing, Assembling, Linking, Execute up can
be done using MASM software
Objectives:

        1. Introduction to Microsoft Macro Assembler (MASM)
        2. General structure of an assembly language program
        3. Use of the Dos Debugger program


Overview:
In general, programming of microprocessor usually takes several iterations before
the right sequence of machine code instruction is written. The process, however is
facilitated using a special program called an “Assembler”. The Assembler allows the
user to write alphanumeric instructions. The Assembler, in turn, generates the
desired 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 Phases




MICROPROCESSORS LAB                                                               1
ELECTRONICS & COMMUNICATION ENGINEERING



Assembling the program:

The assembler is used to convert the assembly language instructions to machine
code. It is used immediately after writing the Assembly language program. The
assembler starts by checking the syntax or validity of the structure of each instruction
in the source file .if any errors are found, the assemblers displays a report on these
errors along with brief explanation of their nature. However
If the program does contain any errors ,the assembler produces an object file that
has the same name as the original file but with the “obj” extension


Linking the program:

The Linker is used convert the object file to an executable file. The executable file is
the final set of machine code instructions that can directly be executed by the
microprocessor. 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 long
program. This segment can not operate by itself, and must be integrated with other
object files representing the rest of the program ,in order to produce the final self-
contained executable file


In 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 program


Executing the program

The executable contains the machine language code .it can be loaded in the RAM
and executed by the microprocessor simply by typing ,from the DOS prompt ,the
name of the file followed by the carriage Return Key (Enter Key). If the program
produces an output on the screen or sequence of control signals to control a piece of
hard ware, the effect should be noticed almost immediately.However,if the program
manipulates data in memory, nothing would seem to have happened as a result of
executing the program.


MICROPROCESSORS LAB                                                                      2
ELECTRONICS & COMMUNICATION ENGINEERING




Debugging the program

The debugger can also be used to find logical errors in the program. Even if a
program does not contain syntax errors it may not produce the desired results after
execution. Logical errors may be found by tracing the action of the program. once
found, the source file should be rewrite to fix the problem, then the re-assembled and
re-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 stepping
through the program or executing the program up to a desired point, called break
point. It also allows the user to inspect or change the contents of the microprocessor
internal 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 the
capability to trace logical errors in executable file. It allows the user to take an
existing executable file and unassembled it,i.e convert it to               assembly
language.Also,it allows the user to write assembly language instructions      directly,
and then convert them to machine language. The program is simple and easy to
use. But offers limited capabilities, which make it unsuitable for serious assembly
language 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
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 by
Microsoft Corporation for professional software developers. it consists of an editor,
an assembler, a linker and a debugger(Code View). The programmer’s workbench
combines these four parts into a user-friendly programming environment with built in
on 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 phases




MICROPROCESSORS LAB                                                                 4
ELECTRONICS & COMMUNICATION ENGINEERING



Procedure 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 ENTER

MICROPROCESSORS LAB                                                    5
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
                                            HLT
For the above sample program we have to enter the data into memory locations. For
  that the procedure is given below

Step1:           Type the sample program by using the above procedure.

Step2:          Then type ‘e’ 2000 (← address of the memory location)

Step3:          Then press ENTER

MICROPROCESSORS LAB                                                                 6
ELECTRONICS & COMMUNICATION ENGINEERING

Step4:          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
ELECTRONICS & COMMUNICATION ENGINEERING



Procedure 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
ELECTRONICS & COMMUNICATION ENGINEERING




                   2. Arithmetic Operation: Addition



a) 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).                          --1
c) Algorithm:
Step1: load CL with 03
Step2 : Initialize the source Index
Step3: Initialize the AL with ‘00’
Step4: Add the contents of the AL with the contents of the SI
        and the result is stored in AL
Step5: Increment SI
Step6: Decrement the content in CL
Step7: If CL is not equal to zero, go to step4
Step8: Store the contents of the Al into any memory location.
Step9: Stop
d) 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 00
UP         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 program



MICROPROCESSORS LAB                                                                        9
ELECTRONICS & COMMUNICATION ENGINEERING




e) Expected results:
Input: 10h                                Output: 60H
          20h
          30h
f)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              HLT


g) Results:
Input :                                   output:
Address           data                    Address        data
2000:            10h                      3000:          60H
2001:            20h
2002:            30h
  CL :           03h
 AL:             00h
h) 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
ELECTRONICS & COMMUNICATION ENGINEERING




           2. Arithmetic Operation: Multibyte addition
a) 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).                      -- 1


c) Algorithm:

Step1: Load BX with 1230
Step2: Load SI with Specific offset value
Step3: 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
Step4: Add the contents of BX, SI with Displacement and load the content in DX
Step5: Repeat Step4
Step6: Add the contents of BX, SI with Displacement and load the content in
        DX Also carry
Step7: Initialize CX register
Step8: Add with carry
Step9: Load BX with 1440
Step10: the contents of Ax loaded with memory location whose address is specified
by
         sum of BX and SI
Step11: the contents of DX loaded with memory location whose address is specified
by
         sum of BX and SI with Displacement and load the content in DX
Step12: Add the contents of BX, SI with Displacement and load the content in DX
Step13: Stop




MICROPROCESSORS LAB                                                                  11
ELECTRONICS & COMMUNICATION ENGINEERING



d) 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 program




e) Expected results
:Input: 12 32 12 32: 1st number


        23 21 23 21: 2nd number
Output : 35 53 35 53 h




MICROPROCESSORS LAB                                                                       12
ELECTRONICS & COMMUNICATION ENGINEERING




f) 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       HLT



g) Results:
Input:                                        Output
Address         Data                          Address        Data
1232:           32                            1442:          53
1233            12                            1443:          35
1234:           34                            1444:          53
1235:           12                            1445:          35
1236:           21                            1446:          00
1237:           23
1238:           21
1239:           23
h) 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 effected
MICROPROCESSORS LAB                                                                   13
ELECTRONICS & COMMUNICATION ENGINEERING




                2. Arithmetic Operation: Subtraction

a) 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).                     --2
c) 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 program


e) Expected result:


Input:           30
            _   20
           _______________
                10
          _______________




MICROPROCESSORS LAB                                                               14
ELECTRONICS & COMMUNICATION ENGINEERING



f) 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               HLT




g) Results:

Input:                                        Output:


Address         Data                          Address        Data
2000:           30
2001:           20                            3000:          10




h) 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 effected




MICROPROCESSORS LAB                                                                   15
ELECTRONICS & COMMUNICATION ENGINEERING




              2. Arithmetic Operation: Multiplication

a) 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
ELECTRONICS & COMMUNICATION ENGINEERING




d) 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 program




e) Expected results

Numbers are : 65h & 2A h
Output/Result: 2B20




MICROPROCESSORS LAB                                                                        17
ELECTRONICS & COMMUNICATION ENGINEERING



f) 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               HLT


g) Results:
        Input                             Output
Address         data             address                   data
1050:           2A h             1052:             20h
1051:           65h              1053:             2Bh


h) 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 effected
ii)what is the difference between MOV DX,[1050],MOV DX,1050?
A: MOV DX,[1050]; the contents of memory location whose address 1050 moved to
DL register,1,1051 contents moved to DH register
   MOV DX,[1050];50h moved to DL register
                        10h moved to DH register



MICROPROCESSORS LAB                                                              18
ELECTRONICS & COMMUNICATION ENGINEERING




2. 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).                  ---1
c) 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 program
d) 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 program




MICROPROCESSORS LAB                                                               19
ELECTRONICS & COMMUNICATION ENGINEERING



e) Expected results:
Input                                                 Output
Data                                                  Data
E4 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          HLT


g) Results:

Input                                                 Output
Address         Data                                  Address       Data
2000:           E4 h (Decimal no is-28)               3000:         C6h (Decimal no
                is -
                                                                                1652)
2001:           3Bh (Decimal no is +59)               3001:         03h




h) 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 Registers




MICROPROCESSORS LAB                                                                     20
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).                        ---1
c) 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 program

d) 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 program


MICROPROCESSORS LAB                                                               21
ELECTRONICS & COMMUNICATION ENGINEERING



e) Expected results:
Input                                                Output:
Data                                                 Data:
00E4/02                                              00F2


f) 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      HLT



g) Results:
Input                                                Output
Address         Data                                 Address       Data
2000:           E4                                   3000:         F2
2001:           00                                   3001:         00
2002:           02
h)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 -127

MICROPROCESSORS LAB                                                       22
ELECTRONICS & COMMUNICATION ENGINEERING




             2. Arithmetic Operation: ASCII addition



a) Aim:     Write an Assembly Language Program to perform the ASCII addition.


b) Appartus/Software:1. 8086 microprocessor kit/MASM---1
                                  2. RPS (+5V).                        ---1
c) Algorithm:
Step-1: Initialize the AH with 00
Step-2: Initialize the source Index
Step-3: Load the contents of the AL with contents of the SI
Step-4: Increment the SI
Step-5: Load the contents of the SI ti the BL
Step-6Add AL and BL
Step-7: Move the result from the accumulator to the memory location
Step-8: End of the program
d) 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 program




MICROPROCESSORS LAB                                                             23
ELECTRONICS & COMMUNICATION ENGINEERING




e) Expected results
Input                                               Output
Address         Data                        Address            Data


2000:           05                          3000:              04
2001:           09                          3001:              01


f) 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        HLT


g) Results:
Input                                               Output
Address         Data                        Address            Data


2000:           05                          3000:              04
2001:           09                          3001:              01




h) Viva- Voice:
                        1. Difference between CMPS&SCAS instruction
                        2. Difference between AAA&DAA instruction


MICROPROCESSORS LAB                                                   24
ELECTRONICS & COMMUNICATION ENGINEERING




         2. Arithmetic Operation: ASCII Multiplication

a) Aim:      Write an Assembly Language Program to perform the ASCII
             multiplication.


b) Appartus/Software:1. 8086 microprocessor kit/MASM---1
                                  2. RPS (+5V).                       ---1
c) Algorithm:
Step-1: Initialize the AH with 00
Step-2: Initialize the source Index
Step-3: Load the contents of the AL with contents of the SI
Step-4: Increment the SI
Step-5: Load the contents of the SI to the BH
Step-6: Multiply the contents of the BH with AL and result is stored in AX
Step-7OR the contents of AX with 3030
Step-8: Move the result from the accumulator to the memory location
Step-9: End of the program
d) 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 program


MICROPROCESSORS LAB                                                          25
ELECTRONICS & COMMUNICATION ENGINEERING



e) Expected results:

Input                                      Output
09*05                                      3435
f) 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       HLT




g) Results:

Input                                                Output
Address         Data                       Address            Data
2000:           09                         5000:              35
2001:           05                         5001:              34




MICROPROCESSORS LAB                                                  26
ELECTRONICS & COMMUNICATION ENGINEERING




           3. Logical Operation: shift right operation

a) 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).                       ---1


c) Algorithm:
Step-1: Initialize the AH with 00
Step-2: Initialize the source Index
Step-3: Load the contents of the AL with contents of the SI
Step-4: Shift the contents of the accumulator to the to the right by 1
Step-5:If there is barrow increment AH
Step-6: Otherwise load the contents of the AL to the memory location
Step-7: End of the program


d) 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 program



MICROPROCESSORS LAB                                                                     27
ELECTRONICS & COMMUNICATION ENGINEERING



e) Expected results:



Input                                                   Output
Data                                                    Data
27                                                      93


f) 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           HLT




g) Results:
Input                                                   Output
Address         Data                           Address            Data
3050:           71                             4000:              93


h) 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
ELECTRONICS & COMMUNICATION ENGINEERING




             3. Logical Operation: shift left operation

a) 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).                        ---1
c)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: End


d) 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 program




MICROPROCESSORS LAB                                                                   29
ELECTRONICS & COMMUNICATION ENGINEERING




e) Expected results:

Input                                                  Output
Address         Data                          Address            Data


2000:           C3                            5000:              86


2001:           E5                            5001:              CB


f) 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            HLT


g) Results:
Input                                                  Output
Address         Data                          Address            Data
2000:           C3                            5000:              86
2001:           E5                            5001:              CB


h) 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 20bit




MICROPROCESSORS LAB                                                               30
ELECTRONICS & COMMUNICATION ENGINEERING




  3. Logical Operation: Packed BCD to Unpacked BCD

a) 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).                  ---1




c) 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
ELECTRONICS & COMMUNICATION ENGINEERING




d) 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 program




MICROPROCESSORS LAB                                          32
ELECTRONICS & COMMUNICATION ENGINEERING




e) Expected results:
Input                                     Output
Data                                      Data
78                                        08
                                          07
f) 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              HLT



g) Results:
        Input                                                Output
Address           Data                             Address            Data
2000:             87                               3000:              07
                                                   3001:              08
h) 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 mode




MICROPROCESSORS LAB                                                                33
ELECTRONICS & COMMUNICATION ENGINEERING




                 3. Operation: Packed BCD to ASCII

a) Aim: - Write an Assembly Language Program in 8086 to convert packed BCD
to ASCII.



b) Appartus/Software:1. 8086 microprocessor kit/MASM---1
                                 2. RPS (+5V).                  ---1


c) 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 program




MICROPROCESSORS LAB                                                              34
ELECTRONICS & COMMUNICATION ENGINEERING




d) 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 program



e) Expected results:
Input                                      Output
Data                                       Data
78                                         38


                                           37




MICROPROCESSORS LAB                                                                     35
ELECTRONICS & COMMUNICATION ENGINEERING




f) 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
   101C



g) Results:
        Input                                          Output
Address          Data                          Address          Data
2000:            87                            3000:            37
                                               3001:            38




MICROPROCESSORS LAB                                                    36
ELECTRONICS & COMMUNICATION ENGINEERING




              4. String Operation: Length of the string

a) Aim:- Write an Assembly Language Program in 8086 to find the length of given
string, and string ended with 00h.
b) Appartus/Software: 1. 8086 microprocessor kit/MASM---1
                                      2. RPS (+5V).                       ---1
c) 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 program


d) 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 program




MICROPROCESSORS LAB                                                                     37
ELECTRONICS & COMMUNICATION ENGINEERING



e) Expected results:
        Input                             Output


        58                                07
        59
        61
        62
        63
        64
        65
        00


  All the data in Hexadecimal system


f) 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              HLT




MICROPROCESSORS LAB                                            38
ELECTRONICS & COMMUNICATION ENGINEERING




g) Results:

        Input                                        Output


Address         data                         Address          data


1050:           76                           1075:            07
1051:           59
1052:           69
1053:           62
1054:           64
1055:           65
1056:           33
1057:           00


H) 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: address




MICROPROCESSORS LAB                                                   39
ELECTRONICS & COMMUNICATION ENGINEERING




                  4. String Operation: Reverse order



a) 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).                           ---1




c) 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
ELECTRONICS & COMMUNICATION ENGINEERING




d) 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 program




MICROPROCESSORS LAB                                                           41
ELECTRONICS & COMMUNICATION ENGINEERING




e) Expected results:
 Input                                            Output
 Address        Data                      Address          Data




2070:           04
2050:           09                        2050:            06


2051:           08                        2051:            07
2052            07                        2052:            08
2053:           06                        2053:            09


f) 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        HLT




MICROPROCESSORS LAB                                               42
ELECTRONICS & COMMUNICATION ENGINEERING



g) Results:
Input                                              Output
Address         Data                       Address               Data




2070:           04
2050:           09                         2050:                 06


2051:           08                         2051:                 07
2052            07                         2052:                 08
2053:           06                         2053:                 09



H) 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 register




MICROPROCESSORS LAB                                                             43
ELECTRONICS & COMMUNICATION ENGINEERING




                         4. String Operation: Delete

a) 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).                      -- 1
c) 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 Program




MICROPROCESSORS LAB                                                                   44
ELECTRONICS & COMMUNICATION ENGINEERING




e) Expected result:

        Input                                  Output


        10h                                10h
        20h                                30h
        30h                                40h
        40h
        01h
f) 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        HLT




MICROPROCESSORS LAB                                           45
ELECTRONICS & COMMUNICATION ENGINEERING



g) Results:

   Input                                                Output


Address         Data                              Address        Data




2000:         10H                         2000:         10H
2001:         20H                         2001:         30H
2002:         30H                         2002:         40H
2003:         40H
3000:         01H




h) Viva –Voice:

        i)      What are the flags effected after executing ADD SI,DX instruction?
        A:      C,Z,AF,S,P flags




MICROPROCESSORS LAB                                                                  46
ELECTRONICS & COMMUNICATION ENGINEERING




                          4. String Operation: Insert

a) 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).                  --1




c)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 zero




MICROPROCESSORS LAB                                                                  47
ELECTRONICS & COMMUNICATION ENGINEERING



d) 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 [program




MICROPROCESSORS LAB                                                              48
ELECTRONICS & COMMUNICATION ENGINEERING



e) Expected result:

     Input                                            Output
        10h                                           10h
        20h                                           20h
        30h                                           30h
        50h                                           40h
        02h                                           50h
        30h


f) 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       HLT


MICROPROCESSORS LAB                                            49
ELECTRONICS & COMMUNICATION ENGINEERING



g) Results:

        Input                                        Output:


Address          Data                           Address     Data
2000:           10h                           2000: 10h
2001:           20h                           2001: 20h
2002:           30h                           2002: 30h
2003:           50h                           2003: 40h
3000:           02h                           2004: 50h
3001:           30h




H) 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 register




MICROPROCESSORS LAB                                                                50
ELECTRONICS & COMMUNICATION ENGINEERING




                              4. Operation: sorting



a) 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).                        ---1
c) 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 to


Step5: Get the next word into DX, and repeat the steps 3 and 4 until the count
register is zero.


Step6: Load the final maximum 16 bit number which is at AX into memory location.




MICROPROCESSORS LAB                                                                   51
ELECTRONICS & COMMUNICATION ENGINEERING




d) 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
              HLT




e) Expected results:

Input                                           Output


Data                                            Data


3003,3032,9030,0083                             9030




MICROPROCESSORS LAB                                                      52
ELECTRONICS & COMMUNICATION ENGINEERING



f) 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                     HLT


g) Results:
Input                                            Output
Address         Data                             Address   Data
1000:           03
1001:           30
1002:           32
1003:           30
1004:           90
1005:           83
1006:           00


H) Viva –Voice:
1.What is the addressing mode of MOV [BX+DI], AX
A.Base plus Index addressing mode




MICROPROCESSORS LAB                                               53
ELECTRONICS & COMMUNICATION ENGINEERING




                      4. String Operation: Move block

a) 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).                      ---1


c) 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 program




MICROPROCESSORS LAB                                                              54
ELECTRONICS & COMMUNICATION ENGINEERING




e) Expected results:
Input                                                  Output
Address         Data                           Address            Data
2000:           05                             2050:              01
2001:           01                             2051:              02
2002:           02                             2052:              03
2003:           03                             2053:              04
2004:           04                             2054:              05
2005:           05
f) 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        HLT


g) Results:
Input                                                  Output
Address         Data                           Address            Data
2000:           05                             2050:              01
2001:           01                             2051:              02
2002:           02                             2052:              03
2003:           03                             2053:              04
2004:           04                             2054:              05
2005:           05


H) Viva- Voice:
            1. What is the purpose of REP instruction?
            A. Repeat the set of instructions until CX becomes zero



MICROPROCESSORS LAB                                                      55
ELECTRONICS & COMMUNICATION ENGINEERING




                         5.Dos / Bios Programming

a) Aim: write an Assembly language program Reading Key board with ECHO



b)Appartus/Software:1. 8086 microprocessor kit/MASM---1
                                 2. RPS (+5V).                     ---1




c) 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 also


d) 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 also




MICROPROCESSORS LAB                                                       56
ELECTRONICS & COMMUNICATION ENGINEERING



f) 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           21H


ii) Reading Keyboard without ECHO

     Mnemonic Operand            Comments
                                 Read keyboard
     MOV              AH,08      echo
     INT              21



iii) Video Display Output
     Mnemonic Operand            Comments
     MOV              DL,0D
     MOV              AH,02
     INT              21


g) Results:
Input                                     Output
Key pressed                               asdfg;lkjh


h) 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 hardware


MICROPROCESSORS LAB                                                              57
ELECTRONICS & COMMUNICATION ENGINEERING




                                     II. Interfacing:
                  1. Intel 8259 : Interrupt Generation


a) 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,4
MICROPROCESSORS LAB                                                       58
ELECTRONICS & COMMUNICATION ENGINEERING



                LEA                       AX,CS:SERV4
                MOV                       [BX],AX
                ADD                       BX,4
                LEA                       AX,CS:SERV5
                MOV                       [BX],AX
LABEL           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


                 STI
BCK:             JMP                      BCK
SERV1:          MOV                       DI,080H
                MOV                       SI,OFFSET MSG1
                CALL                      FAR OP
MICROPROCESSORS LAB                                        59
ELECTRONICS & COMMUNICATION ENGINEERING



                STI
                IRET
SERV2:           MOV                      DI,080H
                MOV                       SI,OFFSET MSG2
                CALL                      FAR OP
LABEL           MNEMONIC                  OPERAND
                STI
                IRET
SERV3:          MOV                        DI,080H
                MOV                       SI,OFFSET MSG3
                CALL                        FAR OP
                STI
                IRET
SERV4:          MOV                        DI,080H
                MOV                       SI,OFFSET MSG4
                CALL                      FAR OP
                STI
                IRE
SERV5:          MOV                        DI,080H
                MOV                        SI,OFFSET MSG5
                CALL                      FAR OP
                STI
                IRET
SERV6:          MOV                        DI,080H
                MOV                       SI,OFFSET MSG6
                CALL                        FAR OP
                STI
                IRET
ORG      0:6030H
SERV7:          MOV                         DI,080H
                MOV                       SI,OFFSET MSG7
                CALL                      FAR OP
                STI
                 IRET
SERV8:          MOV                       DI,080H
MICROPROCESSORS LAB                                         60
ELECTRONICS & COMMUNICATION ENGINEERING



                MOV                       SI,OFFSET MSG8
                CALL                        FAR OP
                STI
CSEG             ENDS
ENDS
d) 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],AX

MICROPROCESSORS LAB                                                                  61
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                        STI

MICROPROCESSORS LAB                                                       62
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   IRET

MICROPROCESSORS LAB                                                        63
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
                                                    ENDS




e) Observations:
After executing the above program

The message 8259 displayed on the address on the address field of the kit

Once the interrupt acknowledge is received displays FE on the data field of the kit

For interrupt no ’0’.




MICROPROCESSORS LAB                                                                   64
ELECTRONICS & COMMUNICATION ENGINEERING




                          2 .8279 Key board display

a) Aim: Write an ALP in 8086 to display string of characters from left to right (left
entry mode) in output mode.

b) Apparatus:             8086 microprocessor kit
                        i. Intel 8279 interfacing module
                       ii. +5v D C supply
                      iii. Serial port communication cable

c) Specifications: Keyboard and display interface module must be connected
to 8086 microprocessor kit through a 50 pin connecter.

d) Description of module:             Intel 8279 is a general purpose programmable
keyboard and display interface I/O device .A keyboard portion can provide scanned
interface to a 64 contact key matrix. Key board entries are debounced and strobed in
an 8-character FIFO.
The display portion provides a scanned display interface for LED .It has 16*8 display
Ram which can be organized into a dual 16*4.Both right entry and left entry display
formats are possible.


Circuit Diagram




Fig: Inter facing Key boardmodule to 8086 Microprocessor




MICROPROCESSORS LAB                                                                     65
ELECTRONICS & COMMUNICATION ENGINEERING


e) 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 words

Control word for left entry 8bit character display

    D7         D6         D5         D4      D3      D2        D1       D0
    0          0          0          0       1       0         0        1


                                                                          =:09H

Clock dividing factor

    D7         D6         D5         D4      D3      D2        D1       D0
    0          0          1          1       0       0         0        1


                                                                          =31H


To clear the display

    D7         D6         D5         D4      D3      D2        D1       D0
    1          1          0          1       0       0         0        0



                                                                          =D0




MICROPROCESSORS LAB                                                               66
ELECTRONICS & COMMUNICATION ENGINEERING




Control word for 8 characters left entry mode



   D7          D6         D5         D4      D3          D2         D1           D0
   1           1          0          1       0           0          0            0


                                                                                =90H

g) Assembly Language Program before execution:


     Lable Mnemonic            Operand                  Comments
                                                        Left entry 8 bit character
              MOV              AL.09H                   display
              MOV              DX,CTRL
              OUT              DX,AL
              MOV              AL,31H                   clock dividing factor
              OUT              DX,AL
              MOV              AL,D0H                   clear display
              OUT              DX,AL
              MOV              CX,0FFFFH                wait till display is cleared
     LI:      LOOP             L1
              MOV              AL,00H                   Control word for 8 characters
              OUT              DX,AL                    Left entry mode and 8 no of
              MOV              AH,08                    Characters will be displayed
                                                        Memory pointer to store 8 no
                               DX,OFFSET                of
              MOV              ADDRESS                  Characters to be displayed
              MOV              AL,90H
              OUT              DX,AL
              MOV              AL,[BX]
                               DX,Address of the
              MOV              data word register
              OUT              DX,AL
              MOV              CX,0FFFFH
     L2:      LOOP             L2
              INC              BX
              DEC              AH
              JNZ              UP
              MOV              CX,0FFFFH
     L3:      LOOP             L3
              INT                                   3




MICROPROCESSORS LAB                                                                     67
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc
Mpmc

More Related Content

Viewers also liked

Minimum Modes and Maximum Modes of 8086 Microprocessor
Minimum Modes and Maximum Modes of 8086 MicroprocessorMinimum Modes and Maximum Modes of 8086 Microprocessor
Minimum Modes and Maximum Modes of 8086 Microprocessor
Nikhil Kumar
 
Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))
Ganesh Ram
 
Analog communication
Analog communicationAnalog communication
Analog communication
Preston King
 
Newton Raphson method for load flow analysis
Newton Raphson method for load flow analysisNewton Raphson method for load flow analysis
Newton Raphson method for load flow analysis
divyanshuprakashrock
 
Digital Communication
Digital CommunicationDigital Communication
Digital Communication
Sujina Ummar
 

Viewers also liked (20)

MPMC Unit-1
MPMC Unit-1MPMC Unit-1
MPMC Unit-1
 
Exp 3 (1)3. To Formulate YBUS Matrix By Singular Transformation.
Exp 3 (1)3.	To Formulate YBUS Matrix By Singular Transformation.Exp 3 (1)3.	To Formulate YBUS Matrix By Singular Transformation.
Exp 3 (1)3. To Formulate YBUS Matrix By Singular Transformation.
 
DSP architecture
DSP architectureDSP architecture
DSP architecture
 
8086 microprocessor lab manual
8086 microprocessor lab manual8086 microprocessor lab manual
8086 microprocessor lab manual
 
Switching theory and logic design.
Switching theory and logic design.Switching theory and logic design.
Switching theory and logic design.
 
Microprocessor chapter 9 - assembly language programming
Microprocessor  chapter 9 - assembly language programmingMicroprocessor  chapter 9 - assembly language programming
Microprocessor chapter 9 - assembly language programming
 
Digital Communication 1
Digital Communication 1Digital Communication 1
Digital Communication 1
 
8051 full ppt
8051 full ppt8051 full ppt
8051 full ppt
 
Ppt of analog communication
Ppt of analog communicationPpt of analog communication
Ppt of analog communication
 
Minimum Modes and Maximum Modes of 8086 Microprocessor
Minimum Modes and Maximum Modes of 8086 MicroprocessorMinimum Modes and Maximum Modes of 8086 Microprocessor
Minimum Modes and Maximum Modes of 8086 Microprocessor
 
Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))
 
Instruction set of 8085
Instruction set  of 8085Instruction set  of 8085
Instruction set of 8085
 
STLD-Combinational logic design
STLD-Combinational  logic design STLD-Combinational  logic design
STLD-Combinational logic design
 
Dsp ppt
Dsp pptDsp ppt
Dsp ppt
 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
 
Analog communication
Analog communicationAnalog communication
Analog communication
 
Digital Communication ppt
Digital Communication pptDigital Communication ppt
Digital Communication ppt
 
8086 microprocessor
8086 microprocessor8086 microprocessor
8086 microprocessor
 
Newton Raphson method for load flow analysis
Newton Raphson method for load flow analysisNewton Raphson method for load flow analysis
Newton Raphson method for load flow analysis
 
Digital Communication
Digital CommunicationDigital Communication
Digital Communication
 

Similar to Mpmc

Debug tutorial
Debug tutorialDebug tutorial
Debug tutorial
Defri N
 
Programming content
Programming contentProgramming content
Programming content
Bazlin Ahmad
 

Similar to Mpmc (20)

Debug tutorial
Debug tutorialDebug tutorial
Debug tutorial
 
Qbasic tutorial
Qbasic tutorialQbasic tutorial
Qbasic tutorial
 
Introduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic TutorialIntroduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic Tutorial
 
Mp lab manual
Mp lab manualMp lab manual
Mp lab manual
 
Lecture 06 assembler
Lecture 06 assemblerLecture 06 assembler
Lecture 06 assembler
 
Introduction to Matlab for Engineering Students.pdf
Introduction to Matlab for Engineering Students.pdfIntroduction to Matlab for Engineering Students.pdf
Introduction to Matlab for Engineering Students.pdf
 
Assembly Language Programming
Assembly Language ProgrammingAssembly Language Programming
Assembly Language Programming
 
Bsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageBsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c language
 
Diploma ii cfpc u-1 introduction to c language
Diploma ii  cfpc u-1 introduction to c languageDiploma ii  cfpc u-1 introduction to c language
Diploma ii cfpc u-1 introduction to c language
 
Mca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c languageMca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c language
 
Machine language
Machine languageMachine language
Machine language
 
Btech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageBtech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c language
 
introduction to c language
 introduction to c language introduction to c language
introduction to c language
 
Programming content
Programming contentProgramming content
Programming content
 
01 Database Management (re-uploaded)
01 Database Management (re-uploaded)01 Database Management (re-uploaded)
01 Database Management (re-uploaded)
 
Ppt on visual basics
Ppt on visual basicsPpt on visual basics
Ppt on visual basics
 
Computer programming k 12
Computer programming k 12Computer programming k 12
Computer programming k 12
 
Qbasic introduction
Qbasic introductionQbasic introduction
Qbasic introduction
 
Into To Solve Problem And Computer Programming
Into To Solve Problem And Computer ProgrammingInto To Solve Problem And Computer Programming
Into To Solve Problem And Computer Programming
 
Programming for problem solving ppts unit 1
Programming for problem solving ppts unit 1Programming for problem solving ppts unit 1
Programming for problem solving ppts unit 1
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Mpmc

  • 1. ELECTRONICS & COMMUNICATION ENGINEERING 1. Introduction to MASM Introduction: The aim of this experiment is to introduce the student to assembly language programming and the use of the tools that he will need throughout the lab experiments. This first experiment let the student use the Dos Debugger and the Microsoft Macro Assembler (MASM). Editing, Assembling, Linking, Execute up can be done using MASM software Objectives: 1. Introduction to Microsoft Macro Assembler (MASM) 2. General structure of an assembly language program 3. Use of the Dos Debugger program Overview: In general, programming of microprocessor usually takes several iterations before the right sequence of machine code instruction is written. The process, however is facilitated using a special program called an “Assembler”. The Assembler allows the user to write alphanumeric instructions. The Assembler, in turn, generates the desired 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 Phases MICROPROCESSORS LAB 1
  • 2. ELECTRONICS & COMMUNICATION ENGINEERING Assembling the program: The assembler is used to convert the assembly language instructions to machine code. It is used immediately after writing the Assembly language program. The assembler starts by checking the syntax or validity of the structure of each instruction in the source file .if any errors are found, the assemblers displays a report on these errors along with brief explanation of their nature. However If the program does contain any errors ,the assembler produces an object file that has the same name as the original file but with the “obj” extension Linking the program: The Linker is used convert the object file to an executable file. The executable file is the final set of machine code instructions that can directly be executed by the microprocessor. 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 long program. This segment can not operate by itself, and must be integrated with other object files representing the rest of the program ,in order to produce the final self- contained executable file In 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 program Executing the program The executable contains the machine language code .it can be loaded in the RAM and executed by the microprocessor simply by typing ,from the DOS prompt ,the name of the file followed by the carriage Return Key (Enter Key). If the program produces an output on the screen or sequence of control signals to control a piece of hard ware, the effect should be noticed almost immediately.However,if the program manipulates data in memory, nothing would seem to have happened as a result of executing the program. MICROPROCESSORS LAB 2
  • 3. ELECTRONICS & COMMUNICATION ENGINEERING Debugging the program The debugger can also be used to find logical errors in the program. Even if a program does not contain syntax errors it may not produce the desired results after execution. Logical errors may be found by tracing the action of the program. once found, the source file should be rewrite to fix the problem, then the re-assembled and re-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 stepping through the program or executing the program up to a desired point, called break point. It also allows the user to inspect or change the contents of the microprocessor internal 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 the capability to trace logical errors in executable file. It allows the user to take an existing executable file and unassembled it,i.e convert it to assembly language.Also,it allows the user to write assembly language instructions directly, and then convert them to machine language. The program is simple and easy to use. But offers limited capabilities, which make it unsuitable for serious assembly language 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. 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 by Microsoft Corporation for professional software developers. it consists of an editor, an assembler, a linker and a debugger(Code View). The programmer’s workbench combines these four parts into a user-friendly programming environment with built in on 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 phases MICROPROCESSORS LAB 4
  • 5. ELECTRONICS & COMMUNICATION ENGINEERING Procedure 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 ENTER MICROPROCESSORS LAB 5
  • 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 HLT For the above sample program we have to enter the data into memory locations. For that the procedure is given below Step1: Type the sample program by using the above procedure. Step2: Then type ‘e’ 2000 (← address of the memory location) Step3: Then press ENTER MICROPROCESSORS LAB 6
  • 7. ELECTRONICS & COMMUNICATION ENGINEERING Step4: 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. ELECTRONICS & COMMUNICATION ENGINEERING Procedure 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. ELECTRONICS & COMMUNICATION ENGINEERING 2. Arithmetic Operation: Addition a) 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). --1 c) Algorithm: Step1: load CL with 03 Step2 : Initialize the source Index Step3: Initialize the AL with ‘00’ Step4: Add the contents of the AL with the contents of the SI and the result is stored in AL Step5: Increment SI Step6: Decrement the content in CL Step7: If CL is not equal to zero, go to step4 Step8: Store the contents of the Al into any memory location. Step9: Stop d) 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 00 UP 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 program MICROPROCESSORS LAB 9
  • 10. ELECTRONICS & COMMUNICATION ENGINEERING e) Expected results: Input: 10h Output: 60H 20h 30h f)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 HLT g) Results: Input : output: Address data Address data 2000: 10h 3000: 60H 2001: 20h 2002: 30h CL : 03h AL: 00h h) 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. ELECTRONICS & COMMUNICATION ENGINEERING 2. Arithmetic Operation: Multibyte addition a) 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). -- 1 c) Algorithm: Step1: Load BX with 1230 Step2: Load SI with Specific offset value Step3: 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 Step4: Add the contents of BX, SI with Displacement and load the content in DX Step5: Repeat Step4 Step6: Add the contents of BX, SI with Displacement and load the content in DX Also carry Step7: Initialize CX register Step8: Add with carry Step9: Load BX with 1440 Step10: the contents of Ax loaded with memory location whose address is specified by sum of BX and SI Step11: the contents of DX loaded with memory location whose address is specified by sum of BX and SI with Displacement and load the content in DX Step12: Add the contents of BX, SI with Displacement and load the content in DX Step13: Stop MICROPROCESSORS LAB 11
  • 12. ELECTRONICS & COMMUNICATION ENGINEERING d) 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 program e) Expected results :Input: 12 32 12 32: 1st number 23 21 23 21: 2nd number Output : 35 53 35 53 h MICROPROCESSORS LAB 12
  • 13. ELECTRONICS & COMMUNICATION ENGINEERING f) 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 HLT g) Results: Input: Output Address Data Address Data 1232: 32 1442: 53 1233 12 1443: 35 1234: 34 1444: 53 1235: 12 1445: 35 1236: 21 1446: 00 1237: 23 1238: 21 1239: 23 h) 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 effected MICROPROCESSORS LAB 13
  • 14. ELECTRONICS & COMMUNICATION ENGINEERING 2. Arithmetic Operation: Subtraction a) 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). --2 c) 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 program e) Expected result: Input: 30 _ 20 _______________ 10 _______________ MICROPROCESSORS LAB 14
  • 15. ELECTRONICS & COMMUNICATION ENGINEERING f) 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 HLT g) Results: Input: Output: Address Data Address Data 2000: 30 2001: 20 3000: 10 h) 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 effected MICROPROCESSORS LAB 15
  • 16. ELECTRONICS & COMMUNICATION ENGINEERING 2. Arithmetic Operation: Multiplication a) 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. ELECTRONICS & COMMUNICATION ENGINEERING d) 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 program e) Expected results Numbers are : 65h & 2A h Output/Result: 2B20 MICROPROCESSORS LAB 17
  • 18. ELECTRONICS & COMMUNICATION ENGINEERING f) 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 HLT g) Results: Input Output Address data address data 1050: 2A h 1052: 20h 1051: 65h 1053: 2Bh h) 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 effected ii)what is the difference between MOV DX,[1050],MOV DX,1050? A: MOV DX,[1050]; the contents of memory location whose address 1050 moved to DL register,1,1051 contents moved to DH register MOV DX,[1050];50h moved to DL register 10h moved to DH register MICROPROCESSORS LAB 18
  • 19. ELECTRONICS & COMMUNICATION ENGINEERING 2. 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). ---1 c) 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 program d) 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 program MICROPROCESSORS LAB 19
  • 20. ELECTRONICS & COMMUNICATION ENGINEERING e) Expected results: Input Output Data Data E4 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 HLT g) Results: Input Output Address Data Address Data 2000: E4 h (Decimal no is-28) 3000: C6h (Decimal no is - 1652) 2001: 3Bh (Decimal no is +59) 3001: 03h h) 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 Registers MICROPROCESSORS LAB 20
  • 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). ---1 c) 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 program d) 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 program MICROPROCESSORS LAB 21
  • 22. ELECTRONICS & COMMUNICATION ENGINEERING e) Expected results: Input Output: Data Data: 00E4/02 00F2 f) 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 HLT g) Results: Input Output Address Data Address Data 2000: E4 3000: F2 2001: 00 3001: 00 2002: 02 h)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 -127 MICROPROCESSORS LAB 22
  • 23. ELECTRONICS & COMMUNICATION ENGINEERING 2. Arithmetic Operation: ASCII addition a) Aim: Write an Assembly Language Program to perform the ASCII addition. b) Appartus/Software:1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1 c) Algorithm: Step-1: Initialize the AH with 00 Step-2: Initialize the source Index Step-3: Load the contents of the AL with contents of the SI Step-4: Increment the SI Step-5: Load the contents of the SI ti the BL Step-6Add AL and BL Step-7: Move the result from the accumulator to the memory location Step-8: End of the program d) 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 program MICROPROCESSORS LAB 23
  • 24. ELECTRONICS & COMMUNICATION ENGINEERING e) Expected results Input Output Address Data Address Data 2000: 05 3000: 04 2001: 09 3001: 01 f) 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 HLT g) Results: Input Output Address Data Address Data 2000: 05 3000: 04 2001: 09 3001: 01 h) Viva- Voice: 1. Difference between CMPS&SCAS instruction 2. Difference between AAA&DAA instruction MICROPROCESSORS LAB 24
  • 25. ELECTRONICS & COMMUNICATION ENGINEERING 2. Arithmetic Operation: ASCII Multiplication a) Aim: Write an Assembly Language Program to perform the ASCII multiplication. b) Appartus/Software:1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1 c) Algorithm: Step-1: Initialize the AH with 00 Step-2: Initialize the source Index Step-3: Load the contents of the AL with contents of the SI Step-4: Increment the SI Step-5: Load the contents of the SI to the BH Step-6: Multiply the contents of the BH with AL and result is stored in AX Step-7OR the contents of AX with 3030 Step-8: Move the result from the accumulator to the memory location Step-9: End of the program d) 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 program MICROPROCESSORS LAB 25
  • 26. ELECTRONICS & COMMUNICATION ENGINEERING e) Expected results: Input Output 09*05 3435 f) 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 HLT g) Results: Input Output Address Data Address Data 2000: 09 5000: 35 2001: 05 5001: 34 MICROPROCESSORS LAB 26
  • 27. ELECTRONICS & COMMUNICATION ENGINEERING 3. Logical Operation: shift right operation a) 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). ---1 c) Algorithm: Step-1: Initialize the AH with 00 Step-2: Initialize the source Index Step-3: Load the contents of the AL with contents of the SI Step-4: Shift the contents of the accumulator to the to the right by 1 Step-5:If there is barrow increment AH Step-6: Otherwise load the contents of the AL to the memory location Step-7: End of the program d) 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 program MICROPROCESSORS LAB 27
  • 28. ELECTRONICS & COMMUNICATION ENGINEERING e) Expected results: Input Output Data Data 27 93 f) 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 HLT g) Results: Input Output Address Data Address Data 3050: 71 4000: 93 h) 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. ELECTRONICS & COMMUNICATION ENGINEERING 3. Logical Operation: shift left operation a) 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). ---1 c)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: End d) 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 program MICROPROCESSORS LAB 29
  • 30. ELECTRONICS & COMMUNICATION ENGINEERING e) Expected results: Input Output Address Data Address Data 2000: C3 5000: 86 2001: E5 5001: CB f) 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 HLT g) Results: Input Output Address Data Address Data 2000: C3 5000: 86 2001: E5 5001: CB h) 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 20bit MICROPROCESSORS LAB 30
  • 31. ELECTRONICS & COMMUNICATION ENGINEERING 3. Logical Operation: Packed BCD to Unpacked BCD a) 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). ---1 c) 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. ELECTRONICS & COMMUNICATION ENGINEERING d) 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 program MICROPROCESSORS LAB 32
  • 33. ELECTRONICS & COMMUNICATION ENGINEERING e) Expected results: Input Output Data Data 78 08 07 f) 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 HLT g) Results: Input Output Address Data Address Data 2000: 87 3000: 07 3001: 08 h) 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 mode MICROPROCESSORS LAB 33
  • 34. ELECTRONICS & COMMUNICATION ENGINEERING 3. Operation: Packed BCD to ASCII a) Aim: - Write an Assembly Language Program in 8086 to convert packed BCD to ASCII. b) Appartus/Software:1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1 c) 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 program MICROPROCESSORS LAB 34
  • 35. ELECTRONICS & COMMUNICATION ENGINEERING d) 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 program e) Expected results: Input Output Data Data 78 38 37 MICROPROCESSORS LAB 35
  • 36. ELECTRONICS & COMMUNICATION ENGINEERING f) 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 101C g) Results: Input Output Address Data Address Data 2000: 87 3000: 37 3001: 38 MICROPROCESSORS LAB 36
  • 37. ELECTRONICS & COMMUNICATION ENGINEERING 4. String Operation: Length of the string a) Aim:- Write an Assembly Language Program in 8086 to find the length of given string, and string ended with 00h. b) Appartus/Software: 1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1 c) 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 program d) 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 program MICROPROCESSORS LAB 37
  • 38. ELECTRONICS & COMMUNICATION ENGINEERING e) Expected results: Input Output 58 07 59 61 62 63 64 65 00 All the data in Hexadecimal system f) 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 HLT MICROPROCESSORS LAB 38
  • 39. ELECTRONICS & COMMUNICATION ENGINEERING g) Results: Input Output Address data Address data 1050: 76 1075: 07 1051: 59 1052: 69 1053: 62 1054: 64 1055: 65 1056: 33 1057: 00 H) 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: address MICROPROCESSORS LAB 39
  • 40. ELECTRONICS & COMMUNICATION ENGINEERING 4. String Operation: Reverse order a) 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). ---1 c) 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. ELECTRONICS & COMMUNICATION ENGINEERING d) 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 program MICROPROCESSORS LAB 41
  • 42. ELECTRONICS & COMMUNICATION ENGINEERING e) Expected results: Input Output Address Data Address Data 2070: 04 2050: 09 2050: 06 2051: 08 2051: 07 2052 07 2052: 08 2053: 06 2053: 09 f) 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 HLT MICROPROCESSORS LAB 42
  • 43. ELECTRONICS & COMMUNICATION ENGINEERING g) Results: Input Output Address Data Address Data 2070: 04 2050: 09 2050: 06 2051: 08 2051: 07 2052 07 2052: 08 2053: 06 2053: 09 H) 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 register MICROPROCESSORS LAB 43
  • 44. ELECTRONICS & COMMUNICATION ENGINEERING 4. String Operation: Delete a) 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). -- 1 c) 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 Program MICROPROCESSORS LAB 44
  • 45. ELECTRONICS & COMMUNICATION ENGINEERING e) Expected result: Input Output 10h 10h 20h 30h 30h 40h 40h 01h f) 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 HLT MICROPROCESSORS LAB 45
  • 46. ELECTRONICS & COMMUNICATION ENGINEERING g) Results: Input Output Address Data Address Data 2000: 10H 2000: 10H 2001: 20H 2001: 30H 2002: 30H 2002: 40H 2003: 40H 3000: 01H h) Viva –Voice: i) What are the flags effected after executing ADD SI,DX instruction? A: C,Z,AF,S,P flags MICROPROCESSORS LAB 46
  • 47. ELECTRONICS & COMMUNICATION ENGINEERING 4. String Operation: Insert a) 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). --1 c)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 zero MICROPROCESSORS LAB 47
  • 48. ELECTRONICS & COMMUNICATION ENGINEERING d) 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 [program MICROPROCESSORS LAB 48
  • 49. ELECTRONICS & COMMUNICATION ENGINEERING e) Expected result: Input Output 10h 10h 20h 20h 30h 30h 50h 40h 02h 50h 30h f) 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 HLT MICROPROCESSORS LAB 49
  • 50. ELECTRONICS & COMMUNICATION ENGINEERING g) Results: Input Output: Address Data Address Data 2000: 10h 2000: 10h 2001: 20h 2001: 20h 2002: 30h 2002: 30h 2003: 50h 2003: 40h 3000: 02h 2004: 50h 3001: 30h H) 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 register MICROPROCESSORS LAB 50
  • 51. ELECTRONICS & COMMUNICATION ENGINEERING 4. Operation: sorting a) 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). ---1 c) 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 to Step5: Get the next word into DX, and repeat the steps 3 and 4 until the count register is zero. Step6: Load the final maximum 16 bit number which is at AX into memory location. MICROPROCESSORS LAB 51
  • 52. ELECTRONICS & COMMUNICATION ENGINEERING d) 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 HLT e) Expected results: Input Output Data Data 3003,3032,9030,0083 9030 MICROPROCESSORS LAB 52
  • 53. ELECTRONICS & COMMUNICATION ENGINEERING f) 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 HLT g) Results: Input Output Address Data Address Data 1000: 03 1001: 30 1002: 32 1003: 30 1004: 90 1005: 83 1006: 00 H) Viva –Voice: 1.What is the addressing mode of MOV [BX+DI], AX A.Base plus Index addressing mode MICROPROCESSORS LAB 53
  • 54. ELECTRONICS & COMMUNICATION ENGINEERING 4. String Operation: Move block a) 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). ---1 c) 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 program MICROPROCESSORS LAB 54
  • 55. ELECTRONICS & COMMUNICATION ENGINEERING e) Expected results: Input Output Address Data Address Data 2000: 05 2050: 01 2001: 01 2051: 02 2002: 02 2052: 03 2003: 03 2053: 04 2004: 04 2054: 05 2005: 05 f) 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 HLT g) Results: Input Output Address Data Address Data 2000: 05 2050: 01 2001: 01 2051: 02 2002: 02 2052: 03 2003: 03 2053: 04 2004: 04 2054: 05 2005: 05 H) Viva- Voice: 1. What is the purpose of REP instruction? A. Repeat the set of instructions until CX becomes zero MICROPROCESSORS LAB 55
  • 56. ELECTRONICS & COMMUNICATION ENGINEERING 5.Dos / Bios Programming a) Aim: write an Assembly language program Reading Key board with ECHO b)Appartus/Software:1. 8086 microprocessor kit/MASM---1 2. RPS (+5V). ---1 c) 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 also d) 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 also MICROPROCESSORS LAB 56
  • 57. ELECTRONICS & COMMUNICATION ENGINEERING f) 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 21H ii) Reading Keyboard without ECHO Mnemonic Operand Comments Read keyboard MOV AH,08 echo INT 21 iii) Video Display Output Mnemonic Operand Comments MOV DL,0D MOV AH,02 INT 21 g) Results: Input Output Key pressed asdfg;lkjh h) 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 hardware MICROPROCESSORS LAB 57
  • 58. ELECTRONICS & COMMUNICATION ENGINEERING II. Interfacing: 1. Intel 8259 : Interrupt Generation a) 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,4 MICROPROCESSORS LAB 58
  • 59. ELECTRONICS & COMMUNICATION ENGINEERING LEA AX,CS:SERV4 MOV [BX],AX ADD BX,4 LEA AX,CS:SERV5 MOV [BX],AX LABEL 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 STI BCK: JMP BCK SERV1: MOV DI,080H MOV SI,OFFSET MSG1 CALL FAR OP MICROPROCESSORS LAB 59
  • 60. ELECTRONICS & COMMUNICATION ENGINEERING STI IRET SERV2: MOV DI,080H MOV SI,OFFSET MSG2 CALL FAR OP LABEL MNEMONIC OPERAND STI IRET SERV3: MOV DI,080H MOV SI,OFFSET MSG3 CALL FAR OP STI IRET SERV4: MOV DI,080H MOV SI,OFFSET MSG4 CALL FAR OP STI IRE SERV5: MOV DI,080H MOV SI,OFFSET MSG5 CALL FAR OP STI IRET SERV6: MOV DI,080H MOV SI,OFFSET MSG6 CALL FAR OP STI IRET ORG 0:6030H SERV7: MOV DI,080H MOV SI,OFFSET MSG7 CALL FAR OP STI IRET SERV8: MOV DI,080H MICROPROCESSORS LAB 60
  • 61. ELECTRONICS & COMMUNICATION ENGINEERING MOV SI,OFFSET MSG8 CALL FAR OP STI CSEG ENDS ENDS d) 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],AX MICROPROCESSORS LAB 61
  • 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 STI MICROPROCESSORS LAB 62
  • 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 IRET MICROPROCESSORS LAB 63
  • 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 ENDS e) Observations: After executing the above program The message 8259 displayed on the address on the address field of the kit Once the interrupt acknowledge is received displays FE on the data field of the kit For interrupt no ’0’. MICROPROCESSORS LAB 64
  • 65. ELECTRONICS & COMMUNICATION ENGINEERING 2 .8279 Key board display a) Aim: Write an ALP in 8086 to display string of characters from left to right (left entry mode) in output mode. b) Apparatus: 8086 microprocessor kit i. Intel 8279 interfacing module ii. +5v D C supply iii. Serial port communication cable c) Specifications: Keyboard and display interface module must be connected to 8086 microprocessor kit through a 50 pin connecter. d) Description of module: Intel 8279 is a general purpose programmable keyboard and display interface I/O device .A keyboard portion can provide scanned interface to a 64 contact key matrix. Key board entries are debounced and strobed in an 8-character FIFO. The display portion provides a scanned display interface for LED .It has 16*8 display Ram which can be organized into a dual 16*4.Both right entry and left entry display formats are possible. Circuit Diagram Fig: Inter facing Key boardmodule to 8086 Microprocessor MICROPROCESSORS LAB 65
  • 66. ELECTRONICS & COMMUNICATION ENGINEERING e) 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 words Control word for left entry 8bit character display D7 D6 D5 D4 D3 D2 D1 D0 0 0 0 0 1 0 0 1 =:09H Clock dividing factor D7 D6 D5 D4 D3 D2 D1 D0 0 0 1 1 0 0 0 1 =31H To clear the display D7 D6 D5 D4 D3 D2 D1 D0 1 1 0 1 0 0 0 0 =D0 MICROPROCESSORS LAB 66
  • 67. ELECTRONICS & COMMUNICATION ENGINEERING Control word for 8 characters left entry mode D7 D6 D5 D4 D3 D2 D1 D0 1 1 0 1 0 0 0 0 =90H g) Assembly Language Program before execution: Lable Mnemonic Operand Comments Left entry 8 bit character MOV AL.09H display MOV DX,CTRL OUT DX,AL MOV AL,31H clock dividing factor OUT DX,AL MOV AL,D0H clear display OUT DX,AL MOV CX,0FFFFH wait till display is cleared LI: LOOP L1 MOV AL,00H Control word for 8 characters OUT DX,AL Left entry mode and 8 no of MOV AH,08 Characters will be displayed Memory pointer to store 8 no DX,OFFSET of MOV ADDRESS Characters to be displayed MOV AL,90H OUT DX,AL MOV AL,[BX] DX,Address of the MOV data word register OUT DX,AL MOV CX,0FFFFH L2: LOOP L2 INC BX DEC AH JNZ UP MOV CX,0FFFFH L3: LOOP L3 INT 3 MICROPROCESSORS LAB 67