0% found this document useful (0 votes)
67 views33 pages

Chapter 5 8051 Addressing Modes: Spring'17 Twhou 8051

This document discusses addressing modes in 8051 microcontrollers. It covers immediate and register addressing modes which allow loading values directly into registers. It also discusses direct addressing of memory locations, SFR registers, and register indirect addressing using pointers in R0 and R1. Indexed addressing mode allows accessing data elements in lookup tables efficiently. Bit addressing allows manipulating individual bits in registers and memory. Finally, it mentions the extra on-chip RAM available in the 8052 microcontroller.

Uploaded by

孫協廷
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views33 pages

Chapter 5 8051 Addressing Modes: Spring'17 Twhou 8051

This document discusses addressing modes in 8051 microcontrollers. It covers immediate and register addressing modes which allow loading values directly into registers. It also discusses direct addressing of memory locations, SFR registers, and register indirect addressing using pointers in R0 and R1. Indexed addressing mode allows accessing data elements in lookup tables efficiently. Bit addressing allows manipulating individual bits in registers and memory. Finally, it mentions the extra on-chip RAM available in the 8052 microcontroller.

Uploaded by

孫協廷
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

成功大學工程科學系

Chapter 5 8051 Addressing Modes

Spring'17 TWHou 8051


1
成功大學工程科學系

• 5.1 Immediate and Register Addressing Modes


• 5.2 Accessing Memory Using Various Addressing
Modes

Spring'17 TWHou 8051


2
成功大學工程科學系

5.1 Immediate and Register Addressing Modes


MOV A, #25H; LOAD 25H INTO A
MOV R4,#62 ;LOAD THE DECIMAL 62 INTO R4
MOV B, #40H ;LOAD 40H INTO B
MOV DPTR, #4521H; DPTR=4512H

MOV DPTR, #2550H; IS THE SAME AS

MOV DPL, #50H;


MOV DPH, #25H;

Spring'17 TWHou 8051


3
成功大學工程科學系

IMMEDIATE ADDRESSING MODE


• MOV DPTR, #68975; ILLEGAL VALUE

• COUNT EQU 30
• ……
• MOV R4, #COUNT; R4=1E (30=1EH)
• MOV DPTR,#MYDATA; DPTR=200H

• ORG 200H
• MYDATA: DB “AMERICA”

Spring'17 TWHou 8051


4
成功大學工程科學系

Register addressing mode


• MOV A, R0
• MOV R2, A
• ADD A, R5
• ADD A, R7
• MOV R6,A

• MOV DPTR, A  ERROR


• MOV DPTR, #25F5H
• MOV R7, DPL
• MOV R6,DPH

Spring'17 TWHou 8051


5
成功大學工程科學系

5.2 Accessing Memory using various addr modes


• Direct addressing mode
• RAM LOCATION: 00~1FH, (register bank)
• 20~2FH, (SFR, bit addr.)
• 30~7FH (byte addr.)
• MOV R0, 40H;save RAM 40H content in R0
• MOV 56H, A;save A content into RAM 56H
• MOV R4,7FH;move RAM 7FH content to R4

Spring'17 TWHou 8051


6
成功大學工程科學系

• MOV A, 4; is same as
• MOV A, R4; which means copy R4 into A

• MOV A, 7; is same as
• MOV A,R7; Which means copy R7 into A

Spring'17 TWHou 8051


7
成功大學工程科學系

• MOV R2, #5 ; R2 = 05
• MOV A, 2; copy R2 to A
• MOV B, 2; copy R2 to B
• MOV 7,2 ; copy R2 to R7
• ;since “MOV R7, R2” is invalid

Spring'17 TWHou 8051


8
成功大學工程科學系

• SFR registers and their addresses


• MOV 0E0H, #55H
• MOV A, #55H; these two are the same

• MOV 0F0H,#25H
• MOV B, #25H; these two are the same.

Spring'17 TWHou 8051


9
成功大學工程科學系

• Table 5-1
• Example 5-1
• Example 5-2

Spring'17 TWHou 8051


10
成功大學工程科學系

Spring'17 TWHou 8051


11
成功大學工程科學系

Spring'17 TWHou 8051


12
成功大學工程科學系

Spring'17 TWHou 8051


13
成功大學工程科學系

Register indirect addressing mode


• Register as pointer to data
• Only R0 and R1 can hold address for RAM
locations. (with the @ sign)
• MOV A, @R0; move contents of RAM
• location whose address is
• held by R0 into A
• MOV @R1,B; move contents of B into RAM
• location whose address is
• held by R1

Spring'17 TWHou 8051


14
成功大學工程科學系

• Example 5-3

Spring'17 TWHou 8051


15
成功大學工程科學系

Spring'17 TWHou 8051


16
成功大學工程科學系

Spring'17 TWHou 8051


17
成功大學工程科學系

• Advantage of register indirect addressing mode


– Access data dynamic rather than static
– Example 5-4, example5-5

Spring'17 TWHou 8051


18
成功大學工程科學系

Spring'17 TWHou 8051


19
成功大學工程科學系

Spring'17 TWHou 8051


20
成功大學工程科學系

• Limitation of register indirect addressing mode


– Only R0 and R1 can be used
– 16 bit pointer – only DPTR is used

Spring'17 TWHou 8051


21
成功大學工程科學系

– Indexed addressing mode and on-chip ROM access


– Widely used in accessing data elements of look-up
table entries located in the program ROM.
– MOVC A, @A+DPTR
– Example 5-6
– Example 5-7

Spring'17 TWHou 8051


22
成功大學工程科學系

Spring'17 TWHou 8051


23
成功大學工程科學系

Spring'17 TWHou 8051


24
成功大學工程科學系

Spring'17 TWHou 8051


25
成功大學工程科學系

Look-up table and indexed addressing mode


• Look-up table – allows access to elements of a
frequently used table with minimum operations
• Example 5-8,
• Example 5-9

Spring'17 TWHou 8051


26
成功大學工程科學系

Spring'17 TWHou 8051


27
成功大學工程科學系

Spring'17 TWHou 8051


28
成功大學工程科學系

Sec 5.3 Bit addresses for I/O and RAM


• Bit addressable RAM- only 16bytes of 128 byte internal
RAM are bit addressable.
• 20H- 2FH (128bits)
• Fig. 5-1
• Table 5-2 Single bit instructions
• SETB bit
• CLR bit
• CPL bit
• JB bit, target
• JNB bit, target
• JBC bit, target

Spring'17 TWHou 8051


29
成功大學工程科學系

• I/O port bit addresses


• SFR RAM addresses
• Bit memory map
• Using BIT directive, Using EQU directive
• Registers and bit-addressablility
– Only A, B, PSW, IP, IE, ACC, SCON and TCON are
bit addressable

Spring'17 TWHou 8051


30
成功大學工程科學系

Section 5.4 Extra 128-byte on-chip RA in 8052


• Table 5-4: 80H-FFH (SFR)

Spring'17 TWHou 8051


31
成功大學工程科學系

End of Chapter 5

Spring'17 TWHou 8051


32
成功大學工程科學系

Spring'17 TWHou 8051


33

You might also like