0


什么是DPTR寄存器

DPRT 中文译名 数据指针data pointer, 是一个16位的特殊寄存器(至少在51中是16位). 其设计初衷是用于跟外部ROM和外部RAM. 寻址方式是间接寻址,一般搭配MOVX使用。
一般用法 :
movx a,@dptr 读取外部内存某一个地址(即dptr所存的值)的内容到A
movx @dptr, a 将A的内容写入外部内存某一个地址(即dptr所存的值)

DPTR作用作为数据指针来讲(正常一个经典8051只有一个DPTR)
作用可以跟通用寄存器类比一下, 一般都是用作间接寻址。(看下面例子)‘

不同的是通用寄存器只能适用于内部RAM的读取和写入。DPTR是专门为16位(或者小于16位)的外部RAM或者外部ROM准备用于读取和写入的。

in 8051,R0 and R1 can be used as pointer
we store required address as data in R0 or R1 and @ will give u data at that address.
so the code would go like:
(这个例子展现了循环多次给30h-100h 连续地址赋值)
mov R0,#30h
mov 05h,#100
back:
mov @R0,#15h
inc R0
DJNZ 05h,back

thats it. even if u increase the number of locations, the program size remains same. only change the loop count.
this is the use of pointer. R0 and R1 are suitable for internal RAM memory as it can point 8 bit address only.
what if we want to access External RAM and External ROM. As their address size is 16 bit. therefore they introduced new pointer called data pointer (DPTR).
where DPTR holds the address and @dptr gives value at that address.
eg:

mov dptr,#1000h
movx a,@dptr

this instruction set is used to read data of ext RAM at location 1000h

标签: 单片机

本文转载自: https://blog.csdn.net/hang_walk_monde/article/details/116166090
版权归原作者 hang_walk_monde 所有, 如有侵权,请联系我们删除。

“什么是DPTR寄存器”的评论:

还没有评论