Shop OBEX P1 Docs P2 Docs Learn Events
PASM Labels Used in Called Methods — Parallax Forums

PASM Labels Used in Called Methods

pjvpjv Posts: 1,903
edited 2013-06-09 20:04 in Propeller 1
Hi All;

In a Spin program, is there a better way to access the PASM labels of an object's methods other than using the "object#constant" reference procedure ?

In the Spin program, I wish to know the cog address of PASM labels of a ch routine, and find having to manually redefine a set of constants in the assembler program as the label address move around while I debug it to be a real pain.

Perhaps there is a trick I am unaware of.

Cheers,

Peter (pjv)

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2013-06-09 16:51
    I've been there but AFAIK there is currently no compile time solution other than constant definition. However, to avoid constant redefinition during the debug phase all my cog binaries have an (optional) translation/lookup table (screen resolution, entry points etc). IOW even if only the binary is distributed you can do a name lookup to get the relevant entry point(s).
  • Heater.Heater. Posts: 21,230
    edited 2013-06-09 17:35
    Doesn't this get you the PASM address of "label" at compile time? At the cost of a LONG in memory. Or are you after something else?
    DAT
            org  0
    enter   mov  0,0
            mov  0,0
    label   mov  0,0
            mov  0,0
            mov  0,0
    
    'PASM address of lable
    label_  long (@label - @enter) / 4
    
  • Heater.Heater. Posts: 21,230
    edited 2013-06-09 17:49
    OK scratch the above. I don't think I understand the question.
    What does "PASM labels of an object's methods" mean?. As far as I know methods don't have PASM labels what with not being PASM code.
  • pjvpjv Posts: 1,903
    edited 2013-06-09 19:04
    Thanks for the responses.

    Kuroneko, how do you (automatically) generate such a table ?

    Heater, I have a Spin program that wants to call one of several assembly methods in an object, using a common PUB to access them. The compiler knows the addresses of these entry points, but won't let me use their names in the parent that's calling them. Hence so far I'm obliged to use the 'object # constant' procedure to effect what I'm trying to do. And during debugging that is a real pain because the addresses all keep changing.

    It would seem to me to be a real benefit if constants could be allowed to inherit the address value of a PASM label. And while we're at it, to allow constants to have global assignments across all objects.

    Cheers,

    Peter (pjv)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-06-09 19:11
    Why don't you just use a jump table in your PASM block to access all of them, and just number them 0 to n-1?

    -Phil
  • kuronekokuroneko Posts: 3,623
    edited 2013-06-09 19:40
    pjv wrote: »
    ... how do you (automatically) generate such a table ?
    Not much to it really, it could look like this:
    DAT                                             ' translation table
    
    __table         word    (@__names - @__table)/2
    
                    word    set_scrn, set_font
                    word    set_crs0, set_crs1
                    word    set_plte, set_bgnd
    
                    word    res_x
                    word    res_y
                    
    __names         byte    "scrn", 0, "font", 0
                    byte    "crs0", 0, "crs1", 0
                    byte    "plte", 0, "bgnd", 0
    
                    byte    "res_x", 0
                    byte    "res_y", 0
    
    The first six entries are code entries from a PASM section in the same file, the last two just constants which identify the screen size. This table (in my case) is referenced from the binary header and some SPIN code extracts the relevant bits (see [thread=139112]DDK example[/thread]).
  • pjvpjv Posts: 1,903
    edited 2013-06-09 20:04
    Thanks.

    Phi...., I have done that, but it makes for a further level of indirection, increasing size and dropping performance. This is for use in my OS, and I want it to be as tight and responsive as I can get it. The assembler knows the addresses, so why not let them be used directly in the program's CONstant definition block.

    Marko.... I'll try your suggestion while I'm debugging.

    Cheers,

    Peter (pjv)
Sign In or Register to comment.