+ Reply to Thread
Results 1 to 3 of 3

Thread: Address Literal Value Syntax ??

  1. #1
    Licensed User RanOx's Avatar
    Join Date
    Oct 2007
    Location
    Lilydale, Australia
    Posts
    47

    Default Address Literal Value Syntax ??

    Colleagues,

    Is there a BAS Syntax for variable ADDRESS, rather than variable value.
    eg.
    Dim Fault_num_worst As Byte
    Fault_num_worst_EE EData As Byte 123

    temp_byte_0a = (Fault_num_worst - Fault_num_worst_EE) ;want ADDRESS, not variable VALUE

    I know there is a VARPTR(variable) function, but this excutes code at run time, rather than loading at compile time.

    I can use ASM "addlw" to load adresses (or difference in address in this example)
    eg.
    Asm ;do location maths.
    Movf eerom_ptr_0b,W ;INDEX (relative EEROM location) > Accum.
    Addlw Fault_num_worst - Fault_num_worst_EE ;add (difference between RAM address & EEROM address) to accum. (gets real RAM pointer in Accum.)
    Movwf FSR ;Accum. > indirect addressing register
    Movf temp_byte_0a,W; ;Byte (Read from EEROM) > Accum.
    Movwf INDF ;Accum. > RAM @ pointer address (indirect addressing)

    EndAsm


    I also use the AT Syntax to define a Symbol, but do not want to do this whenever I need the address of a variable.
    eg.
    Dim Ptr_Input_mV As Byte At input_mV
    ;address of input_mV variable
    Any ideas
    Thanks
    Alan.

    Hi, its great to see you visiting our forum. Why not try Proton Compiler for FREE?

    Download the FREE version of Proton Compiler, Its called Amicus18 and its available from HERE

    Already using proton Compiler??? Get rid of these pesky messages... get LICENSED USER STATUS




  2. If you're a Licensed user of PROTON DEVELOPMENT SUITE, apply for Licensed User Status to remove these pesky messages
     and get access to additional forum areas, Beta test downloads and more!

  3. #2
    Licensed User Tim's Avatar
    Join Date
    Jan 2003
    Location
    london
    Posts
    6,950


    Default Re: Address Literal Value Syntax ??

    I will try and answer this

    For starters lets identify the basics
    Fault_num_worst will be a variable
    Fault_num_worst_EE is a constant
    VARPTR(variable) is a constant of the address of "variable" and is know at compile time. What might be the issue though is at what point in the compile cycle it becomes known. So it might not work exactly the way you want it.

    I have to say I'm not 100% sure what you want to do so correct me if I go off track

    I presume you want to know the address of a variable at compile time so you can do some maths on it during the compile. The only way I think you can do this is to set the address your self and tell Proton were that is. What you can also do is reserve memory so you can be sure its safe using the stack allocation system.

    Dim MyVariable as Word at $100

    The other solution is to use the variable name in say asm much the same as I think you are doing in the example.

    HTH please point me right if I have your question wrong.
    Tim

  4. #3
    Licensed User RanOx's Avatar
    Join Date
    Oct 2007
    Location
    Lilydale, Australia
    Posts
    47


    Default Re: Address Literal Value Syntax ??

    Tim,
    Thanks for your attention.

    Fault_num_worst is a variable, but I wanted to use its ADDRESS, rather than its value.

    I am using arrays of mixed (Byte & Word) variable types in RAM, which are initialised from EEROM values. They are later updated in EEROM, if changed.

    I understood that there was no "compound" TYPE definition available in PDS, where I could define my own type (mix of Byte & Word), which could then be accessed by index (like a 2 dimensional array).
    In PIC16, I was reading from EEROM[index] and writing to RAM[offset + index], inside a FOR/NEXT loop.

    The index can be just the EEROM address (eg 24 .. 44).

    However to write to the RAM (can't use CWRITE with PIC16), I had to know the RAM array "offset", which is the difference between RAM & EEROM address (for appropriate matching variables).

    This was done with ASM, as partially ilustrated above.

    However, I was wondering if there was a BAS Syntax for similar.
    I have overcome (in PIC18 using 3.5.2.1), by using the AT format, as illustrated above. However, this requires an additional line per "requirement".

    Previoulsy I had manually defined the address-values after examing ASM, but this can get "messy", if I add a variable lower in RAM, which changed addresses.

    The VARPTR(var) adds run-time code, which was VERY tight in PIC16.

    No big issue, if there is no syntax for using the address, so be-it.

    Thanks
    Alan.

+ Reply to Thread

Similar Threads

  1. Address Literal Value Syntax ??
    By RanOx in forum Tips 'n Tricks
    Replies: 0
    Last Post: 2nd July 2011, 10:33
  2. give an address to pic on rs-485 network
    By talgo in forum Serial / Ethernet
    Replies: 9
    Last Post: 23rd September 2010, 06:23
  3. Better Syntax
    By fgcity in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 25th January 2008, 08:05
  4. Address Pointer
    By Toley in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 10th October 2007, 12:18

Members who have read this thread : 7

Actions :  (Set Date)

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts