8 BIT DIVISION - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Wednesday, October 27, 2010

8 BIT DIVISION

To write an assembly language program in microcontroller to perform division between two 8 bit numbers.

ALGORITHM:
1. Start the program.
2. Get the dividend (65) in accumulator.
3. Get the divisor (08) in B reg.
4. Divide the two data.
5. Move the address location to Data Pointer.
6. Store the remainder result in the Data Pointer.
7. Increment the Data Pointer.
8. Move the content of B reg (quotient) to accumulator.
9. Move the content of accumulator to the address location in DPTR.
10. Stop the program.

PROGRAM:

ADDRESS LABEL OPCODE MNEMONICS OPERAND COMMENTS
4400 74 MOV A, #Data 1 Move the dividend (65) to accumulator.
4401 65
4402 75 MOV B, #Data 2 Move the divisor (08) to B reg.
4403 F0
4404 08
4405 84 DIV A,B Dividend the content of Acc and B reg.
4406 90 MOV DPTR, #4500 Move the address location 4500 to DPTR.
4407 45
4408 00
4409 F0 MOVX @DPTR,A Move the content of accumulator to the address location (4500) in DPTR
440A A3 INC DPTR Increment the content of DPTR.
440B E5 MOV A,B Move the content of B to acc.
440C F0
440D F0 MOVX @DPTR,A Move the content of accumulator to the address location (4501) in DPTR
440E 80 HERE:SJMP HERE
440F FE
INPUT:
4401: 65 4404: 08
OUTPUT:
4500: 0C
4501: 00

No comments:

Post a Comment