Difference between revisions of "WSC and FVM"

From Casio Universal Wiki
Jump to: navigation, search
(int getfree( int type, int *freebytes ))
(File name format)
Line 726: Line 726:
 
Returns 0 on success. In case of failure it return a negative number
 
Returns 0 on success. In case of failure it return a negative number
  
=====File name format=====
+
===File name format===
  
 
==Feedback==
 
==Feedback==

Revision as of 15:27, June 21, 2012

Contents

Getting Started

Copy the two files inside the bin folder (WSC.g1a, FVM.g1a) to the calculator. In order to edit the source code on calc, you may need to use the EDITv1.51, of course, you can also edit the source code on the computer, it is plain text.

After the installation is complete, the main menu should be as follows:

Wsc-fvm-installed.jpg

Making a hello world

Open the EDIT, the storage Mem (Warning: Do not use the Main Mem) and create a new document.

Wsc-fvm-hello-c.jpg

Enter the text:

void main( )

{

    printf( “Hello World!\n” );

}

(PS the edit can adjust the font size (shift-set up to enter the setting interface), use the small print on one screen you can see more code, it is recommended to use the small print, set the font size in the optn other Word the wrap is also recommended to choose the offrecommended settings below)

Edit-settings.png

The input is completed as follows:

Wsc-fvm-hello-c-code.jpg

To compile the file, exit, enter the WSC, press the F1 (compile) to compile the source code.

Wsc-fvm-compile-file.jpg

If there are no error, the screen output is done, if there are errors you can return to EDIT to modify. Upon completion any key to exit into the FVM, the F1 (run) the implementation of the bytecode. The screen will output hello world. After the implementation of any key to exit.

Wsc-fvm-hello-f.jpgWsc-fvm-run-hello.jpg

WSC Support the C language features

The operator

+ - * / % += -= *= /= < <= > >= == != && || ! != &

Note that the last '&' is the address instead of a bitwise

Data type

Any number of dimensions in an int a char a float array to point to the basic types of pointer (pointer to the array)

Statement

If the else the while for the return the break

Notes

C style / * ........... * / and C + + style / / ...........

The function

Support recursion, a detailed list of library functions, see library.html

Preprocessor

Simple macro replacement (with parameters) a #define, #include (not a real file contains internal use only)

WSC Error reporting

Wsc error reporting is not perfect, calculator small screen is not easy to display all error messages.

Wsc will be displayed on the screen when the error is detected, the error message, as shown:

Wsc-error-reporting.jpg

Then press the menu key you can exit to modify the other key to display the next error message.

Note that WSC did not prompt a warning!

Any pointers, arrays, in its eyes are the same, any assignment.

int, a char, float, assignment, will not generate any warning messages.

Some differences in the WSC with the standard C

Does not require the function declaration

As long as the function is defined in the file, regardless of location, can call anywhere.

Only two scopes

The entire procedure only two scope, global scope and function within the local scope.

void main()

{

int a;

{

    int a;

}

}

The example program will receive an error message "Variable 'a' redefinition"

int * a, b;

WSC a and b will be a pointer to int. (It is recommended that written int * a, b; instead of int * a, b;).

int *p; p++;

The actual value of p in the ANSI C plus 4 (sizeof (int)), but WSC will only p plus 1.

char s[50] = “asdfjkl”;

This initialization is not yet supported, sample sentence is wrong.

int a[2][2] = { 1, 2, 3, 4 };

Int a [2] [2] = {1, 2, 3, 4};

This initialization is not yet supported, sample sentence is wrong. Multidimensional array initialization must be properly grouped, such as

int a[2][2] = { {1, 2}, {3, 4} }; grouped correctly less some elements correctly, such as

int a[2][2] = { {1}, {3} };

Notice & Tips

int a[10];printf( “%d”, a );

The code writer's intent is to obtain the value of a, but as mentioned above, the WSC seen as a type of all pointers, printf library function is overloaded, and the second parameter is a pointer to a function only printf (char *, char *), so the compiler to do a wrong choice, a look has become a char *.

A correct approach is: int a[10]; int t = a; printf( “%d”, t );

char ch;scanf( “%c”, &ch );

For some reason, such an approach to problems, it is recommended to use getchar ();

Enter the uppercase letters

Press F6 in the input interface switch case.

FVM will automatically initialize the random number seed

Does not require the programmer calling the srand ()

Enter the uppercase letters

Press F6 in the input interface switch case

Set up multiple strong back

#progma FORCE_BREAK

Anywhere in the source code to add the above statement, you can hold down the F1 + F2 + F6 to force quit the program execution.

List of library functions

Has now completed most of 9860 to support the c standard functions, the next version will be added to the SDK functions.

printf, sprintf, scanf, sscanf is the overloaded function. Note that they do not have a variable argument list


stdio.h

int printf( char *format, int val )

int printf( char *format, float val )

int printf( char *format, char* val )

int sprintf( char *buffer, char *format, int val )

int sprintf( char *buffer, char *format, float val )

int sprintf( char *buffer, char *format, char* val )

int scanf( char *format, int *address )

int scanf( char *format, float *address )

int scanf( char *format, char *address )

int sscanf( char *buffer, char *format, int *address )

int sscanf( char *buffer, char *format, int *address )

int sscanf( char *buffer, char *format, float *address )

int getchar( void )

int putchar( int c )

ctype.h

int isalnum( int c )

int isalpha( int c )

int iscntrl( int c )

int isdigit( int c )

int isgraph( int c )

int islower( int c )

int isprint( int c )

int ispunct( int c )

int isspace( int c )

int isupper( int c )

int tolower( int c )

int toupper( int c )

math.h

float acos( float x )

float asin( float x )

float atan( float x )

float atan2( float x, float y )

float cos( float x )

float sin( float x )

float tan( float x )

float cosh( float x )

float sinh( float x )

float tanh( float x )

float log( float x )

float log10( float x )

float modf( float x, float *y )

float pow( float x, float y )

float sqrt( float x )

float ceil( float x )

float fabs( float x )

float floor( float x )

float fmod( float x, float y )

stdlib.h

float atof( char *str )

int atoi( char *str )

int rand( void )

#define RAND_MAX 32767

void srand( int seed )

void *calloc( int nelem, int elsize )

void *malloc( int size )

void *calloc( void *ptr, int size )

void free( void *ptr )

int abs( int x )

string.h

void memcpy( void *p1, void *p2, int n )

char *strcpy( char *s1, char *s2 )

char *strncpy( char *s1, char *s2, int n )

char *strcat( char *s1, char *s2 )

char *strncat( char *s1, char *s2, int n )

int memcmp( void *p1, void *p2, int n )

int strcmp( char *s1, char *s2 )

int strncmp( char *s1, char *s2, int n )

void *memchr( void *p, int c, int n )

char *strchr( char *s, int c )

int strcspn( char *s1, char *s2 )

char *strpbrk( char *s1, char *s2 )

char *strrchr( char *s, int c )

int strspn( char *s1, char *s2 )

char *strstrr( char *s1, char *s2 )

void memset( void *s, int c, int n )

int strlen( char *s )

void *memmove( void *s1, void *s2, int n )

WSC Functions

Use the following function definition needs to include fxlib.h
Graphics functions are memory operations and need to use putdisp() in the memory content output to the screen. The point of the abscissa range is 0 to 127, the vertical axis range is from 0 to 63.

void allclr( void )

Clear all memory

void areaclr( int x1, int y1, int x2, int y2 )

Clear the memory of the specified rectangular area, (x1,y1) is a rectangle the upper left corner, (x2, y2) is a rectangular bottom right corner.

void arearev( int x1, int y1, int x2, int y2 )

Rectangular area of the designated areas reversal wink, (x1,y1) is a rectangle the upper left corner, (x2, y2) is a rectangular bottom right corner

void putdisp( void )

Memory output on the screen.

void setpoint( int x, int y, char kind )

To the point (x,y) set the kind value determines eye color, 1 is black, 0 for white

int getpoint( int x, ing y )

Return to point (x,y) wink, 1 is black, 0 is white

void drawline( int x1, int y1, int x2, int y2 )

Draw a (x1,y1) to (x2,y2) black line

void clearline( int x1, int y1, int x2, int y2 )

Draw a (x1,y1) to (x2,y2) white line

void drawcircle( int x, int y, int r )

In the (x,y) draw a radius r of the hollow round

void fillcircle( int x, int y, int r )

In the (x,y) draw a radius r of the solid round

void drawbox( int x1, int y1, int x2, int y2 )

Draw a hollow rectangle (x1,y1) is a rectangle the upper left corner, (x2,y2) is a rectangular bottom right corner

void fillbox( int x1, int y1, int x2, int y2 )

Draw a solid rectangle (x1,y1) is a rectangle the upper left corner, (x2,y2) is a rectangular bottom right corner

void locate( int x, int y )

Set the output cursor position (x,y) where x is 1~21, the scope of y is 1~8

void print( char *str )

Output string at the cursor position

void printxy( int x, int y, char *str, int type )

(x,y) is the location of the output string type value equal to 1,anti-color is equal to 0

void printmini( int x, int y, char *str, int type )

(x, y) is the position of the output string (small font). You can see the type of the value in the table below:

MINI_OVER OVER
MINI_OR OR
MINI_REV Anti-Color
MINI_REVOR Anti-Color + OR

void savedisp( char num )

Memory to maintain a system area of a label num of num values ​​can only be SAVEPAGE1, SAVEPAGE2, SAVEPAGE3

void restdisp( char num )

Before with savedisp maintain memory re-set to the memory area

void popupwin( int n )

Pop up a window of n lines, n is in the range of 1 to 5

int openfile( const char *name, int mode )

The name is the file name ( see file name format )

mode define what is the open the way, only the following values

OPEN_R Reading a file
OPEN_W Write files
OPEN_RW Read and write files

If the open is successful, will return to a special file handle (handle), it is a greater than or equal to a value of 0

If the open fails, it will return an error code, it is negative!

int readfile( int handle, void *buf, int size, int readpos )

handle is the openfile the return value readpos began to read the position, if it is equal to -1, then in the last read to the end position Other parameters and return values ​​are similar with fopen

int writefile( int handle, void *buf, int size )

a handle is the openfile the return value, and other similar fwrite

int seekfile( int handle, int pos )

handle the openfile the return value pos specifies the location of the read and write files

Returns 0 on success, failure to return a negative number

int closefile( int handle )

Close the file

int getfree( int type, int *freebytes )

Read the remaining available memory.

type can only be the following values:

MAIN_FREE the main memory
STO_FREE storage memory
SD_FREE sd card

Equipment the remaining value of the space will be stored in freebytes point to an int value

Returns 0 on success. In case of failure it return a negative number

File name format

Feedback

If you found bugs, or have any suggestions, questions, you can post it at WSC and FVM Thread.

Special thanks to yangsc825 (testing and recommendations), helder7 (English documentation), Kenneth C. Louden ("Compiler Construction Principles and Practice").

Changelog

* 21-06-2012 version 1.2
- Add a simple pre-processor (now the #include)
- Add file manipulation and plotting functions
- Add to the bond strength rewind functions
- Add an optimized technology, test data, maximum speed increased by 10%
- Fixed some errors in the parameter passing
- Fix array initialization can only occur once error
- Fixed the error of the multidimensional array address
- Others...

* 07-06-2012 version 1.1
- Add most of 9860 to support the standard C function
- Add a full description of document
- Add multi-dimensional array initialization
- Add transfer the character '\ t'
- Improve the stdio, to support multi-line input, uppercase letters
- Improve the error message, more friendly
- Fixed main, not the return 0 mistakes
- Fixed errors in some of the parameters passed
- Fixed a global variable, function, character constants can not be the same name error
- Repair evaluation stack stack stack error
- Other

* 28-05-2012 version 1.0
- Preview Release