MULTIPLY WITHOUT CARRY
To MULTIPLY TWO 8-BIT NUMBERS WITHOUT CARRY MP 8085A we use repetitive addition, here we can not consider CARRY, Thus Output size is 8 bit.
WRITE 8085 ASSEMBLY LANGUAGE PROGRAM TO MULTIPLY TWO 8-BIT NUMBERS STORED IN MEMORY LOCATION AND STORE THE 16-BIT RESULTS INTO THE MEMORY WITHOUT CARRY.
THEORY :
In 8085 microprocessor, there is no multiplication operation. To get the result of multiplication, we should use the repetitive addition method. After multiplying (repetitive addition) two 8bit numbers are store in the next memory location. We are saving the data at location 2000h and 2001h. The resultant value will be stored at the location in 2002h.
ALGORITHM :
Step 1: LXI H,2000h, to load the address in H-L register pair using LXI H from 16-bit location 2000h.
Step 2: MOV B, M to move the value of 2000h memory address value into the register B.
Step 3: INX H, to increase the value of the H-L register pair to get the next memory location.
Step 4: MOV C, M to move the value of the 2001h memory location to register C.
Step 5: XRA A; to make sure and turn the value of the accumulator to zero by X-OR operation.
Step 6: ADD B, for we need to perform addition with the value of accumulator with the content of B register and store the result into the accumulator.
Step 7: DCR C, To decrement the value of the C register.
Step 8: JNZ to make a loop and back to step 6.
Step 9: INX H, done to the H-L pair of the register will be increased and pointed to store the addition result.
Step 10: MOV M, A; to store the value of the accumulator into a memory location in 2002h.
Step 11: HLT; to stop the program.
IMPLEMENTATION :
Location | Mnemonics | Hex Code |
---|---|---|
3000 | LXI H | 21 |
3001 | 00 | 00 |
3002 | 20 | 20 |
3003 | MOV B,M | 46 |
3004 | INX H | 23 |
3005 | MOV C,M | 4E |
3006 | XRA A | AF |
3007 | ADD B | 80 |
3008 | DCR C | 0D |
3009 | JNZ | C2 |
300A | 07 | 07 |
300B | 30 | 30 |
300C | INX H | 23 |
300D | MOV M,A | 77 |
300E | HLT | 76 |
INPUT AND OUTPUT :
Location | Input |
---|---|
2000 | 04 |
2001 | 02 |
Location | Output |
---|---|
2002 | 08 |
DISCUSSION :
In this program, we perform multiplication by taking inputs from the user. In this case, 04h is stored at memory location 2000h and 02h at location 2001h. The drawback is that it cannot store carry value. If the result is in 18 bit with carry then it cannot store that value.
Comments
Post a Comment