In this section we will see one Intel 8085 Microprocessor program. This program is mainly for adding multi byte numbers.
Problem Statement −
Write an 8085 Assembly language program to add two multi-byte numbers.
We are using 4-byte numbers. The numbers are stored into the memory at location 8501H and 8505H. One additional information is stored at location 8500H. In this place we are storing the byte count. The result is stored at location 85F0H.
The HL pair is storing the address of first operand bytes, the DE is storing the address of second operand bytes. C is holding the byte count. We are using stack to store the intermediate bytes of the result. After completion of the addition operation, we are popping from the stack and storing into the destination.
|F000||31, 00, 20||LXI SP,2000H||Initialize Stack Pointer|
|F003||21, 00, 85||LXI H,8500H||load memory address to get byte count|
|F006||4E||MOV C,M||load memory content into C register|
|F007||06, 00||MVI B,00H||clear B register|
|F009||21, 01, 85||LXI H, 8501H||load first argument address|
|F00C||11, 05, 85||LXI D, 8505H||load second argument address|
|F00F||1A||LOOP||LDAX D||load DE with second operand address|
|F010||8E||ADC M||Add memory content and carry with Acc|
|F011||F5||PUSH PSW||Store the accumulator content into stack|
|F012||04||INR B||increase b after pushing into stack|
|F013||23||INX H||Increase HL pair to point next address|
|F014||13||INX D||Increase DE pair to point next address|
|F015||0D||DCR C||Decrease c to while all bytes are not exhausted|
|F016||C2, 0F, F0||JNZ LOOP||When bytes are not considered, loop again|
|F019||D2, 20, F0||JNC SKIP||when carry = 0, jump to store|
|F01C||3E, 01||MVI A,01H||when carry = 1, push it into stack|
|F01E||F5||PUSH PSW||Store the accumulator content into stack|
|F01F||04||INR B||increase b after pushing into stack|
|F020||21, F0, 85||SKIP||LXI H,85F0H||load the destination pointer|
|F023||F1||L1||POP PSW||pop AF to get back bytes from stack|
|F024||77||MOV M,A||store Acc data at memory location pointed by HL|
|F025||23||INX H||Increase HL pair to point next address|
|F026||05||DCR B||Decrease B|
|F027||C2, 23, F0||JNZ L1||Go to L1 to store stack contents|
|F02A||76||HLT||Terminate the program|