Shop OBEX P1 Docs P2 Docs Learn Events
Need little help in Spin coding — Parallax Forums

Need little help in Spin coding

SapiehaSapieha Posts: 2,964
edited 2007-09-15 23:12 in Propeller 1
Hi All
·
Help my.
·
I portar my C code to Propeler spin and can’t convert it to Spin.
·
while(*the_string !="\0")
·

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sapieha

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2007-09-15 18:44
    Not too obvious..
    And I assume you mean '\0' rather than "\0"...
     REPEAT WHILE BYTE[noparse][[/noparse]the_string]
    
    


    or
     REPEAT WHILE BYTE[noparse][[/noparse]the_string]<> 0
    
    


    or
     REPEAT UNTL BYTE[noparse][[/noparse]the_string] == 0
    
    


    "the_string" is a pointer; don't forget to increment it (++)
  • SapiehaSapieha Posts: 2,964
    edited 2007-09-15 19:07
    Hi deSilva
    Thanks

    It is corect ????

    repeat i from i to i < yme|i++
    ' for (i=0|i < yme|i++) ' // 10 bytes per char 15
    '{ //
    Mask := $80
    j := x
    repeat j from j to j < (x + xme)|j++
    'for (j=x|j < (x + xme)|j++)
    '{ //
    z := y + i
    ' //
    if (@Data & Mask)
    '{ //
    LCD_PixelPut (j,z,fcolor)
    '} ' //
    if not (@Data & Mask) ' else
    '{ //
    LCD_PixelPut (j,z,bcolor)
    '} ' //
    Mask>>=1
    '} //
    Data++
    x+=xme
    the_string++
    '}

    REPEAT WHILE BYTE[noparse][[/noparse]@the_string] == 0 ' //· while(@the_string !="\0") keep spitting chars until end
    ' //
    SendLcd(LCDCommand,nNOP) '· //· Recomended to send now and then



    Prppeller Tools compile it ! but I still not run it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sapieha

    Post Edited (Sapieha) : 9/15/2007 7:21:32 PM GMT
    1092 x 681 - 62K
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-15 19:33
    Sapieha said...
    Hi deSilva
    Thanks

    It is corect ????
    Sorry, no - most of it is simply poppycock.
    repeat i from i to i < yme|i++ ' for (i=0|i < yme|i++) ' // 10 bytes per char 15
    
    


    C has no nice for loops; SPIN has - please look into the manual
    correct would be: REPEAT i FROM 0 TO yme-1

    j := x
    repeat j from j to j < (x + xme)|j++ 'for (j=x|j < (x + xme)|j++)
    
    


    correct would be: REPEAT j FROM x TO x+yme-1

    if (@Data & Mask)
    
    


    What do you want to say with "@Data" ???
    if not (@Data & Mask) ' else
    
    


    Use ELSE by all means

    REPEAT WHILE BYTE[noparse][[/noparse]@the_string] == 0 ' //  while(@the_string !="\0") keep spitting chars until end
    
    


    This makes hardly any sense! Where is "the_string" incremented? You must use a pointer, to be de-referenced by BYTE[noparse][[/noparse]..]
  • SapiehaSapieha Posts: 2,964
    edited 2007-09-15 19:46
    Hi deSilva

    Sorry I have not manual till Propeller spin Programing.
    It is my first attemp to port my C code to spin.

    I only learn mig from code on forum and I know att it looks bad.


    Ps. Has not problem understand ASM coding but in ·spin I have little problem

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sapieha

    Post Edited (Sapieha) : 9/15/2007 7:56:16 PM GMT
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-15 20:06
    Sapieha said...
    Sorry I have not manual till Propeller spin Programing.

    Propeller IDE -> Help -> Propeller Manual
    Chapter 3 is extraordinary good!
  • SapiehaSapieha Posts: 2,964
    edited 2007-09-15 20:08
    Hi deSilva

    What do you want to say with "@Data" ???

    It is Variable to hold temporary address to pixel table on every character

    Where is "the_string" incremented?

    one rad before repeat

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sapieha
  • SapiehaSapieha Posts: 2,964
    edited 2007-09-15 20:27
    Hi deSilva

    If I use else Propeler tools talking it

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sapieha
    932 x 642 - 55K
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-15 20:28
    Sapieha said...
    >>What do you want to say with "@Data" ???
    > It is Variable to hold temporary address to pixel table on every character
    Maybe, but "@" makes no sense at all..
    said...
    >>Where is "the_string" incremented?
    >one rad before repeat
    This also makes no sense - it has do be done inside the repeat-loop.

    Please post your code again; when you sorround it by "[noparse][[/noparse] code ]" and "[noparse][[/noparse] /code]" it will also look nice.
  • SapiehaSapieha Posts: 2,964
    edited 2007-09-15 20:46
    Hi deSilva



    Thanks for help.
    It is entire code of my PUB routin.



    Look on picture

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sapieha
    947 x 963 - 80K
  • SapiehaSapieha Posts: 2,964
    edited 2007-09-15 20:53
    Ps. I most programing in ASM on IBM PC next language is C.
    Need little time to think Spin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sapieha

    Post Edited (Sapieha) : 9/15/2007 8:58:03 PM GMT
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-15 21:07
    All your REPEAT loops are terribly wrong! So take your time to think about it.
  • SapiehaSapieha Posts: 2,964
    edited 2007-09-15 21:17
    Hi deSilva

    I think about it but for it I most understand Spin programing.
    And it take up little time

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sapieha
  • SapiehaSapieha Posts: 2,964
    edited 2007-09-15 21:24
    Ps. I most find similar program on forum for study it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sapieha
  • SapiehaSapieha Posts: 2,964
    edited 2007-09-15 23:12
    Hi deSilva

    Look on attach code and give my acceptable solution if You wish.





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sapieha
Sign In or Register to comment.