Quentin wrote:
>
> To ensure that my lookup table is in the first 256 places, is this right?:
> org 0x000
>
> ;Lookup table here.
> ;ensure table does not cross 0x0FF
>
> org 0x0FF ;or less,depending on size of table
Correct this org value to 0x100
> ;main program here
> ;call lookup table from here
> end
0xFF addr is owned by zero page. First page is starting from 0x100 addr.
Don't forget that 0x000 addr is reset vector and 0x004 is int vector.
> To ensure that my lookup table is in the first 256 places, is this right?:
> org 0x000
> ;Lookup table here.
> ;ensure table does not cross 0x0FF
>
> org 0x0FF ;or less,depending on size of table
>
> ;main program here
> ;call lookup table from here
> end
Nope. You didn't mention which flavor of PIC you are using, but most PIC's
take their first instruction from location 0x000. Additionally, many PIC's
use 0x004 for the Interrupt vector.
If your table isn't huge (<200 or so) then you might try:
MAIN_LOOP
; main program here
; call lookup table from here
END
You will still need to be cautious not to inadvertantly cross the 0xFF
boundary without accounting for it.
If your table is >200 or so, then you might be better served to just place the
table at 0x100 (which is on the second page).
Michael
*************************************************************************
When the way of the Tao is forgotten, kindness and ethics must be taught.
Men must learn to pretend to be wise and good. -- Lao Tzu
*************************************************************************
> org 0x000
>
> ;Lookup table here.
> ;ensure table does not cross 0x0FF
>
> org 0x0FF ;or less,depending on size of table
>
> ;main program here
> ;call lookup table from here
> end
>
> Thanks
> Quentin
You could do that, but when Resetting your PIC (most of them anyway) will
want to start at adress 0x0000. But that is where you want to put your
table. So, You've got a problem. Not a big one, but nevertheless :-)
When you use a Table Look-up you are using a ADWF PCL instruction to a
RETLW in the table. When modifying the PCL you will use some bits outof
the PCLATH register also. Those bits (outof the PCLATH-register) will
provide the high-bits of your Destination-adres when changing the
PCL-register. In short : When you change the PCL register the target adres
for the "jump" will consist outof 8 bits from the PCL register, and
pre-pended to (placed to the left of) that will be the bits outof the
PCLATH register. This means that the PCLATH register contains a sort of
"page-adres" for your table. And this in turn means that you can place
your table at any 256-byte page in memory !