Syscalls

From Casio Universal Wiki
Revision as of 11:01, April 6, 2013 by Casimo (talk | contribs) (Created page with "The system call documentation can be download here[http://www.casiopeia.net/forum/downloads.php?view=detail&df_id=72]. To use system calls in the official SDK, you can either...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The system call documentation can be download here[1].

To use system calls in the official SDK, you can either use instant the system call implementation or a .src-file.

The effect of both implementations is the same, these asm lines are generated:

mov.l   #h'80010070, r2
mov.l   #SyscallNo, r0
jmp     @r2
nop

Instant system call implementation

// the following definitions are only needed once
#define SCA 0xD201D002
#define SCB 0x422B0009
#define SCE 0x80010070
// 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 );