ADDITION OF TWO 8 BIT NUMBERS

AIM:
To perform addition of two 8 bit numbers using 8085.

ALGORITHM:
1) Start the program by loading the first data into Accumulator.
2) Move the data to a register (B register).
3) Get the second data and load into Accumulator.
4) Add the two register contents.
5) Check for carry.
6) Store the value of sum and carry in memory location.
7) Terminate the program.

PROGRAM:
MVI C, 00 'Initialize C register to 00
LDA 4150 'Load the value to Accumulator.
MOV B, A 'Move the content of Accumulator to B register.
LDA 4151 'Load the value to Accumulator.
ADD B 'Add the value of register B to A
JNC LOOP 'Jump on no carry.
INR C 'Increment value of register C
LOOP: STA 4152 'Store the value of Accumulator (SUM).
MOV A, C 'Move content of register C to Acc.
STA 4153 'Store the value of Accumulator (CARRY)
HLT 'Halt the program.

OBSERVATION:
Input: 80 (4150)
80 (4251)
Output: 00 (4152)
01 (4153)

RESULT:
Thus the program to add two 8-bit numbers was executed.

10 comments:

  1. Super amazing.....thank u Google

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. i m getting error can someone help me out to correct this code
    LDA 0000H ;LOAD ACCUMULATOR WITH 000H CONTENT EX:02
    MOV B,A ;MOVE ACCUMULATOR CONTENT A TO B REGISTER
    LDA 0001H ;LOAD ACCUMULATOR WITH 0001H CONTENT EX:03
    ADD B ; ADDITION OF B=A+B =05

    JC LOOP1 ;JUMP IF CARRY TO LOOP1
    LOOP1:
    LDA C,00H ;INITIALIZE C WITH 00 VALUE
    INR C ;INCREMENT C
    STA 0011H ;STORE C IN 0011H ADDRESS
    MOV A,C ;MOV C TO ACCUMULATOR
    STA 0020H ;STORE VALUE OF ACCUMULATOR IN 0020H ADDRESS
    HLT

    JNC LOOP2 ;JUMP ON NO CARRY -ON LOOP2
    LOOP2:
    STA 00050H :STORE THE RESULT IN THE ADDRRESS 00050H (ADDTION OF A+B)
    HLT

    ReplyDelete