Jump to content



Photo
- - - - -

Wsc & Fvm V1.2 - Casio Fx-9860 Series On-calc C Compiler


  • Please log in to reply
28 replies to this topic

#1 Wudy

Wudy

    Newbie

  • Members
  • Pip
  • 13 posts

  • Calculators:
    fx-9860gii

Posted 25 June 2012 - 05:58 AM

Hello !

(sorry for my poor English, I'm from China).

I released WSC & FVM v1.2, and translated the documentation to english.
WSC is a on-calc C compiler, I add many functions to it, now you can use it like the 9860 SDK on computer.


there is a deom, the program is written in C on my calculator:



download:
http://code.google.c...t...mp;can=2&q=

Edited by Wudy, 25 June 2012 - 08:33 AM.

  • flyingfisch and Casimo like this

#2 Wudy

Wudy

    Newbie

  • Members
  • Pip
  • 13 posts

  • Calculators:
    fx-9860gii

Posted 25 June 2012 - 06:04 AM

I want to entry the summer contest with the compiler
what should i do?

Edited by Wudy, 25 June 2012 - 06:04 AM.


#3 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 25 June 2012 - 01:55 PM

Hello Wudy and welcome to UCF!

You should introduce yourself here when you get a chance. ;)


I think you can open a thread (like this one) and as long as the file is in zip format, you should be ok. :)

And this is an awesome project, by the way.

How big is the addin itself? And does it have custom libraries or does it use the official casio ones? Does it come with a grayscale library?




Oh, and your english is fine! :)

#4 Forty-Two

Forty-Two

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 528 posts
  • Gender:Male
  • Location:Well, The sign says "You are here"...

  • Calculators:
    Casio fx-CG10 Prizm
    Casio fx-9860GII
    TI-84+ SE

Posted 27 June 2012 - 07:37 PM

Make sure that everything is in a subfolder as well.

#5 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 27 June 2012 - 07:38 PM

Make sure that everything is in a subfolder as well.


(In the zip file) ;)

#6 Wudy

Wudy

    Newbie

  • Members
  • Pip
  • 13 posts

  • Calculators:
    fx-9860gii

Posted 29 June 2012 - 08:36 AM

How big is the addin itself? And does it have custom libraries or does it use the official casio ones? Does it come with a grayscale library?


the addin is about 110kb, it use the official casio libraries, it has not a grayscale library yet..

#7 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 29 June 2012 - 12:21 PM

OK.

How does it compile code? Does it compile it the same way a computer would?

#8 Xerxes

Xerxes

    Casio Freak

  • Members
  • PipPipPipPip
  • 130 posts
  • Gender:Male

Posted 07 July 2012 - 12:43 PM

How does it compile code? Does it compile it the same way a computer would?


WSC compiles to bytecode of a virtual machine to be executed by FVM bytecode interpreter.
The CASIO SDK compiles to native sh3 code that's surely much faster but not on-calc.

#9 MicroPro

MicroPro

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 640 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    Casio ClassPad 300

Posted 07 July 2012 - 05:02 PM

It would be a good idea if FVM compiles its bytecode to SH3 before executing. Wudy, do you have any plans for this?

(Wudy should be here with the news of releasing version 1.3 of his compiler soon. :) )
  • Casimo likes this

#10 Forty-Two

Forty-Two

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 528 posts
  • Gender:Male
  • Location:Well, The sign says "You are here"...

  • Calculators:
    Casio fx-CG10 Prizm
    Casio fx-9860GII
    TI-84+ SE

Posted 07 July 2012 - 06:37 PM

JIT gogogogogo

#11 Wudy

Wudy

    Newbie

  • Members
  • Pip
  • 13 posts

  • Calculators:
    fx-9860gii

Posted 11 July 2012 - 08:31 AM

It would be a good idea if FVM compiles its bytecode to SH3 before executing. Wudy, do you have any plans for this?

(Wudy should be here with the news of releasing version 1.3 of his compiler soon. :) )


Sorry, i'm unfamiliar with SH3 ASM, so it may not come true.

Well, i live up to your expectation. The new version is released!

download

