Skip to main content

8 bit addition in all addressing modes

Aim: 

Write an assembly language program to perform two 8 bit numbers addition using immediate, direct, indirect and register addressing modes.

Apparatus:

A computer loaded with Keil or edsim51.

Program:

Immediate mode:

ORG 0000H
LJMP MAIN
MAIN:
MOV A,#50H
ADD A,#30H
END

Note: Observe 'Acc' for the result.

Direct mode:

ORG 0000H
LJMP MAIN
MAIN:
MOV 40H,#50H
MOV A,#30H
ADD A,40H
END

Note: Observe 'Acc' for the result.

Indirect mode:

ORG 0000H
LJMP MAIN
MAIN:
MOV 40H,#50H
MOV 41H,#30H
MOV R0,#40H
MOV R1,#41H
MOV A,@R0
MOV B,@R1
ADD A,B
END

Note: Observe 40H, 41H locations, R0, R1 registers and A, B for intermediate results.

Observe 'Acc' for the final result.

Register mode:

ORG 0000H
LJMP MAIN
MAIN:
MOV 40H,#50H
MOV 41H,#30H
MOV A,40H
MOV R0,41H
ADD A,R0
END


Note: Observe 40H, 41H locations, R0 register and A for intermediate results.

Observe 'Acc' for the final result.

Result:

Performed 8-bit addition using all addressing modes.


    In the same way, we can program for 8-bit subtraction, multiplication, division using SUB, MUL, DIV instructions.

Comments