What memory is used for DATA @X, LONG $XXXXXX


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2017
    Posts
    17

    Default What memory is used for DATA @X, LONG $XXXXXX

    If one uses the DATA command to write to EEPROM at program time and are writing a LONG variable, how many bytes are used in memory and what locations are used. The memory is organized in bytes and writing DATA @0, $FF writes to the 1st byte of memory. If instead DATA @0, LONG $FFFFFFFF, does this write to eeprom locations 0,1,2 and 3 or is the memory managed by the PIC such that memory location 0 is a long and the next memory location is 1 which will also be a long?

    Thanks

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,517


    Did you find this post helpful? Yes | No

    Default Re: What memory is used for DATA @X, LONG $XXXXXX

    If you write a LONG to EEPROM it will occupy 4 bytes or "locations". So if your LONG starts at 0 the next free byte/location will be at adress 4.
    To be honest I'm not sure about the "order", ie little vs big endian but that's easy enough to test.

    /Henrik.

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: What memory is used for DATA @X, LONG $XXXXXX

    This should give you some idea how it is orginized.

    It explains itself. I captured the values 4 times, and the picture shows all 4 values.

    Code:
    LongVal var long
    ByteVal0 var byte
    ByteVal1 var byte
    ByteVal2 var byte
    ByteVal3 var byte
    
    
    Test:
        
    '%00000000 00000000 00000000 00000001
    '%00000000 00000000 00000001 00000000
    '%00000000 00000001 00000000 00000000
    '%00000001 00000000 00000000 00000000
    
        longval = %00000000000000000000000000000001  '32-bit value.
                    
        write 0, long longval
        
        read 0, byteval0
        read 1, byteval1
        read 2, byteval2    
        read 3, byteval3
            
        lcdout $fe,1,"LongVal:", dec longval
    
        lcdout $fe,$94,"10:",bin8 byteval1," ",bin8 byteval0
        lcdout $fe,$D4,"32:",bin8 byteval3," ",bin8 byteval2
        
        pause 100
    
    
    
    
        goto test
    Attached Images Attached Images  
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. linear data memory & large data arrays
    By ronsimpson in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 28th June 2011, 00:21
  2. Replies: 11
    Last Post: - 17th August 2010, 17:45
  3. LONG Data type
    By TerdRatchett in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th February 2009, 05:06
  4. Replies: 4
    Last Post: - 2nd March 2007, 07:12
  5. Use internal program memory like DATA memory
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th December 2006, 19:38

Members who have read this thread : 1

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