G850VS entering C ?

Talk in english

Modérateur : Politburo

Répondre
Richard
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 16
Inscription : 01 févr. 2015 12:10

G850VS entering C ?

Message par Richard » 28 févr. 2015 10:33

Hi...

I'd like to try writing C on this beast yet can't figure out the flow. Basic was easy.....press 'basic', type in your program, enter run mode and type 'run' !.

If I press 'C' I seem to get to some kind of complier menu with no way to enter a C program !?......HELP.

Regards

Richard
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 16
Inscription : 01 févr. 2015 12:10

Re: G850VS entering C ?

Message par Richard » 28 févr. 2015 15:16

I managed to work it out from a mix of French and Japanese documents.

Next issue....

printf ("hello ¥n");

Where ¥ is the yen symbol (shift-G). This just prints 'hello', so what is the ¥n for ??

Regards

Avatar de l’utilisateur
pir2
Fonctionne à 9600 bauds
Fonctionne à 9600 bauds
Messages : 3953
Inscription : 31 oct. 2006 16:08
Localisation : 67310 Westhoffen
Contact :

Re: G850VS entering C ?

Message par pir2 » 28 févr. 2015 16:10

"¥" is for "\" on the PC-G850 series ("\" is not availabe on this machine), and "\n" in C is for New Line.

If you type printf ("Hello"); then printf("world");, te result will be :

Code : Tout sélectionner

HelloWorld
Typing printf ("Hello¥n"); then printf("world");, te result will be :

Code : Tout sélectionner

Hello
World
Image
Image

Richard
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 16
Inscription : 01 févr. 2015 12:10

Re: G850VS entering C ?

Message par Richard » 28 févr. 2015 16:53

Thanks Pir2 !

To see the difference in speed between C and basic I entered a simple loop program with 10,000 iterations. A simple for loop in both cases. My C code being....

{Int i;
for (i=0; i <10000; i++){}
}

The result was......

Basic 10.5 seconds
C 4.4 seconds

At first I was pleased to see a doubling in speed yet it does not explain the amazing results from another website that uses a more complicated loop to compare various calculators and their built-in languages. Extract re the G850VS below.....

37.7   PC-G850VS       Basic
4.25   PC-G850VS         C / Unstructured / Bytecode
0.0353  PC-G850VS         Assembly / Z80 @ 8.0 MHz

Hence my C loop should have been in the region of 9 times faster !?. What is wrong with my C loop ?, was it wrong to define 'i' as 'int i' ?.

Regards

Avatar de l’utilisateur
doudou
Fonctionne à 300 bauds
Fonctionne à 300 bauds
Messages : 178
Inscription : 07 août 2013 13:36
Localisation : Grenoble

Re: G850VS entering C ?

Message par doudou » 01 mars 2015 20:21

Comparing languages is not that easy.

While it's almost obvious that compiled code runs faster than scripted, then there are many things that come into play, of which I can list:
- The compiler. 2 different compilers will give 2 different results on the same code+hardware.
- Compiler options (if the option exists, try -O3 when compiling your c program :wink: )
- Language "philosophy", that make some treatments more efficient in some languages compared to others (I saw some operations quicker in Java than C for example...on strings if I recall correctly)

Your loop is fine by the way.

Hope that clarifies a bit,
Roads? Where we're going, we don't need... roads.

Répondre

Revenir vers « Silicium in english »