What's new:
* 2012 – 07– 11 version 1.3
- Add functions about overclock, RTC, file finding, call fvm program
( They are cpuspeed, readrtc, setrtc, findfirst, findnext, findclose, exefvm, getfvmmsg )
- Add bitwise function
( They are bitand, bitor, bitxor, bitnot, shiftl, shiftr )
- Add hexadecimal constant supporting
- Add big font for IO interface( see Notice & Tips )
- Optimize the source code of FVM( thanks to chuxianbing )
- Cancel automatic initialization for the random number seed
( now you should set the seed of rand() by yourself with srand(), you can use RTC functions )
- Fix bug( optimizing error )
- Others

#12 MicroPro

MicroPro

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 640 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    Casio ClassPad 300

Posted 20 July 2012 - 06:04 PM

Wudy, your program seems nice. I looked at your source code and it seems somehow professional. B) I'm curious if you've had academic learning about compilers or you got inspirations from other compilers?

I have something to say about the differences with C: This difference: int * a, bï¼› makes programs harder to port to WSC. It would be nice if you make it work like standard C!

Sorry, i'm unfamiliar with SH3 ASM, so it may not come true.

Do you need some help? I'm writing some program about the assembly and I think I can help if you let us know more about the FVM virtual machine. For example its instruction set, memory model, etc.

#13 Wudy

Wudy

    Newbie

  • Members
  • Pip
  • 13 posts

  • Calculators:
    fx-9860gii

Posted 22 July 2012 - 07:10 AM

Fix a serious bug!

* 2012 – 07 – 22 version 1.3 patched
- Fix bug(WSC don't transform integer actual parameters to float formal parameters ,thank chuxianbing)

Download

#14 Wudy

Wudy

    Newbie

  • Members
  • Pip
  • 13 posts

  • Calculators:
    fx-9860gii

Posted 22 July 2012 - 07:47 AM

Wudy, your program seems nice. I looked at your source code and it seems somehow professional. B) I'm curious if you've had academic learning about compilers or you got inspirations from other compilers?


I'm only a high school student... I have not had academic learning about compilers. But A wonderful book - "Compiler Construction- Principles and Practice" by Kenneth C. Louden taught me a lot.

I have something to say about the differences with C: This difference: int * a, bï¼› makes programs harder to port to WSC. It would be nice if you make it work like standard C!


I will have a try!

Do you need some help? I'm writing some program about the assembly and I think I can help if you let us know more about the FVM virtual machine. For example its instruction set, memory model, etc.


Yes! I want to learn about the SH3 ASM.
You can see /src/FVM/fvm.h(lines 4-21) and /src/FVM/iset.txt to know a little bit about the instruction set.
For memory model, i don't know how to describe it...
FVM has 16 integer registers and 16 float registers.(the bytecode generated by WSC just use some of them)

Edited by Wudy, 22 July 2012 - 07:48 AM.


#15 MicroPro

MicroPro

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 640 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    Casio ClassPad 300

Posted 25 July 2012 - 11:52 AM

Yes! I want to learn about the SH3 ASM.

Do you know any other assembly language? In my opinion SH assembly is one of the easy ones.

Do you have the Renesas SH3 documents?

You can see /src/FVM/fvm.h(lines 4-21) and /src/FVM/iset.txt to know a little bit about the instruction set.

FVM has a small set of instructions and almost everything is done via interrupts. This makes things easy. The instructions are fundamental and most of them map exactly to one SH instruction. This is good too.

For memory model, i don't know how to describe it...

For example where does it start, how big is it, are there separate memories and memory parts or just one? Where is RAM_SIZE initialized in your code? I couldn't find it :(

FVM has 16 integer registers and 16 float registers.(the bytecode generated by WSC just use some of them)

So normal registers can be mapped directly to SH3 registers ;) (not sure about those used in function calling) But since SH3 doesn't have float registers, there will be difficulty with them.

Wudy, in your preprocessor, WSC\prepro.c line 108, i thought the correct word is "pragma", not "progma" !

There are some unused variables in your code also, e.g in fvm.h:

Line 22: extern const char *codeToStr[];
Line 229: #define CAST_INT(a) (*(int *)(a))
Line 230: #define CAST_FLOAT(a) (*(float *)(a))

