Register

Instant syscall implementation (C)

Learn how to program. Code snippets for creating sprites etc. Submit your own or use those of others.
Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Instant syscall implementation (C)

Postby SimonLothar » Sat May 12, 2012 10:42 am

The following code is an example of how to implement a syscall without much effort using the CASIO SDK:
(f. i. to check out, if it is of some use, before you include it in your library and headerfiles)
After defining some function pointer types every syscall declaration needs two lines.

// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// NEVER try undocumented syscall numbers randomly!
// mostly the calc will do nothing or hang, if the parameters are not chosen correctly.
// but someday you will call the sector erase syscall, which will kill your calc permanently!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Code: Select all
// the following definitions are only needed once
#define SCA 0xD201D002
#define SCB 0x422B0009
#define SCE 0x80010070
// 0x80010070 is the fx-9860-syscall-entry point
// 0x80020070 is the fx-CG-syscall-entry point (but remember: the syscall numbers are different!)

// now define some function pointer types
// (for every syscall's interface a different function pointer type is required)
// the following type is for syscalls, which return an int and require no input.
typedef int(*sc_iv)(void);
// the following type is for syscalls, which return an int and require an int-pointer as input (like GetKey).
typedef int(*sc_ipi)(int*);

// example 1
const unsigned int sc0998[] = { SCA, SCB, SCE, 0x0998 };
#define App_DYNA (*(sc_iv)sc0998)

// now you could use
  App_DYNA();
// to call the built-in DYNA.

// or

// example 2
const unsigned int sc090F[] = { SCA, SCB, SCE, 0x090F };
#define GetKey (*(sc_ipi)sc090F)

// to call
  GetKey( &key );



for reference:
this are the assembler instructions, which represent the int arrays of the type
"const unsigned int scSyscallNo[] = { SCA, SCB, SCE, SyscallNo };"
Code: Select all
   mov.l   #h'80010070, r2
   mov.l   #SyscallNo, r0
   jmp     @r2
   nop
I'll be back!

Senior Member
Posts: 369
Joined: Tue Jan 03, 2012 11:24 pm
Calculators: Casio Afx 1.0, Casio fx-9860GII SD, Casio Classpad 330, Casio fx-CG20, Casio Classpad fx-CP400

Postby helder7 » Sat May 12, 2012 2:49 pm

thanks, useful for use new syscalls :rolleyes: that have not been added to sdk
SiO2 + CaCO3 ----------> CaSiO3 + CO2

Junior Member
Posts: 2
Joined: Sat May 05, 2012 2:05 pm

Postby scout » Sat May 12, 2012 4:11 pm

Great job Simon. In http://www.casio-scene.com/archive/index.php/t-1047.html (OLD thread warning!) you had written "Among about 4000 syscall-table entries some very interesting and well tested serial-, RTC-, keyboard- and display-functions (and then some) can be found." Did you actually research and document all 4000? (Impressive!) Would you share that list?

And just while I am playing around any list of syscall numbers I should avoid?

Senior Member
Posts: 369
Joined: Tue Jan 03, 2012 11:24 pm
Calculators: Casio Afx 1.0, Casio fx-9860GII SD, Casio Classpad 330, Casio fx-CG20, Casio Classpad fx-CP400

Postby helder7 » Sat May 12, 2012 4:19 pm

scout, syscall documentation is available here: http://www.casio-scene.com/downloads.php?do=file&id=270
;)
SiO2 + CaCO3 ----------> CaSiO3 + CO2

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Postby SimonLothar » Sat May 12, 2012 4:49 pm

scout wrote:Did you actually research and document all 4000?

No. I identified about 950 syscalls on the fx-9860-systems up to now. Some of them are not worth to be documented.

scout wrote:And just while I am playing around any list of syscall numbers I should avoid?

Yo, ho, ho! ;-) I am on this since January 2008. And I never gave away any information concerning the nasty syscall.
And I won't. My recommendation: do not play around! You will be occupied with experimenting around the documented syscalls.
I'll be back!

Junior Member
Posts: 2
Joined: Sat May 05, 2012 2:05 pm

Postby scout » Sat May 12, 2012 5:06 pm

Good stuff! Going through the docs now.

Member
User avatar
Posts: 23
Joined: Fri Apr 20, 2012 6:13 am

Postby Eiyeron » Mon May 14, 2012 6:24 pm

I think that all the syscalls in your help file should be documented, there are some that I find interesting
ImageImageImage
ImageImage

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Postby SimonLothar » Tue May 15, 2012 6:14 am

Eiyeron wrote:I think that all the syscalls in your help file should be documented, there are some that I find interesting
The complete documentation of a syscall involves several steps, which can be time-consuming. A very important thing is verification, t. i. writing a little program, testing it on serveral calculator-types or OSes, checking out every member of the assumed interface. Some of the interfaces have eleven-parameters. It is simply a matter of time, that not every syscall can be documented at once. Above that some of the syscalls are worthless for general use. Tell me the syscalls you are interested in and I will have a look.
I'll be back!

Senior Member
User avatar
Posts: 66
Joined: Sun Apr 15, 2012 4:00 pm
Calculators: Casio fx-9860G

Re: Instant syscall implementation (C)

Postby aapman55 » Mon Feb 11, 2013 7:39 pm

How do I use the syscalls where there are more int inputs? like [0x0A48: int App_GRAPH_TABLE( int R4, int R5 );]?
The SDK compiles the code when i do not call App_GRAPH_TABLE(0,1) in the main program. But when i do there is an error saying: C2202 (E) Number of parameters mismatch.

I did it this way:
Code: Select all
#define SCA 0xD201D002
#define SCB 0x422B0009
#define SCE 0x80010070
typedef int(*sc_ipi)(int*);
const unsigned int sc0A48[] = { SCA, SCB, SCE, 0x0A48 };
#define App_GRAPH_TABLE (*(sc_ipi)sc0A48)


What do i do wrong?

Senior Member
Posts: 68
Joined: Tue May 08, 2012 5:40 pm

Re: Instant syscall implementation (C)

Postby happy » Mon Feb 11, 2013 8:22 pm

Change typedef int(*sc_ipi)(int*); to typedef int(*sc_ipi)(int, int);

Next

Return to Tutorials & Code Snippets

Who is online

Users browsing this forum: No registered users and 18 guests