Searching \ for 'Addressing ROM space ??' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/index.htm?key=addressing+rom+space
Search entire site for: 'Addressing ROM space ??'.

Truncated match.
PICList Thread
'Addressing ROM space ??'
1998\03\03@193925 by Bob Smith x31105

picon face
Hello All,

New to PIC's...  Working on a project using a 16C74A - the original
idea prior to having a better understanding of the PIC was to have
some lookup tables in ROM - my first pass at looking at the opcodes
for this beasty leaves me with the belief that I can't use ROM address
space for data?!?!  somebody tell me I'm blind and haven't read the
correct page!

Thanks!

Bob

1998\03\03@220346 by Brian Schousek

picon face
-----Original Message-----
From: Bob Smith x31105 <spam_OUTrsmithTakeThisOuTspamKODAK.COM>
To: .....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU <PICLISTspamKILLspamMITVMA.MIT.EDU>
Date: Tuesday, March 03, 1998 7:38 PM
Subject: Addressing ROM space ??


>Hello All,
>
>New to PIC's...  Working on a project using a 16C74A - the original
>idea prior to having a better understanding of the PIC was to have
>some lookup tables in ROM - my first pass at looking at the opcodes
>for this beasty leaves me with the belief that I can't use ROM address
>space for data?!?!  somebody tell me I'm blind and haven't read the
>correct page!
Bob:
you're blind and haven't read the right page.
Brian














Ok, smart-ass mode OFF. You need to make use of the retlw instruction. You
set up a table filled with retlw's. The front of the table consists of an
addwf 0x02 instruction. Then you call the address of the table with the w
register containing the offset of the data you wish to receive. For example:

table:
addwf 0x02    ;0x02 is the Program Counter register.
                     ;whatever is in w register when 'table' is called
                     ;will serve as an offset into the table
retlw    'a'
retlw    'b'
retlw    'c'
;end of table


reset:
movlw 0
call table
movwf    wherever    ;you just retrieved element 0, ASCII 'a' and put it
wherever

movlw 2
call table    ;similarly, element 2 is retrieved, ASCII 'c'
END
Brian

1998\03\04@011801 by Clyde Smith-Stubbs

flavicon
face
On Tue, Mar 03, 1998 at 07:04:35PM -0400, Bob Smith x31105 wrote:

> for this beasty leaves me with the belief that I can't use ROM address
> space for data?!?!  somebody tell me I'm blind and haven't read the
> correct page!

You're very nearly right; data tables on a mid-range PIC are implemented
as RETLW tables, indexed by an addwf PCL. For example:

table     addwf   pcl
         retlw   1
         retlw   2

You access the data with a call, with the 8 bit index of the data you want
in W. You also have to worry about ROM pages if you have more than 2K
of ROM. This technique stores 8 bits of data per 14 bit instruction.

the same applies on the baseline PICs (12 bits instead of 14) but
the high-end have instructions to read (and write!) the external program
memory space.

--
Clyde Smith-Stubbs               |            HI-TECH Software
Email: .....clydeKILLspamspam.....htsoft.com          |          Phone            Fax
WWW:   http://www.htsoft.com/    | USA: (408) 490 2885  (408) 490 2885
PGP:   finger EraseMEclydespam_OUTspamTakeThisOuThtsoft.com   | AUS: +61 7 3354 2411 +61 7 3354 2422
---------------------------------------------------------------------------
ANSI C for the PIC! Now shipping! See http://www.htsoft.com for more info.

1998\03\04@045545 by Orin Eman

flavicon
face
> On Tue, Mar 03, 1998 at 07:04:35PM -0400, Bob Smith x31105 wrote:

> > for this beasty leaves me with the belief that I can't use ROM address
> > space for data?!?!  somebody tell me I'm blind and haven't read the
> > correct page!

> You're very nearly right; data tables on a mid-range PIC are implemented
> as RETLW tables, indexed by an addwf PCL. For example:

> table     addwf   pcl
>           retlw   1
>           retlw   2

Best set PCLATH too ie.:

table   movlw   HIGH table
       movwf   PCLATH
       addwf   pcl, f
       retlw   1
etc.

If you don't, and PCLATH doesn't point to the same 256 byte page
as the table, your program will be lost...

Now how did I find that out?

Orin.

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...