Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Lookup Tables on 8051

904 views
Skip to first unread message

peens

unread,
Sep 10, 1999, 3:00:00 AM9/10/99
to
How does one implement lookup tables on 8051s?

Mark A. Odell

unread,
Sep 10, 1999, 3:00:00 AM9/10/99
to
const char code lookupTable[] =
{
// Entries
};

You must be more specific. A linear array like above? A 2 x n
matrix? A jump table of funtion pointers? C? AssemblY?

.--------------------------------..--------------------------------.
| Mark A. Odell || Embedded Firmware Design, Inc. |
| Principal Consultant || 8051 Experts |
| http://www.embeddedfw.com || Real-time Specialists |
| || |
| .-----------------------------------------------. |
| / "When meeting all deadlines IS the requirement" \ |
| \_________________________________________________/ |
| || |
'--------------------------------''--------------------------------'

(Remove the obvious from reply address to respond via e-mail)

peens <pe...@icon.com> wrote in message news:7rb9kt$ni7$1...@ctb-nnrp2.saix.net...

phil

unread,
Sep 10, 1999, 3:00:00 AM9/10/99
to
Since there is only one DPTR, you must use it and do your lookups with:
mov dptr,#TABLEBASE
movc a,@a+dptr if it is in code space and
movx a,@dptr if it is in RAM


You will have to do the pointer addition directly into the DPTR.

mov a,offsetLo
add a,dpl
mov dpl,a
mov a,offsethi
addc a,dph
mov dph,a


or just:

inc dptr

if you are walking through a table ....


you can configure your hardware to use RAM as code space if you wish with a
couple of gates.

Cass

unread,
Sep 10, 1999, 3:00:00 AM9/10/99
to
some versions of the 8051 have two DPTRs.
Cass

phil <ph...@extreme-measures.com> wrote in message
news:nTbC3.861$8Y4....@alfalfa.thegrid.net...

Chris Hills

unread,
Sep 11, 1999, 3:00:00 AM9/11/99
to

some versions of the 8051 have eight DPTRs

It depends on what you want to do an on which MCU

Cass <casseg...@galaxycorp.com> writes

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\/\ Chris Hills Staffs /\/\/\/\/\/
/\/\/\/\/\/\/\/\/\ England /\/\/\/\/\/\/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Tom Maier

unread,
Sep 13, 1999, 3:00:00 AM9/13/99
to
Chris Hills <ch...@phaedsys.demon.co.uk> wrote:

>
>some versions of the 8051 have eight DPTRs
>

Out of curiousity, who makes one with 8?

Tom


@keil.com Jon Ward

unread,
Sep 13, 1999, 3:00:00 AM9/13/99
to
The Siemens/Infineon 515 and 517.

Jon Ward
Keil Software

Tom Maier wrote in message <37dd65af...@news.bitstorm.net>...

Chris Hills

unread,
Sep 13, 1999, 3:00:00 AM9/13/99
to
Tom Maier <tma...@bitstorm.net> writes

>Chris Hills <ch...@phaedsys.demon.co.uk> wrote:
>>some versions of the 8051 have eight DPTRs
>Out of curiousity, who makes one with 8?

The Siemens range based on the C500 core.

Chris Hills

unread,
Sep 14, 1999, 3:00:00 AM9/14/99
to
Jon,
Just out of curiosity, who does a C51 compiler that takes advantage of
these 8 data pointers :-)

Jon Ward <jo...@keil.com> writes
>The Siemens/Infineon 515 and 517


>Jon Ward
>Keil Software
>
>Tom Maier wrote in message <37dd65af...@news.bitstorm.net>...

>>Chris Hills <ch...@phaedsys.demon.co.uk> wrote:

>>>some versions of the 8051 have eight DPTRs

>>Out of curiousity, who makes one with 8?

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

Bryan Whitton

unread,
Sep 14, 1999, 3:00:00 AM9/14/99
to
Actually no one writes a C compiler that takes advantage of all 8
DPTRs. But the Keil compiler can use the first two as source and
destination pointers in the string manipulation andbuffer manipulation
libraries.

Bryan Whitton

Henk Dekker

unread,
Sep 17, 1999, 3:00:00 AM9/17/99
to
Hi !

Here's another way:
(in asm)
If, for any reason, you don't want to use the DPTR and you don't have any
other data pointers, you can use the zero-page addressing mode for tables <=
256 bytes. (If the table is in RAM)

e.g. MOV A,@R0 (internal RAM)
or MOVX A,@R0 (external RAM)

For external RAM, port P0 and P2 will be used by the CPU to access the
external memory. Because the "@Ri" addressing mode is an 8-bits mode, the
instruction will cause port P2's value (the high-byte) to stay at the
external addressbus. You can use this feature to address a certain
memory-page.
(Note: normally port P2 will be 0 by default, so you will access the
external zero-page.)


For example:

You have located a table at external RAM address 0500h and you want to
address the 23rd element, you can do this by:

MOV P2,#5 ;High byte of external address
MOV R0,#23 ;Index into table (low byte of external address)
MOV A,@R0 ;Read the table !!i!


I've used this feature to create a second datapointer to make block-moves
and bit-blitting very fast on the stupid old 8051.
I don't know if this is usefull to you. Bye !

Henk Dekker

0 new messages