Shop OBEX P1 Docs P2 Docs Learn Events
Spin feature request - Page 3 — Parallax Forums

Spin feature request

13»

Comments

  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-01-12 10:31
    @Peter: in you objectpassing.zip you are only changing the VAR offset, not the object offset. Is that what you want to do?

    Steven
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-01-12 10:35
    Steven,
    Yes, as d in file obj2 is of type obj1 and I want to call obj1 that is declared in main.
    So the object base is identical.

    regards peter
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-01-12 10:46
    @Peter: I'm not sure if spin nows to only include one copy of the object program when one of the copies is a sub-object of another sub-object. I think what your code is doing is including two copies of obj1 including code and variables. All you are doing is resetting the variable base for the copy in obj2 to point back to the variables in main. If you want to run the actual code in main then you will need to do the same thing with the object pointers as well as the variable pointers.

    Steven
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-01-12 11:01
    @Peter: just had a look at the code I posted before and
    PUB getObjectAddress(index)
    ' if index==1  'using the absolute addresses
    '  return word[noparse][[/noparse] @endOfObjects-4 ]
    ' elseif index==0
    '  return word[noparse][[/noparse] @endOfObjects-8 ]
    'or if you want the absolute address and not the offset (makes finding the new offset easier)
     if index==1
      return word[noparse][[/noparse] @endOfObjects-4]+$10 'the $10 is where the first object starts
     elseif index==0
      return word[noparse][[/noparse] @endOfObjects-8]+$10
    
    


    should have been
    PUB getObjectAddress(index)
    ' if index==1  'using the absolute addresses
    '  return word[noparse][[/noparse] @endOfObjects-4+2 ]
    ' elseif index==0
    '  return word[noparse][[/noparse] @endOfObjects-8+2 ]
    'or if you want the absolute address and not the offset (makes finding the new offset easier)
     if index==1
      return word[noparse][[/noparse] @endOfObjects-4+2]+$10 'the $10 is where the first object starts
     elseif index==0
      return word[noparse][[/noparse] @endOfObjects-8+2]+$10
    
    


    but I think you figured that out.

    Steven
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-01-12 11:30
    As far as I know, the methods and DAT area of an object are included only once in the compilation
    no matter how many instances you use of·that object. Only the VAR section is different
    for every instance of the object.

    regards peter
  • hippyhippy Posts: 1,981
    edited 2008-01-12 14:46
    @ Steven : Yes, only one copy of any object's executable code and DAT in hub memory no matter how many times or where the object is used.

    This is the trick which allows a "debugging object" to be included whereever it's needed without worrying about massively inflating the size of the code. The proof is had by adding more objects of the same type and using F8 to note memory use doesn't increase by much.
  • jazzedjazzed Posts: 11,803
    edited 2008-02-27 05:03
    hippy said...
    @ Steven : Yes, only one copy of any object's executable code and DAT in hub memory no matter how many times or where the object is used.

    This is the trick which allows a "debugging object" to be included whereever it's needed without worrying about massively inflating the size of the code. The proof is had by adding more objects of the same type and using F8 to note memory use doesn't increase by much.
    @Hippy, in the JVM development, we hit at least one exception to the rule.
    The problem is related to using a large array (everything's relative) about 16KB.
    Reorganizing how the file was included avoided the issue.
    See JVM for Prop page 4, Peter Posted 2/6/2008 10:16 PM (GMT -8)



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    jazzed·... about·living in·http://en.wikipedia.org/wiki/Silicon_Valley

    Traffic is slow at times, but Parallax orders·always get here fast 8)
Sign In or Register to comment.