0% found this document useful (0 votes)
311 views

8051 Memory Organization

This document provides an overview of computer instructions and memory organization in 8051 microcontrollers. It discusses that computer instructions are the basic components of a machine language program encoded as binary instruction codes containing an opcode and operands. It then describes the different types of memory in 8051 microcontrollers including internal and external ROM for program memory and internal and external RAM for data memory. It explains the addressing modes used in 8051 instructions to specify operands including immediate, direct, indirect, register, and indexed addressing.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
311 views

8051 Memory Organization

This document provides an overview of computer instructions and memory organization in 8051 microcontrollers. It discusses that computer instructions are the basic components of a machine language program encoded as binary instruction codes containing an opcode and operands. It then describes the different types of memory in 8051 microcontrollers including internal and external ROM for program memory and internal and external RAM for data memory. It explains the addressing modes used in 8051 instructions to specify operands including immediate, direct, indirect, register, and indexed addressing.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

INTRODUCTION

Computer Instructions

Computer instructions are the basic components of a machine language program. They
are also known as macro operations, since each one is comprised of a sequences of
microoperations.

Each instruction initiates a sequence of microoperations that fetch operands from registers
or memory, possibly perform arithmetic, logic, or shift operations, and store results in registers
or memory.

Instructions are encoded as binary instruction codes. Each instruction code contains of


a operation code, or opcode, which designates the overall purpose of the instruction (e.g. add,
subtract, move, input, etc.). The number of bits allocated for the opcode determined how many
different instructions the architecture supports.

In addition to the opcode, many instructions also contain one or more operands, which
indicate where in registers or memory the data required for the operation is located. For example,
and add instruction requires two operands, and a not instruction requires one.

The term addressing mode refers to the way in which the operand of an instruction is
specified. The operand can be directly given in an instruction, it can be the address of location
where data is stored or it can even be a pointer to memory location where data is stored.

8051 MEMORY ORGANIZATION

The 8051 microcontroller's memory is divided into Program Memory and Data Memory.
Program Memory (ROM) is used for permanent saving program being executed, while Data
Memory (RAM) is used for temporarily storing and keeping intermediate results and variables.

8051 Microcontroller has both Internal ROM and Internal RAM. If the internal memory is
inadequate, you can add external memory using suitable circuits.  

Then, 8051 operates with 4 different memories.

 Internal ROM
 External ROM
 Internal RAM
 External RAM
 Program Memory (ROM) of 8051 Microcontroller

In 8051 Microcontroller, the code or instructions to be executed are stored in the Program
Memory, which is also called as the ROM of the Microcontroller. The original 8051
Microcontroller by Intel has 4KB of internal ROM.

In case of 4KB of Internal ROM, the address space is 0000H to 0FFFH. If the address space i.e.
the program addresses exceed this value, then the CPU will automatically fetch the code from the
external Program Memory.

ROM can be implemented in three different ways in 8051.

1) Only Internal ROM: 8051 has 4 KB internal ROM. In many cases this size is sufficient
and there is no need for connecting External ROM. All addresses from 0000H to 0FFFH
will be accessed from internal ROM.
2) Internal and external ROM: If the size of internal ROM is insufficient, systems can use a
combination of both Internal and External ROM. All addresses from 0000H to 0FFFH
will be accessed from Internal ROM. Addresses 1000H to FFFH will be accessed from
External ROM.
3) Only External ROM: If the user choose not to use Internal ROM because of reasons like
the program stored in the Internal ROM becoming invalid or outdated or if the system
needs to be upgraded etc. upto 64 KB of external ROM can be connected.

 Data Memory (RAM) of 8051 Microcontroller

The Data Memory or RAM of the 8051 Microcontroller stores temporary data and intermediate
results that are generated and used during the normal operation of the microcontroller. Original
Intel’s 8051 Microcontroller had 128B of internal RAM. The address range is 00H to 7FH.

Memory addresses from 00H to 7FH is divided in to Working Registers (organized as Register
Banks), Bit – Addressable Area and General Purpose RAM (also known as Scratchpad area).

