We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have 8051 with 2 DPTR, SFR register to switch data banks(32Kb/16Kb)... Both DPTRs used to increment read/write pointers. I need correct 32bit address increment over all accessible memory. How to widen DPTR to work with 32 bit address?
Thanks, so at the end my solution is:
typedef union U32 { unsigned long dword; unsigned short word[2]; unsigned char byte[4]; } bdata U32; ... unsigned long Inc32bitDPTR (unsigned long addr) { U32 idata tmp_dptr; tmp_dptr.dword = addr; tmp_dptr.dword++; switch (DPS) { case 0x00: DPL0 = tmp_dptr.byte[3]; DPH0 = tmp_dptr.byte[2]; break; case 0x01: DPL1 = tmp_dptr.byte[3]; DPH1 = tmp_dptr.byte[2]; } if (tmp_dptr.dword >= MAX_ADDR) tmp_dptr.dword = 0; return tmp_dptr.dword; } ... tmp_dptr_dst.dword = addr;//long addr; WriteByte (tmp_dptr_dst.dword, byte); tmp_dptr_dst.dword = Inc32bitDPTR(tmp_dptr_dst.dword); ...
May be anybody realized it better and faster?
I would avoid the use of "word" to mean "16 bits"
See: www.8052.com/.../read.phtml
Strictly, on an 8051, the word-size is 8 bits.
Micro$oft wouldn't :)
They currently uses it to mean half (and possibly also a quarter of) the size of an integer register...)
That's because they used it specifically in the context of their original 16-bit platform.
They are now stuck with it for 32- and 64-bit platforms.
Serves 'em right!
Learn form their mistake!