Instant syscall implementation (C)
14 posts
• Page 1 of 2 • 1, 2
- SimonLothar
- Senior Member
-
- 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)
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!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
for reference:
this are the assembler instructions, which represent the int arrays of the type
"const unsigned int scSyscallNo[] = { SCA, SCB, SCE, SyscallNo };"
(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!
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?
And just while I am playing around any list of syscall numbers I should avoid?
- helder7
- 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
scout, syscall documentation is available here: http://www.casio-scene.com/downloads.php?do=file&id=270


SiO2 + CaCO3 ----------> CaSiO3 + CO2
- SimonLothar
- Senior Member
-
- 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
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!
- SimonLothar
- Senior Member
-
- 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
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.Eiyeron wrote:I think that all the syscalls in your help file should be documented, there are some that I find interesting
I'll be back!
- aapman55
- Senior Member
-
- Posts: 66
- Joined: Sun Apr 15, 2012 4:00 pm
- Calculators: Casio fx-9860G
Re: Instant syscall implementation (C)
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:
What do i do wrong?
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?
Re: Instant syscall implementation (C)
Change typedef int(*sc_ipi)(int*); to typedef int(*sc_ipi)(int, int);
14 posts
• Page 1 of 2 • 1, 2
Return to Tutorials & Code Snippets
Who is online
Users browsing this forum: No registered users and 9 guests