What's the use of these?

#16 Wudy

Wudy

    Newbie

  • Members
  • Pip
  • 13 posts

  • Calculators:
    fx-9860gii

Posted 26 July 2012 - 12:47 PM

Do you know any other assembly language? In my opinion SH assembly is one of the easy ones.

Do you have the Renesas SH3 documents?

I know a little about 8086 ASM and I don't have the documents.

For example where does it start, how big is it, are there separate memories and memory parts or just one? Where is RAM_SIZE initialized in your code? I couldn't find it

FVM programs has a 16-byte header, see src/fvm/fvm.h( lines 44-55 ).
RAM_SIZE initialized in fvm.c line 133
there are 2 parts memories:
One is BC, the address of bytecode.Another is RAM, store variable, temp variable, calling sequence.
As for the heap, I just use malloc() simply...

Wudy, in your preprocessor, WSC\prepro.c line 108, i thought the correct word is "pragma", not "progma" !

Oh...i am wrong! Thanks for correcting.

There are some unused variables in your code also, e.g in fvm.h:

Line 22: extern const char *codeToStr[];
Line 229: #define CAST_INT(a) (*(int *)(a))
Line 230: #define CAST_FLOAT(a) (*(float *)(a))

What's the use of these?

Line 22: extern const char *codeToStr[];
It's for debugging.There is a version for Windows, I use it for debugging. When I ported FVM to fx-9860, i deleted it.
Line 229: #define CAST_INT(a) (*(int *)(a))
Line 230: #define CAST_FLOAT(a) (*(float *)(a))
I use CAST_INT(RAM+6) to tanslate 4 bytes begin with RAM+6 to integer.
For example, the RAM is
0x12 0x5A 0xC5 0x4A 0x00 0x00 0x30 0x01 0x00 0xAC
CAST_INT(RAM+6) equal to 0x300100AC
but when I ported FVM to fx-9860, I found it did not work. because fx-9860 must read from aligned memory locations.( i.e. RAM + 4, RAM + 8, RAM + 12.. )
So I must use memcpy( RAM+6, &temp, sizeof(int) ); instead.

Edited by Wudy, 26 July 2012 - 01:47 PM.


#17 MicroPro

MicroPro

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 640 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    Casio ClassPad 300

Posted 27 July 2012 - 11:33 AM

I know a little about 8086 ASM and I don't have the documents.

I mean the datasheets. Especially the SH3 software manual at this link is the main manual that most of us read to know the SH3 and its assembly. Chapters 2,3,6,7,8 are the best refernce: http://documentation...0317_sh_3sm.pdf

Thanks for other explanations in your post as well.

#18 Wudy

Wudy

    Newbie

  • Members
  • Pip
  • 13 posts

  • Calculators:
    fx-9860gii

Posted 29 July 2012 - 05:35 AM

ASM is a little difficult for me..

#19 neptune45

neptune45

    Casio Fan

  • Members
  • PipPip
  • 44 posts
  • Gender:Male
  • Location:Madrid (Spain)

  • Calculators:
    fx-9860g Slim

Posted 29 August 2012 - 01:50 PM

Dear Wudy,

I have created a new version of the text editor to help the c coding on the calculator.

Now you can bind specific ascii characters to the keys, and they will be available after pressing VARS key.

This way you can have easier the characters more frecuently used that not available on the keyboard.

It is available here:
https://sourceforge....s/edit-fx9860g/

Regards,
Diego.

#20 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 06 January 2013 - 01:23 PM

Is this project still in developement?

#21 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 06 January 2013 - 10:38 PM

Is this project still in developement?


as far as i know, yes. ;)

#22 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 23 January 2013 - 01:22 PM

I can't wait for that. I found a bug: after I tried to compile 6kB of code (about 600 lines), WSC showed me SYSTEM ERROR.

#23 Forty-Two

Forty-Two

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 528 posts
  • Gender:Male
  • Location:Well, The sign says "You are here"...

  • Calculators:
    Casio fx-CG10 Prizm
    Casio fx-9860GII
    TI-84+ SE

Posted 28 January 2013 - 03:12 PM

I can't wait for that. I found a bug: after I tried to compile 6kB of code (about 600 lines), WSC showed me SYSTEM ERROR.


Can you pastebin the code?

#24 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 28 January 2013 - 03:20 PM

Copyright by me. It's a program for tex - to - morsecode converting (unfinished).
Edit: forgot to uncomment. Sorry.

#include <fxlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
char *ptr = 0;
char *msg = 0;
int lenght = 0;
int msglenght = 0;
void add(char c)
{
char *new = malloc(lenght + 2);
char *eof = new + lenght;
memcpy(new, ptr, lenght);
*eof = c;
eof += 1;
*eof = 0;
free(ptr);
ptr = new;
lenght += 1;
}
void set(char c)
{
char O = 0, X = 1, P = 2;
if(c == 'A' || c == 'a')
{
add(O);
add(X);
add(P);
return;
}
if(c == 'B' || c == 'b')
{
add(O);
add(X);
add(X);
add(X);
add(P);
return;
}
if(c == 'C' || c == 'c')
{
add(O);
add(X);
add(O);
add(X);
add(P);
return;
}
if(c == 'D' || c == 'd')
{
add(O);
add(X);
add(X);
add(P);
return;
}
if(c == 'E' || c == 'e')
{
add(X);
add(P);
return;
}
if(c == 'F' || c == 'f')
{
add(X);
add(X);
add(O);
add(X);
add(P);
return;
}
if(c == 'G' || c == 'g')
{
add(O);
add(O);
add(X);
add(P);
return;
}
if(c == 'H' || c == 'h')
{
add(X);
add(X);
add(X);
add(X);
add(P);
return;
}
if(c == 'I' || c == 'i')
{
add(X);
add(X);
add(P);
return;
}
if(c == 'J' || c == 'j')
{
add(X);
add(O);
add(O);
add(O);
add(P);
return;
}
if(c == 'K' || c == 'k')
{
add(O);
add(X);
add(O);
add(P);
return;
}
if(c == 'L' || c == 'l')
{
add(X);
add(O);
add(X);
add(X);
add(P);
return;
}
if(c == 'M' || c == 'm')
{
add(O);
add(O);
add(P);
return;
}
if(c == 'N' || c == 'n')
{
add(X);
add(O);
add(P);
return;
}
if(c == 'O' || c == 'o')
{
add(O);
add(O);
add(O);
add(P);
return;
}
if(c == 'P' || c == 'p')
{
add(X);
add(O);
add(O);
add(X);
add(P);
return;
}
if(c == 'Q' || c == 'q')
{
add(O);
add(O);
add(X);
add(O);
add(P);
return;
}
if(c == 'R' || c == 'r')
{
add(X);
add(O);
add(X);
add(P);
return;
}
if(c == 'S' || c == 's')
{
add(X);
add(X);
add(X);
add(P);
return;
}
if(c == 'T' || c == 't')
{
add(O);
add(P);
return;
}
if(c == 'U' || c == 'u')
{
add(X);
add(X);
add(O);
add(P);
return;
}
if(c == 'V' || c == 'v')
{
add(X);
add(X);
add(X);
add(O);
add(P);
return;
}
if(c == 'W' || c == 'w')
{
add(X);
add(O);
add(O);
add(P);
return;
}
if(c == 'X' || c == 'x')
{
add(O);
add(X);
add(X);
add(O);
add(P);
return;
}
if(c == 'Y' || c == 'y')
{
add(O);
add(X);
add(O);
add(O);
add(P);
return;
}
if(c == 'Z' || c == 'z')
{
add(O);
add(O);
add(X);
add(X);
add(P);
return;
}
 if(c == '0')
{
add(O);
add(O);
add(O);
add(O);
add(O);
add(P);
return;
}
if(c == '1')
{
add(X);
add(O);
add(O);
add(O);
add(O);
add(P);
return;
}
if(c == '2')
{
add(X);
add(X);
add(O);
add(O);
add(O);
add(P);
return;
}
if(c == '3')
{
add(X);
add(X);
add(X);
add(O);
add(O);
add(P);
add(P);
return;
}
if(c == '4')
{
add(X);
add(X);
add(X);
add(X);
add(O);
add(P);
add(P);
return;
}
if(c == '5')
{
add(X);
add(X);
add(X);
add(X);
add(X);
add(P);
return;
}
if(c == '6')
{
add(O);
add(X);
add(X);
add(X);
add(X);
add(P);
return;
}
if(c == '7')
{
add(O);
add(O);
add(X);
add(X);
add(X);
add(P);
return;
}
if(c == '8')
{
add(O);
add(O);
add(O);
add(X);
add(X);
add(P);
return;
}
if(c == '9')
{
add(O);
add(O);
add(O);
add(O);
add(X);
add(P);
return;
}
if(c == ' ')
{
add(P);
add(P);
return;
}
 if(c == '.')
{
add(X);
add(O);
add(X);
add(O);
add(X);
add(O);
add(P);
return;
}
if(c == ',')
{
add(O);
add(O);
add(X);
add(X);
add(O);
add(O);
add(P);
return;
}
if(c == ':')
{
add(O);
add(O);
add(O);
add(X);
add(X);
add(X);
add(P);
return;
}
if(c == '?')
{
add(X);
add(X);
add(O);
add(O);
add(X);
add(X);
add(P);
return;
}
/*if(c == ''')
{
add(X);
add(O);
add(O);
add(O);
add(O);
add(X);
add(P);
return;
}*/
/*if(c == '"')
{
add(X);
add(O);
add(X);
add(X);
add(O);
add(X);
add(P);
return;
}*/
if(c == '-')
{
add(O);
add(X);
add(X);
add(X);
add(X);
add(O);
add(P);
return;
}
if(c == '/')
{
add(O);
add(X);
add(X);
add(O);
add(X);
add(P);
return;
}
if(c == '+')
{
add(X);
add(O);
add(X);
add(O);
add(X);
add(P);
return;
}
if(c == '=')
{
add(O);
add(X);
add(X);
add(X);
add(O);
add(P);
return;
}
if(c == '(' || c == ')')
{
add(O);
add(X);
add(O);
add(P);
return;
}
if(c == '@')
{
add(X);
add(O);
add(O);
add(X);
add(O);
add(X);
add(P);
return;
}
}
void analyt()
{
int x;
char c;
char *this;
char O = 0, X = 1, P = 2;
add(O);
add(X);
add(O);
add(X);
add(O);
add(P);
for(c = 0; x < msglenght; x += 1)
{
this = msg + x;
c = *this;
set(c);
}
add(X);
add(O);
add(X);
add(O);
add(X);
}
void display()
{
int l;
char c;
char *this;
for(l = 0; l < lenght; l += 1)
{
this = ptr + l;
c = *this;
if(c == 1)
{
fillbox(0, 0, 127, 63);
putdisp();
sleep(500);
allclr();
sleep(500);
}
if(c == 0)
{
fillbox(0, 0, 127, 63);
putdisp();
sleep(250);
allclr();
sleep(250);
}
if(c == 2)
{
allclr();
sleep(1000);
}
}
}
int main()
{
msg = malloc(30);
scanf("%s", ptr);
msglenght = 29;
analyt();
}

Edited by Casimo, 29 January 2013 - 04:13 PM.


#25 Wudy

Wudy

    Newbie

  • Members
  • Pip
  • 13 posts

  • Calculators:
    fx-9860gii

Posted 01 February 2013 - 05:01 AM

I am sorry to tell that I stopped developing WSC several months months ago..

Edited by Forty-Two, 01 February 2013 - 08:17 PM.
Please don't use unneccessary colors


#26 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 01 February 2013 - 07:26 AM

Oh, that's sad. WSC + FVM are awesome.

#27 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 01 February 2013 - 04:13 PM

I am sorry to tell that I stopped developing WSC several months months ago..


Do you plan on resuming any time soon?

#28 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 06 February 2013 - 06:39 PM

Is it possible to make an oncalc SDK with WSC? That would be incredible!

#29 MicroPro

MicroPro

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 640 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    Casio ClassPad 300

Posted 07 March 2013 - 06:21 PM

On-calc IDE would be great.

I once even thought about porting WSC,FVM to ClassPad. It is so useful for the more professional users.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users