Catalina C statement syntax question
JaanDoh
Posts: 129
in Propeller 1
In spin we can write stuff like this...
I just used address 10 as a random number that popped in my head but my question relates to any address
And so each of the above statements plugs a value in to a memory location in Main Ram, be it a byte, word or long value.
How do I do the same thing in C?
I don't want to create a variable and assign the value to the variable,
I want to poke the value into a memory address...
I know that in Propeller C, with the aid of SimpleTools you can use stuff like HUBDATA
But what if, I want to use Catalina C? (because of its XMM support),
Because I'm guessing that wont work in Catalina C (unless the simpletools libraries are used? this is a guess because I just started with C...)
And I prefer to use Catalina's own library instead of simpletools,
As I would prefer to use the SImpletools library with Propeller C only.
Do I have to use an include file? and what include file do I use?
Is there keyword list with simple C samples describing syntax and usage?
Like a for dummies book?
Most times I resort to a google search, which although correct for most computer C programs, it doesn't usually work with a micro controller.
Is there a list of the functions supported by each of the include files in the library?
What is the exact folder location of the Library files included with the installation?,
Or is there ONE book that I can buy and it will contain everything?
Like a Propeller Bible or something?
I'm finding I'm spending more time trying to find the right syntax for stuff than actually working on the stuff.
Thanks.
Byte[10] := 65 Word[10] := 65 Long[10] := 65
I just used address 10 as a random number that popped in my head but my question relates to any address
And so each of the above statements plugs a value in to a memory location in Main Ram, be it a byte, word or long value.
How do I do the same thing in C?
I don't want to create a variable and assign the value to the variable,
I want to poke the value into a memory address...
I know that in Propeller C, with the aid of SimpleTools you can use stuff like HUBDATA
But what if, I want to use Catalina C? (because of its XMM support),
Because I'm guessing that wont work in Catalina C (unless the simpletools libraries are used? this is a guess because I just started with C...)
And I prefer to use Catalina's own library instead of simpletools,
As I would prefer to use the SImpletools library with Propeller C only.
Do I have to use an include file? and what include file do I use?
Is there keyword list with simple C samples describing syntax and usage?
Like a for dummies book?
Most times I resort to a google search, which although correct for most computer C programs, it doesn't usually work with a micro controller.
Is there a list of the functions supported by each of the include files in the library?
What is the exact folder location of the Library files included with the installation?,
Or is there ONE book that I can buy and it will contain everything?
Like a Propeller Bible or something?
I'm finding I'm spending more time trying to find the right syntax for stuff than actually working on the stuff.
Thanks.
Comments
What you want to research is pointers.
The only way to be productive with any language is to understand the intricacies of its syntax.
Based on a bit of Googling, you might try either of these approaches.
EDIT: I think you could also write Word[10] as ((short *)0)[10], so you could do something like this: C is case-sensitive so Long and long are two different symbols.
Thank you Ray,
I had thought after using simpleide that it was some special technique to write to the ram,
like a special method to write to main ram and another special method to write to cog ram,
specifically to address the Propeller hardware.
So I was simply confusing myself...
Thank you JonnyMac,
It was the pointers area of C that confused me most,
But I did a quick google for the book and think I've found, it...
I've sent you a PM regarding that...
I'll just buy that one if its the right one, its a second edition though?
And pointers.... Gosh how much that has troubled me...
Not the understanding, because I know what a pointer is, but the syntax formatting of the command,
Like in your example above, Some variables/names have an asterisk to the left, and in other places to the right,
but it's no worry now, Once I get the book I should be fine and cheers too!!
Thank You Dave,
The literal translation helps, since that conversion (of a spin object to C) effort that i has a go at the other day is my first ever serious attempt at C...
But wow! Gosh your example with the #define definitions is just superior to everything else, it just makes it look so easy, and so simple to understand...
That's the method I will use, since a simple definition means I can keep the old syntax of Byte[N] = X and it seems much more friendly to look at 1, 2, 3 years down the line.
Currently I look at stuff I wrote 15-20 years ago and scratch my head and wonder whats going lol (its commented but not commented enough sadly)