Title: Microprocessors
1Microprocessors
2Immediate Addressing Mode
- Immediate data preceded by .
- Used to load data into any programmable register.
- Immediate data is stored in ROM with the
application program.
3MOV DPTR, 2550H
- To access 64Kb RAM addresses, the data pointer
(DPTR) must be loaded with a 16 bit RAM address. - The low byte register of the DPTR is DPL.
- The high byte register of the DPTR is DPH.
4Using the EQU directive for immediate data.
COUNT EQU 30 MYDATA EQU 200H MOV R4,
COUNT MOV DPTR, MYDATA or COUNT EQU
30 MOV R4, COUNT MOV DPTR, MYDATA DPTR
200H ORG 200H MYDATA IS 200HMYDATA DB
America
Demonstrates that labels are addresses.
5Register Addressing Mode
- Register addressing conserves ROM and executes
faster than direct addressing. - Examples
- MOV A, Rn
- MOV Rn, A
- MOV Rn, 40H
register addressing
direct addressing
6Direct Addressing Mode
- Can address 00H to 7FH of on-board RAM.
- Most often used to address 30H to 7FH.
- SFRs can be direct addressed.
- Non SFR addresses between 80H and FFH are off
limits to the programmer. - Stack instructions require direct addressing.
7Register Indirect Addressing Mode
- R0 and R1 may be pointer registers.
- Use _at_ to indicate that R0 or R1 is a pointer.
- R0 and R1 can point only to on chip RAM
addresses. - Use the DPTR to point to external RAM and ROM
addresses.
8Register Indirect Addressing Mode (Program
Example)
MOV R0, 35H source pointer MOV R1, 60H
destination pointer MOV A, _at_R0 get a byte
from address 35H MOV _at_R1, A copy that byte
into 60H
9Look-up Table in Code Memory
ORG 0 MOV DPTR, 300H MOV A,
0FFH MOV P1, A BACK MOV A, P1 MOVC
A, _at_ADPTR MOV P2, A SJMP BACK ORG
300HXSQR_TABLE DB 0,1,4,9,16,25,36,49,64,81 E
ND
10Look-up Table in Code Memory
MOV DPTR, 300H
MOV A, 0FFHMOV P1, A
MOV A, P1
MOVC A, _at_ADPTR
MOV P2, A
11(No Transcript)
12(No Transcript)
13(No Transcript)
14(No Transcript)
15Thats 4 squared!
16(No Transcript)
17A word about MOVC
- MOVC gets a byte from code memory.
- MOVC A, _at_ADPTR uses the data pointer
- MOVC A, _at_APC uses the program counter.