Power-C & Ramdos (REU Ramdisk) finally possible w/out limitations

Started by hannenz, February 11, 2008, 02:25 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

hannenz

i love power-c.
i love my REU and ramdos.
they don't want to go together.
this drove me nuts.
i fixed it.

get it and read everything about these patches at http://people.freenet.de/hannenz/pwrc128rd.html

i know that this has always been an issue and noone seemed to ever have made the effort to supply suitable patches (like Adrian Pepper did way back then for Power-C 64 + Ramdos) - so i am a little proud to announce that Power-C and Ramdos now can go hand in hand flawlessly  providing another yet powerful feature for the Power-C environment!
C'mon people. Use POWER-C!!!! ;) :) :P

hydrophilic

This looks awesome!  I like your page that describes the problems and your solutions.  Plus it is in English so thanks a lot :)

I confess I have been afraid to use PowerC (or any C) because of reports of bloated code (like 1K for 'hello world').  But now I am tempted to try this... I just need to learn K&R syntax...

hannenz

Quote from: hydrophilic on February 11, 2008, 03:06 AM
This looks awesome!  I like your page that describes the problems and your solutions.  Plus it is in English so thanks a lot :)
thanks.
Quote
I confess I have been afraid to use PowerC (or any C) because of reports of bloated code (like 1K for 'hello world').
you can find such remarks often, and maybe its true...
in fact i just compiled

main()
{
    printf("hello world\n");
}

and the resulting executable binary has in fact 1741 bytes. on the other hand this is an overhead that gets remarkably relativized (is that english??) when writing larger programs since all that added overhead is added once and then used again by all the other code.
the actual object module from the above code has a code segment of just 56 (!)bytes pure ml code. That's what the actual main routine needs (the "hello world\n" string alone takes 12 bytes!). the rest is stuff like code for entering the function, returning from the function, managinng the runtime stack and the whole environment of the program at runtime. this is added ONCE for each program of course. So: those "hello world takes > 1K" statements are to be ignored. Try compiling hello world with gcc or any other compiler and look how big the excutable will be.
Of course a compiler adds a lot of overhead and can never ever compete with hand-written ml code but that's not why writing in C, in my opinion ;). And still, mixing C and ML is possible too, so you cayn still do the time-consuming jobs in ML while maintaining the whole prog's logic/ flow etc.  in C.
[/quote]
  But now I am tempted to try this... I just need to learn K&R syntax...
[/quote]
YESSS!
K&R is no black magic. just replace any function declaration in the ANSI-C form:

<retval> functionname (<parameter_list>)
{
/* body */
}

to

<retval> functionname (<parameter_list>)
<parameter_declarations>
{
/* body */
}

e.g.:

int main(argc, argv)
char **argv;
{
  /* code */
}

integers don't have to be declared outside the paranthesis, any parameters not declared there (argc in this example) is miplicitly declared as int.
Power-C has no real prototypes but as soon as you use the return value of a function on the left side of an assignment, you should add a line like:

char *malloc();

to let the compiler know, that malloc returns a pointer. though this is needed only if you use code like:

char *strchr();

*(strchr("hello world", 'o')) = '\0';

which one seldom does.

there are a few more quirks about Power-C being pre-ANSI but that's the stuff to get started with.
(struct members have no own namespace, no line continuation with '\', no string constant concatenation...)
ah, one more thing is important to know when starting:
builtin data types differ slightly from what we expect:
Power-C has:

char (8 Bit)
int (16-bit)
unsigned (16-bit)
long (16-bit)
pointer (16-bit)
float(5 byte)
double (5 byte)

Power-C has these hardcoded as default types; note the "unsigned" which in ANSI is a type modifyer. IN Power-C it is TYPE. (Power-C has no modifiers besides static, auto and register - which are storage classes, not modifiers - correct me if i'm wrong here...).

so there is no such thing like an "unsigned int"  in Power-C, it is simply (unsigned).
note also, that there are no signed chars as there is no unsigned long.
floats are BASIC-floats. float and double are synonyms.
Power-C has no void type but a "typedef char void;" will do in most cases. (i know it's dirty...)