Experiment Number 2

AIM :Write a program to multiply two 8 bit numbers by repetitive addition method using 8086

Objective:

After completing this experiment, students will be able to :

  1. understand opcode and mnemonic of the program
  2. Draw the flowchart of the program
  3. Write the algorithm of the program to multiply two 8-bit numbers
  4. Write the program to multiply two numbers
  5. Run and debug the program

System Requirement:

  • 8086 Trainer Kit with Key Board

Setting up the Trainer Kit:

  • Ensure that standard IBM PC/AT system keyboard is connected
  • System is Powered ON
  • Student has a handy opcode table for programming

Flow Chart:

Figure: 2.1 Flowchart to multiply two numbers

Logic / Algorithm

  1. Start
  2. Initialize the CL register to store the multiplier, clear accumulator (AL) and register BL and SI and DI register
  3. Read the contents of the memory pointer by SI register in register CL (multiplier)
  4. Increment the SI register.
  5. Add accumulator with carry with the content pointed by SI
  6. Increment the SI register content
  7. Decrement counter (CL)
  8. If not zero, goto step 5
  9. If NO carry goto step 11
  10. Store result at location pointed by DI
  11. Increment BL
  12. Increment DI
  13. Save carry at location pointed by DI
  14. Stop

Explanation of the Code:

Program Address Op-Code Label Mnemonic Comment
1000: 0200 F8 CLC ;Clear the Carry Flag
1000: 0201 BE 1300 MOV SI, 1300h ;load SI with address of multiplier
1000:0204 BF 1302 MOV DI, 1302h ;Load DI with address for storing result
1000:0207 B8 0000 MOV AX, 0000H ;Clear accumulator
1000:020A B3 00 MOV BL, 00H ;Clear BL to store carry
 1000:020C 8A 0C MOV CL, [SI] ;Read multiplier into CL register
 1000:020E 46 INC SI ;increment the source pointer to point to multiplicand
 1000:020F 12 04 AGAIN: ADC AL, [SI] ;Add Accumulator with multiplicand
 1000:0211 FE C9  DEC CL ;Decrement after addition
 1000:0213 75 FA  JNZ AGAIN ;Repeat if not zero
 1000:0215 73 02  JNC SAVE ;Check if carry and Jump to Save on NO Carry
1000:0217 FE C3 INC BL ;increment BL register to account for carry
 1000:0219 88 05  SAVE: MOV [DI], AL ;Save Product into Destination memory
 1000:021B 47 INC DI ;Increment destination address
 1000:021C 88 1D MOV [DI], BL ;Save Carry
1000:021E F4 HLT ;Stop

 

Execution :

Address Map for DATA

Data Segment Address DATA
Multiplier Segment  : Offset: 0000 : 1300
Multiplicand Segment  : Offset: 0000 : 1301

Executing The Program

Key Pressed/Action Display on LCD
Press G  from Keyboard BURST or Single Step
Press Enter Segm_Adr
0000 Press Enter Ofst
0200 Press Enter Wait

Cmd_Wrd=

 

Do not press the Reset Key; Check the result by using ub_Mir Command

Verification of Result

DATA Multiplicand Multiplier
             1st Data
Address SegAdr: 0000 Ofst : 1301 Ofst : 1300

 

Result Carry Product
 

 

Address SegAdr: 0000 Ofst : 1303 Ofst : 1302

Viva Question

Q.1.  What is purpose of CX (CH, CL) Register?

Answer :

  1. CX register in 8086 is a general purpose register used to hold 16-bit data
  2. CX register is also used a counter register for applications requiring execution of LOOP for repeated operation

Q.2. How is the carry checked

Answer: 8086 microprocessor has a JNC/ JC statements to check the status of the carry flag. The control of the statement can be transferred to any location by the use of JNC or JC. In this experiment we used JNC SAVE to jump to location SAVE when there is no carry as a result of addition. If the statement becomes false on execution then the immediate next instruction (inc BL in this experiment) is executed.

Q.3. Explain how the multiplication of two numbers can be obtained by addition operation

Answer: Multiplication in fact the repeated operation of addition. For this purpose we set the counter value with multiplier and add the multiplicand with itself number of times as given by multiplier.

 

Updated: April 27, 2019 — 1:53 pm

Leave a Reply

Your email address will not be published. Required fields are marked *

care4you © 2014 care4you © Revision-1: 2016 care4you © Revision-2: 2019 Connect On Facebook DMCA.com Protection Status
error: Content is protected !!