Originally posted by: daveh@cbmvax.cbm.UUCP (Dave Haynie)
Article-I.D.: cbmvax.988
Posted: Thu Nov 13 12:51:32 1986
Date-Received: Thu, 13-Nov-86 21:48:51 EST
References: <156@uwslh.UUCP>
Organization: Commodore Technology, West Chester, PA
Lines: 59
>
> The problem: passing 'char' variables by value to procedures. It took
> me a year to discover this, and after I changed how I was passing chars, I
> haven't had problems since. I have talked with several people VERY familiar
> with C, and this is what we have come up with. Apparently, when C (in
> general)> passes a char variable, it is expanded to the size of an int,
> pushed on the stack, the procedure is called, the variable (now size int)
> is popped off, and it is 'decomposed' down to a char size again.
Just a point here - while I wouldn't be surprised if the method you
describe is actually what C-Power does, being thet you're running on a
6510, that has nothing to do which C language in general. This is a
compiler implementation detail, and will change from machine to machine.
On the Amiga, for instance, the first several parameters in a function
call are passed in machine registers, not on the stack.
> However, C-power seems to leave out the 'decomposition' step...
> Chris Lishka /lishka@uwslh.uucp
> Wisconsin State Lab of Hygiene -lishka%uwslh.uucp@rsch.wisc.edu
> \{seismo, harvard,topaz,...}!uwvax!uwslh!lishka
I don't actually own C64 C-Power, though I played with a friend's copy
about a year ago for a weekend. I didn't run across this bug, but I
encountered another compiler error. It seems if I were to use either:
#define BYTE char;
or
typedef char BYTE;
and then create a function like:
BYTE Wombat(x,y,x)
BYTE x,y,z;
{...}
The compiler would choke, claiming some sort of syntax error. I think this
was fixed in later versions, and the best way to find out about any of
the compiler upgrades or any other information is to call the C-Power BBS,
the number should be in the front of your manual. The BBS is in Canada,
and they (as of last I heard) only support Punter (often pronounced
Punt-Her) protocol. I've been considering the C-128 version of the
C-Power compiler; its a really good compiler, very fast, and the editor
with error checking is really nice. Then again, I have all these Amiga
around to write C code on...
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dave Haynie {caip,ihnp4,allegra,seismo}!cbmvax!daveh
"Laws to supress tend to strengthen what they would prohibit.
This is the fine point on which all the legal professions of
history have based their job security."
-Bene Gesserit Coda
These opinions are my own, though for a small fee they may be yours too.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~