Shop OBEX P1 Docs P2 Docs Learn Events
[SOLVED] How to pass address of string to another cog — Parallax Forums

[SOLVED] How to pass address of string to another cog

Mark SwannMark Swann Posts: 124
edited 2008-08-29 17:38 in Propeller 1
I thought I knew how to do this.

I am simply trying to pass the address of a string, as returned by STRING(), to an assembly language routine in a separate·cog.

The cog routine should be getting a series of characters to display, but is getting garbage.

The following SPIN routine·is called with something like "Graphics.plotText(x,3,0, color, string(" Testing"))", and is attempting to pass the address of the string (named _str) to the cog routine by storing it in a variable named parm3. The cog routine·will retrieve the contents of parm3, along with parm1 and parm2. I can tell that the cog routine is clearly getting parm1 and parm2, but not parm3, or maybe it is getting parm3 but I am not passing the string address properly.

PUB plotText(_xC, _yC, _font, _color, _str) | t, x, y
'' Plot a string of characters into the video memory.
''
''  _xC        - Text column (0-11 for 8x8 font, 0-15 for 5x7 font)
''  _yC        - Text row (0-7 for 8x8 and 5x7 font)
''  _font      - The font, if 1 then 8x8, else 5x7
''  _color     - 8-bit color value (RRRGGGBB)
''  _str       - String of characters
''

  SetFont(_font)
  SetColor(_color)
  repeat while command
  parm1 := _xC
  parm2 := _yC
  parm3 := _str
               
  command := cmdPlotText
 

I cannot see what I am doing wrong. Any suggestions?

Mark

Post Edited (Mark Swann) : 8/29/2008 2:57:41 AM GMT

Comments

  • tpw_mantpw_man Posts: 276
    edited 2008-08-29 02:47
    Everything that you have provided looks okay. How big are the 'param' variables? They need to be at least word size to get the address properly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1011, so be surprised!


    Advertisement sponsored by dfletch:
    Come and join us on the Propeller IRC channel for fast and easy help!
    Channel: #propeller
    Server: irc.freenode.net or freenode.net
    If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
    tongue.gif
  • Mark SwannMark Swann Posts: 124
    edited 2008-08-29 02:52
    tpw_man said...
    Everything that you have provided looks okay. How big are the 'param' variables? They need to be at least word size to get the address properly.

    Good question. All the "parm" variables are "long".
    Thanks for responding.

    Mark
  • Mark SwannMark Swann Posts: 124
    edited 2008-08-29 03:01
    I found my problem.
    I'm embarrased to admit that, in my assembly code, I did not "de-reference" the pointer to parm3 in main memory. I used the address of parm3 as tha data to display. Silly me. cry.gif
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-08-29 17:38
    Simple errors get the best of us, I still on occasion forget to put an immediate (#) in front of the address in a jmp/djnz instruction.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.