Post by RajWHi Ian,
Post by iAN CooGtypedef unsigned char UC;
*(UC*)0xd020 = (UC)0x0f;
Thanks for your help. This is fun writing programs for the C64 after
all these years!
typedef char UC;
*(UC*)0xd020 = (UC)0x0f;
did work. So I'm guessing that "Power C" is brain damaged when it
comet to "unsigned". Should I worry about this? Thanks again!
/*Raj*/
In the manual for Power C (that I gave a link to in another posting in this
thread) it says:
"The following table lists the size in bytes of all data types supported
by the compiler:
Type Size
char 1
short 2
int 2
long 2
unsigned 2
float 5
double 5
pointer 2
Note that short, int, and long are synonyms, as are float and double.
Integers and pointers are stored low byte first, high byte last.
Float quantities are stored in the same format as BASIC variables."
Therefore, it seems like Power C has a special type for unsigned that is
always 2 bytes. You can't put unsigned in front of other types but you must
write only unsigned if you want to declare a variable as unsigned. This
doesn't comply to the C standard very well but as other people have pointed
out, this compiler predates the C standard.
At another place in the manual it says:
"Declare variables unsigned rather than int if they never contain
negative values. For example, variables which are used only as array
indices should always be declared unsigned."
I still don't understand how to read or write a byte. In standard C you
would use unsigned char but that is not possible in Power C. If char is
always signed it means that you can only PEEK or POKE values between -128
and 127. This for example means that if you want to POKE the value 255 you
would instead use -1 and 128 would be written as -128. This seems akward. I
guess some experimenting with Power C would give the answer on how to do it.