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

Popular posts from this blog

Learning about 8051 simulator like keil micro-vision.

Aim:  To study about Keil simulator. Apparatus:  A computer loaded with Keil Microvision2 or higher version. Procedure:                         If we want to develop embedded system program for 8051 using Keil software, we need to follow these steps.    1. Create work directory. 2. Create a new project. 3. Create source files(.alp or .c). 4. Add files to project. 5. Compilation and error checking. 6. Debugging and output verification. 7. Creation of HEX file. 8. Burn the project(HEX file) into ROM of the target device. 1. Create work directory: Go to my computer. Open local disk: D. Create a new folder. Rename with the desired name. That is our work directory.  2.Create a new project:     Go to project menu in Keil. Select new project.     Click on Atmel. Select AT89C51 or AT89C52 or AT89S51 or AT89S52. Select ok. Next press yes. NOTE:  Give the project name and work folder path properly.