PDA

View Full Version : Need little help in Spin coding



Sapieha
09-16-2007, 02:22 AM
Hi All
·
Help my.
·
I portar my C code to Propeler spin and can’t convert it to Spin.
·
while(*the_string !="\0")
·

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

deSilva
09-16-2007, 02:44 AM
Not too obvious..
And I assume you mean '\0' rather than "\0"...



REPEAT WHILE BYTE[the_string]



or



REPEAT WHILE BYTE[the_string]<> 0



or



REPEAT UNTL BYTE[the_string] == 0



"the_string" is a pointer; don't forget to increment it (++)

Sapieha
09-16-2007, 03:07 AM
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[@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

deSilva
09-16-2007, 03:33 AM
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[@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[..]

Sapieha
09-16-2007, 03:46 AM
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

deSilva
09-16-2007, 04:06 AM
Sapieha said...
Sorry I have not manual till Propeller spin Programing.


Propeller IDE -> Help -> Propeller Manual
Chapter 3 is extraordinary good!

Sapieha
09-16-2007, 04:08 AM
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

Sapieha
09-16-2007, 04:27 AM
Hi deSilva

If I use else Propeler tools talking it

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

deSilva
09-16-2007, 04:28 AM
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 "[ code ]" and "[ /code]" it will also look nice.

Sapieha
09-16-2007, 04:46 AM
Hi deSilva



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



Look on picture

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

Sapieha
09-16-2007, 04:53 AM
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

deSilva
09-16-2007, 05:07 AM
All your REPEAT loops are terribly wrong! So take your time to think about it.

Sapieha
09-16-2007, 05:17 AM
Hi deSilva

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

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

Sapieha
09-16-2007, 05:24 AM
Ps. I most find similar program on forum for study it.

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

Sapieha
09-16-2007, 07:12 AM
Hi deSilva

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





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