Sie sind auf Seite 1von 6

Page 1 of 6

Rajarambapu Institute of Technology, Rajaramnagar.


Department of Electrical Engineering.
Lab Manual
Document No : ELE-MCA-02
Issue No./ Date : II 01/07/2005
Subject : Microcontroller and Its Application Revision No./Date : 01 02/01/2012
Ref. :Procedure RIT 7.5.1-01 Total Pages : 06

Experiment No: 1
Title: Addressing Modes of 8051 Microcontroller.
Aim: Study of Addressing Modes of C 8051.
Objective: To write a program for different addressing modes of 8051 using
Apparatus: 1] C 8051 Kit/ Keilv3.0.
2] Power Supply.
3] Keypad.
4] Connecting Leds etc.
Theory:
Addressing Mode:
Addressing modes are an aspect of the instruction set architecture in most central
processing unit (CPU) designs. The various addressing modes that are defined in a given instruction
set architecture define how machine language instructions in that architecture identify the operand
(or operands) of each instruction.
An addressing mode specifies how to calculate the effective memory address of an
operand by using information held in registers and/or constants contained within a machine
instruction or elsewhere.
I] Register Address Mode: Register addressing mode involves the use of registers to hold the data to
be manipulated.
e.q:- MOV A,R0 :- In this instruction Register R0 hold data which will be used for manipulation.

II] Immediate Addressing Mode:
In immediate addressing Mode the operand comes immediately after the op-code.
The immediate data must be preceded by the pound sign, "#".
e.q:- MOV R0,#02H :- After execution of command Data 02H will be moved to Register R0.
Page 2 of 6


III] Direct Addressing Mode:
In the direct addressing mode, the data is in a RAM memory location whose address is known,
and this address is given as a part of the instruction.
It is most often used to access RAM locations 30 - 7FH.
This is due to the fact that register bank locations are accessed by the register names of R0 - R7.
There is no such name for other RAM locations so must use direct addressing.
e.q: MOV R0,40H:- After execution of this command data which has been stored at RAM memory
location 40H will be moved to Register R0.

IV] Indirect Addressing Mode:
In indirect addressing mode, the data is in a RAM memory location whose address is specified
in blank register R0 or R1.
A register is used as a pointer to the data.
If the data is inside the CPU, only registers R0 and R 1 are used for this purpose.
R2 - R7 cannot be used to hold the address of an operand located in RAM when using indirect
addressing mode.
When RO and R 1 are used as pointers they must be preceded by the @ sign.
e.q: MOV A,@R0 After execution data will be moved from RAM memory location whose address is
stored in blank register R0.
Page 3 of 6


Procedure:
1] Connect power supply to single phase ac supply.
2] Connect Microcontroller Kit to Power supply.
3] Feed Program.
4] Check contents of program before execution.
5] Execute program.
6] Observe output of program.
Algorithm:
I] Register Addressing Mode.
1] Start.
2] Load Data (02H) in to Register R0.
3] Load Data (03H) in to Register R1.
4] Move contents of R0 to accumulator A.
5] Add contents of R1 to Accumulator and store result in A.
II] Immediate Addressing Mode:
1] Start.
2] Move immediate data (02H) to A.
3] Add immediate data (03H) with A.
4] Return.

III] Direct Addressing Mode:
1] Start.
2] Move data 02H at Address 50H.
3] Move data 03H at Address 51H.
2] Move content from Data Address 50H to A.
3] Add content of Data Address 51H to A.
4] Return.
Page 4 of 6

IV] Indirect Addressing Mode:
1] Start.
2] Move data 02H at Address 50H.
3] Move data 03H at Address 51H.
4] Move content stored at Data address 50H to Register R1.
5] Move contents of Register R1 to A.
6] Move contents stored at Data Address 51H to R0.
7] Add contents of Register R0 with A.
8] Return.
Flowchart:
I] Register Addressing Mode. II] Immediate Addressing Mode.





III] Direct Addressing Mode IV] Indirect Addressing Mode

Page 5 of 6




Assembly Program:
I] Register Address Mode:
Instruction
Sequence
Mnemonics Operands Comments
78 MOV R0,#02H Move Data 02H to Register R0
02
79 MOV R1,#03H Move Data 03H to Register R1
03
E8 MOV A,R0 Move Contents of R0 to A
29 ADD A,R1 Add contents of R1 to A
22 RET Return
Results: Kindly Write Results of Program
II] Immediate Addressing Mode:
Instruction
Sequence
Mnemonics Operands Comments
74 MOV A,#02H Move Immediate Data 02H to Register A
02
24 ADD A,#03H Add Immediate Data 03H to content of Register A
Page 6 of 6

03
22 RET Return
Results: Kindly Write Results of Program
III] Direct Addressing Mode:
Before Execution: Save two numbers in Internal RAM:
Address Data
20H 02H
21H 03H

Instruction
Sequence
Mnemonics Operands Comments
E5 MOV A,20H Move content of Memory location 20 H to Accumulator.
50
25 ADD A,21H Add contents of accumulator with the content of Memory
location 21H.
51
22 RET Return.
Results: Kindly Write Results of Program
IV] Indirect Addressing Mode:
Before Execution: Save two numbers in Internal RAM:
Address Data
20H 02H
21H 03H

Instruction
Sequence
Mnemonics Operands Comments
A9 MOV R1,20H Move Contents of Memory location 20H to register R1.
50
E7 MOV A,@R1 Move contents of Memory location pointed by register R1
to Accumulator.
A8 MOV R0,21H Move Contents of Memory location 21H to register R0.
51
26 ADD A,@R0 Add the contents of Memory location pointed by resistor
R0 to accumulator.
22 RET Return.
Results: Kindly Write Results of Program
Conclusion:

Das könnte Ihnen auch gefallen