Internal Architecture of 8051: Dinesh Sharma
Internal Architecture of 8051: Dinesh Sharma
Internal Architecture of 8051: Dinesh Sharma
Dinesh Sharma
15/10/2007
State
Instructions
Data Instruction
Processing Processing
Data
Instructions A common bus is used for
data as well as instructions.
Bus
The system can become ‘bus
bound’.
Bottleneck! Memory
State
Data Instruction
Processing Processing Separate data and instruction
Instructions paths
Good performance
Data Instructions Needs 2 buses → expensive!
Traffic on the buses is not
balanced.
Data Instruction Instruction bus may remain
Memory Memory idle.
State
Data Instruction
Processing Processing
Instructions Constants can be stored with
Instructions in ROM.
Better Bus balancing is
Variables Constants Instructions possible.
Typically, 1 instruction read, 1
constant read, 1 data read and
1 result write per instruction.
Data Read Only
Memory Memory
2 mem ops per bus.
State
Data Instruction
Processing Instructions Processing
external RAM. FF
Special
FF FFFF
Memory
Function
External and Internal ROM are Registers
(8052 Only)
SFR range accessed only by direct addressing 8052 upper memory range accessed only by
indirect addressing.
F8 F8
F0
SP Fn Regs
98
8052 RAM
90
88 88
80 80
30
28 Bit Addressable
20
18 R0 R1 R2 R3 R4 R5 R6 R7
10 R0 R1 R2 R3 R4 R5 R6 R7 Register Banks
08 R0 R1 R2 R3 R4 R5 R6 R7 (Active bank selected by bits in PSW)
00 R0 R1 R2 R3 R4 R5 R6 R7
F8 FF
F0 B F7
E8 EF
E0 ACC E7
D8 DF
D0 PSW D7
C8 CF
C0 C7
B8 IP BF
B0 P3 B7
A8 IE AF
A0 P2 A7
98 SCON SBUF 9F
90 P1 97
88 TCON TMOD TL0 TL1 TH0 TH1 8F
80 P0 SP DPL DPH PCON 87
0/8 1/9 2/A 3/B 4/C 5/D 6/E 7/F
XCH A, src
Here src can be a direct address, Rn or @Ri. The src byte
then contains the value of A and A acquires the original
value of the source byte.
XCHD A, @Ri
This exchanges just the lower nibble of the two operands.
The upper nibble retains its original value.
Exchanging the upper nibble
The upper nibble may be exchanged by combining the
above instructions. If we do
XCH A, @Ri
XCHD A, @Ri
Both instructions exchange the lower nibble while the first
exchanges the upper nibble also. Thus the upper nibble is
exchanged once, while the lower nibble is restored to its
original value due to two exchanges.
Dinesh Sharma 8051Architecture
Swapping Nibbles
MOVC A, @A+DPTR
Move a constant from the ROM to A. The address to be
accessed in ROM is the sum of the 8 bit value in A and the
16 bit value in DPTR. This is convenient for table look up.
the start address of the table is put in DPTR and the offset
derived from the index is in A.
MOVC A, @A+PC
This is like MOVC A @A+DPTR, except that the 16 bit
pointer value is taken from (updated) PC instead of DPTR.
This is used when constants are at some fixed offset from
the current instruction. The offset is placed in A. Using this
instruction allows one to access the constant irrespective
of the absolute address at which the program is loaded.
7 6 5 4 3 2 1 0
RL A ; Rotate A left
7 6 5 4 3 2 1 0
RR A ; Rotate A right
Cy 7 6 5 4 3 2 1 0