0% found this document useful (0 votes)
13 views4 pages

Multiplication and Division

The document outlines an assembly language program for performing multiplication and division of two 8-bit numbers using the PIC16F877 microcontroller. It includes a detailed procedure for setting up the MPLAB IDE, writing the program, and verifying the results. The algorithm for both multiplication and division is provided, along with sample input and output addresses for the operations.

Uploaded by

vivekvivek662005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

Multiplication and Division

The document outlines an assembly language program for performing multiplication and division of two 8-bit numbers using the PIC16F877 microcontroller. It includes a detailed procedure for setting up the MPLAB IDE, writing the program, and verifying the results. The algorithm for both multiplication and division is provided, along with sample input and output addresses for the operations.

Uploaded by

vivekvivek662005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

MULTIPLICATION AND DIVISION OF 8 BIT NUMBERS

EX. NO: 2 DATE:

Aim:
To write an assembly language program for multiplication and division of two 8 bit
numbers in PIC16F877 microcontroller and verify the same using Microchip IDE simulation.

Apparatus Required:

Desktop computer installed with MPLAB IDE - 1 No

Procedure:

1. Switch ON the PC.


2. Open MPLAB IDE and create a new project using Project Wizard.
3. Create and save the assembly language program file with “.ASM” file extension.
4. Add the ASM file to the project.
5. Build the Code for error detection and correction.
6. Open the watch Window and add the SFR and Registers used in the program.
7. Give the inputs in input register.
8. Run the program in “step into” method and find note the result in output
register.
9. Close the MPLAB IDE.
10. Shutdown the PC.

Algorithm:

1. Multiplication:
1. Start the program
2. Initialize the Input and Output registers.
3. Clear the W register.
4. Add the multiplicand with the W-Register.
5. Decrement the multiplier by 1 and check for zero if not zero continue adding the
multiplicand with W register if zero stop adding.
6. Store the W register value in product High.
7. Check the carry flag: if set increment product low.
8. Stop the process.

2. Division:
1. Start the program
2. Initialize the Input and Output registers.
3. Clear the W register.
4. Load the divider to the W-Register.
5. Subtract the divider from the dividend value.
6. Increment the quotient value by 1.
7. Store the dividend to get remainder.
8. Check the carry flag : if it is 0continue subtracting the value of W reg from
dividend.
9. If the carry flag is 1 then terminate the subtraction loop.
10. Stop the process.

4
PROGRAM:

1. Multiplication:

LABLE MNEMONICS COMMENT


#INCLUDE<P16F877A.INC> ; include the PIC header file
LIST P=16F877A ; add the list file of PIC16F877A
ORG 00 ; Initialize the origin of the program memory
DATA1 EQU 70 ; equate location 70 the DATA1
DATA2 EQU 71 ; equate location 71 to DATA 2
PRO_L EQU 72 ; equate location 72 to Product Low byte
PRO_H EQU 73 ; equate location 73 to product High byte
GOTO MAIN ; Goto main program
ORG 30 ; initialize the starting address of the code
MAIN MOVLW 00 ; load W-Reg with 00H
; ADD W-Reg with DATA1 and store the result in W-
LOOP ADDWF DATA1,0
Reg
DECFSZ DATA2,1 ; check the file register for 0 and skip
GOTO LOOP ; continue the addition process
BTFSS STATUS,0 ; check the carry for set to identify the higher byte
GOTO LOOP1 ;if no carry goto loop1
INCF PRO_H,1 ; increment higher byte of the product
LOOP1 MOVWF PRO_L ;load the lower byte from W reg
HLT GOTO HLT ; Stop Here
END ;End

5
2. Division:

LABLE MNEMONICS COMMENT


#INCLUDE<P16F877A.INC> ; include the PIC header file
LIST P=16F877A ; add the list file of PIC16F877A
ORG 00 ; Initialize the origin of the program memory
DIVIDENT EQU 40 ; equate location 40 the DIVIDENT
DIVIDER EQU 41 ; equate location 41 to DIVIDER
QUOTIENT EQU 42 ; equate location 42 to QUOTIENT
REMAINDER EQU 43 ; equate location 43 to REMAINDER
GOTO MAIN ; Goto main program
ORG 30 ; initialize the starting address of the code
MAIN MOVLW 00 ; load W-Reg with 00h
LOOP MOVF DIVIDER,0 ; Move the divider to W-Reg
SUBWF DIVIDENT,1 ; Subtract the DIVIDENT value by W-Reg
BTFSS STATUS,0 ; Check the Carry Flag for set condition
GOTO HLT ; goto HLT location
INCF QUOTIENT,1 ;Increment the Quotient
MOVF DIVIDENT,0 ;store the reminder in W-Reg
MOVWF REMAINDER ; Store the Remainder value from W-register
GOTO LOOP ; goto LOOP for continue subtraction
HLT GOTO HLT ;halt here
END ; End of the program

6
SAMPLE INPUT AND OUTPUT:

1. Multiplication:

ADDRESS DATA
DATA1 (70)
DATA2 (71)
PRO_L (72)
PRO_H (73)

2. Division:

ADDRESS DATA
DIVIDENT (40)
DIVIDER (41)
QUOTIENT (42)
REMAINDER(43)

RESULT:
Thus the assembly language program for multiplication and division of two 8-bit
numbers were written and its outputs were verifier using MPLAB IDE simulator.

You might also like