The first 32B i.e. memory from addresses 00H to 1FH consists of 32 Working Registers that are
organized as four banks with 8 Registers in each Bank. The 4 banks are named as Bank0, Bank1,
Bank2 and Bank3. Each Bank consists of 8 registers named as R0 – R7. Each Register can be
addressed in two ways: either by name or by address.
Eg. Location 00H can be accessed as R, if Bank 0 is the active bank.

MOV A, R0 : “A” register gets data from register R0.

It can also be accessed as location 00H irrespective of which bank is the active bank.

MOV A,00H: “A” register gets data from location 00H

The appropriate bank is selected by the RS1, RS0 bits of PSW.

The upper 128B of the RAM i.e. memory addresses from 80H to FFH is allocated for Special
Function Registers (SFRs). SFRs control specific functions of the 8051 Microcontroller. Some of
the SFRs are I/O Port Registers (P0, P1, P2 and P3), PSW (Program Status Word), A
(Accumulator), IE (Interrupt Enable), PCON (Power Control), etc.

SFRs are 8 bit registers. SRFs Memory addresses are only direct addressable. SFRs are allotted
addresses from 80H to FFH. Even though some of the addresses between 80H and FFH are not
assigned to any SFR, they cannot be used as additional RAM area.

In some microcontrollers, there is an additional 128B of RAM, which share the memory address
with SFRs i.e. 80H to FFH. But, this additional RAM block is only accessed by indirect
addressing.

ADDRESSING MODES

The term addressing mode refers to the way in which the operand of an instruction is specified.
Information contained in the instruction code is the value of the operand on the address of the
result/operand. The CPU access data in various ways. The 8051 supports the following types of
addressing modes.

1. Immediate mode

2. Direct addressing

3. Indirect addressing

4. Register instructions

5. Register specific

6. Indexed addressing
Symbols

Rn Register R7-R0 of the currently selected


Register Bank.

direct 8-bit internal data location’s address. This


could be an Internal Data RAM location (0-
127) or a SFR [i.e., I/O port, control register,
status register, etc. (128-255)].

@Ri 8-bit internal data RAM location (0-255)


addressed indirectly through register R1or R0.

#data 8-bit constant included in instruction.

#data 16 16-bit constant included in instruction.

addr 16 16-bit destination address. Used by LCALL


and LJMP. A branch can be anywhere within
the 64K byte Program Memory address space.

addr 11 11-bit destination address. Used by ACALL


and AJMP. The branch will be within the
same 2K byte page of program memory as the
first byte of the following instruction.

1. IMMEDIATE ADDRESSING :

In immediate addressing mode, an 8/16 bit immediate data / constant is specified in the
instruction itself. A ‘#’ character is put before the data, to identify it as a data value and not as an
address. The destination register to which the constant data must be copied should be the same
size as the operand mentioned in the instruction.

Immediate Addressing is very fast as the data to be loaded is given in the instruction
itself.

E.g.
 MOV A, #35H :- Move the immediate data 35H given in the instruction to A-register.
 MOV DPTR, #3000H :- Load the immediate 16-bit constant given in the instruction in
DPTR (Data pointer). This constant will be an address of data memory location.

2. DIRECT ADDRESSING :

In direct addressing mode, the address of the data is directly specified in the instruction. The
direct address can be the address of an internal data RAM location (00H to 7FH) or address of
special function register (80H to FFH).

Most assemblers and compilers provide equates or standard symbol name for the SFRs and I/O
ports , so that SFRs names may be used in lieu of its direct address.

For e.g. P0 stands for address 80H , TMOD stands for address 89H etc.

E.g.

 MOV A, 35 H :- This instruction will move the RAM location 35H to A-register
(Accumulator).
 ADD A,#100 : Immediate data 100(decimal) is added to the contents of accumulator. For
specifying a hex number, it should be followed by H
 MOV A,80H or MOV A,P0: Move contents of Port 0 (SFR at address 80H) to A
 MOV R0,89H : Here 89H is the address of a special function register TMOD
 MOV 20H,30H: Location 20H gets the content of location 30H
REFERENCES

 Advanced microprocessors and peripherals, A K Ray and K M Bhurchandi, 2 nd edition, The


McGraw Hill Pvt Ltd, 2012.
 https://www.electronicshub.org/8051-microcontroller-instruction-set/

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy