Searching \ for '[PIC] : 18F452 table addresses' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/memory.htm?key=table
Search entire site for: ': 18F452 table addresses'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] : 18F452 table addresses'
2005\11\25@101900 by Phil Cross

picon face
I'm a beginner, trying to use an 18F452 as a controller. I have a problem,
although it may be my ignorance that prevents me seeing the solution. I read
around, but can't find how to do it.

I am using MPASM 7.2

I want to define a number of what I call "canned" messages in flash memory,
thus:

message1
    dw    "String1",0
message2
    dw    "String2",0
message3
    dw    "String3",0
etc.

(I use NULL as string terminator, and ensure even number of bytes in each
message.)

I want to be able to load TBLPTR with the label address of (say) message2,
and then use the 18F452
TBLRD + instruction to step through and read the message bytes, until I
reach NULL, while transmitting them on RS232.

What I don't understand is how I get the addresses of message1, message2
etc. in order to load them into TBLPTR. I need the equivalent of 'C' '&'
deferencing.

Is there such a thing, please? I don't want to have to ORG every message - I
want the compiler to take care of its location.

Regards, Phil.


2005\11\25@105223 by Thomas C. Sefranek

face picon face

-----Original Message-----
From: spam_OUTpiclist-bouncesTakeThisOuTspammit.edu [.....piclist-bouncesKILLspamspam@spam@mit.edu] On Behalf Of
Phil Cross
Sent: Friday, November 25, 2005 10:19 AM
To: piclistspamKILLspammit.edu
Subject: [PIC] : 18F452 table addresses

I'm a beginner, trying to use an 18F452 as a controller. I have a problem,
although it may be my ignorance that prevents me seeing the solution. I read

around, but can't find how to do it.

I am using MPASM 7.2

I want to define a number of what I call "canned" messages in flash memory,
thus:

message1
    dw    "String1",0
message2
    dw    "String2",0
message3
    dw    "String3",0
etc.

(I use NULL as string terminator, and ensure even number of bytes in each
message.)

I want to be able to load TBLPTR with the label address of (say) message2,
and then use the 18F452
TBLRD + instruction to step through and read the message bytes, until I
reach NULL, while transmitting them on RS232.

What I don't understand is how I get the addresses of message1, message2
etc. in order to load them into TBLPTR. I need the equivalent of 'C' '&'
deferencing.

Is there such a thing, please? I don't want to have to ORG every message - I

want the compiler to take care of its location.

Regards, Phil.


       CLRF        TBLPTRU        ; Set the Upper table pointer to 0x00.
       MOVLW        HIGH ARG1        ; Fetch the HIGH address of the table.
(message1)
       MOVWF        TBLPTRH        ; Set the High table pointer.
       MOVLW        LOW ARG1        ; Fetch the LOW address of the table.
(message1)
       MOVWF        TBLPTRL        ; Set the Low table pointer.

--


 *
 |  __O    Thomas C. Sefranek  .....tcsKILLspamspam.....cmcorp.com
 |_-\<,_   Amateur Radio Operator: WA1RHP
 (*)/ (*)  Bicycle mobile on 145.41MHz PL74.4

ARRL Instructor, Technical Specialist, VE Contact.
hamradio.cmcorp.com/inventory/Inventory.html
http://www.harvardrepeater.org


2005\11\25@144110 by Phil Cross

picon face
Thomas C. Sefranek said :

>      CLRF        TBLPTRU        ; Set the Upper table pointer to 0x00.
>
>      MOVLW        HIGH ARG1        ; Fetch the HIGH address of the table.
>(message1)
>      MOVWF        TBLPTRH        ; Set the High table pointer.
>      MOVLW        LOW ARG1        ; Fetch the LOW address of the table.
>(message1)
>      MOVWF        TBLPTRL        ; Set the Low table pointer.


Thank you, Thomas.  That is exactly what I wanted. I am now sending my
canned messages with great facility.

By the way, I found that using "dw" to define strings always ensures that
the string is NULL terminated, whether it has an odd or even number of
characters.

Also, for "deferencing" read "dereferencing".

Regards, Phil.


2005\11\25@190601 by olin piclist

face picon face
Phil Cross wrote:
> I'm a beginner, trying to use an 18F452 as a controller.

Go away.  Can't you see we're all busy arguing about top posting, bottom
posting, context posting and trimming.

(That was a joke, James)

{Quote hidden}

Sounds reasonable.

> What I don't understand is how I get the addresses of message1, message2
> etc. in order to load them into TBLPTR.

Read up on the LOW, HIGH, and UPPER assembler functions.  They let you pick
off a particular byte of a multi-byte value.  For example:

    movlw  low message1

will get the low byte of the address of your first string into W.  From
there it can be moved to TBLPTR.  Use HIGH and UPPER to get the other bytes
and do similar things with them.


******************************************************************
Embed Inc, Littleton Massachusetts, (978) 742-9014.  #1 PIC
consultant in 2004 program year.  http://www.embedinc.com/products

2005\11\26@093302 by Roy J. Gromlich - PA

picon face
Phil:

Just another variant of what you are using - call the procedure by name and ultimately the string goes out through the call to the Transmit procedure.

RJG

;--------------------------------------------------------------------------------------------------
SysName      dw " RTI IP_Relay V1.05.10.12.01 < 10:00 >",0x00
                       movlw HIGH(SysName)
                       movwf TBLPTRH
                       movlw LOW(SysName)
                       movwf TBLPTRL
Sys1               tblrd*+
                       movff TABLAT,TrnsByt
                       tstfsz TrnsByt
                       goto Sys0
                       return

Sys0               call Transmit
                        goto Sys1
;---------------------------------------------------------------------------------------------------
 {Original Message removed}

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