什么是DPTR寄存器
rom是什么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
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论