Author :
Craig
Steiner
Source :
8052.com
Book :
The
8051/8052
Microcontroller:
Architecture,
Assembly
Language,
And
Hardware
Interfacing
(Paperback)
256 BYTES OF INTERNAL RAM
The
standard
8051
microcontroller
contains
128
bytes of
Internal
RAM that
are
available
to the
developer
as
working
memory
for
variables
and/or
for the
operating
stack.
Instructions
that
refer to
addresses
in the
range of
00h
through
7Fh
refer to
the
8051's
Internal
RAM,
while
addresses
in the
range of
80h
through
FFh
refer to
Special
Function
Registers
(SFRs).
Although
the 8052
has 256
bytes of
Internal
RAM, the
above
method
of
referencing
them
remains
true.
Any
address
between
00h and
7Fh
refers
to
Internal
RAM
whereas
address
in the
range of
80h
through
FFh
refer to
SFRs.
The
8052's
additional
Internal
RAM may
only be
referred
by
Indirect
Addressing.
Indirect
addressing
always
refers
to
Internal
RAM,
never to
an SFR.
Thus, to
read the
value
contained
in
Internal
RAM
address
90h, the
developer
would
need to
code
something
along
the
lines of
the
following:
MOV R0,#90h ;Set the indirect address to 90h
MOV A,@R0 ;Read the contents of Internal RAM pointed to by R0
The above code first assigns the value 90h to the register
R0. It
subsequently
reads,
indirectly,
the
contents
of the
address
contained
in R0
(90h).
Thus,
after
these
two
instructions
have
executed,
the
Accumulator
will
contain
the
value of
Internal
RAM
address
90h.
It is
very
important
to
understand
that the
above
code is
not the
same as
the
following:
MOV A,90h ;Reads the contents of SFR 90h (P1)
This instruction uses direct addressing; recall that direct
addressing
reads
Internal
RAM when
the
address
is in
the
range of
00h
through
7Fh, and
reads an
SFR when
the
address
is in
the
range of
80h
through
FFh.
Thus in
the case
of this
second
example,
the move
instruction
reads
the
value of
SFR
90h-which
happens
to be P1
(I/O
Port 1).