什么是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

  • 11
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值