Calling conventions

The Lightfoot SDK supports applications that contain Java, C and assembler code. Java and C are high level languages that have specific calling conventions, while assembler can have any type of calling convention!

Java calling convention

Soft bytecodes used

Soft bytecode
Description
Jivirt
Invoke a virtual method
Jiinterf
Invoke an interface method
Jistatic0
Invoke a static method with zero parameters
Jistatic
Invoke a static method
Jcscall0
Call the C function on the stack with zero parameters.
Jcscalln
Call the C function on the stack with zero parameters.
Jispec
Invoke a special method, either private, a superclass method or a constructor
Jxreturn
Return from the method. Any value to return is on the stack.

Parameters/local variables

The first 4 parameters and local variables are stored in parameter registers P0-P3. The remaining parameters and local variables are stored in the paramter pool at entries 4 and above.

Stack frame

The stack frame for Java methods is as follows
method pointer
stack counter
flags
previous ppp
return address
previous cpp
next ppp

C calling convention

Soft bytecodes used

Soft bytecode
Description
ccall0
Call a named function with zero parameters
ccalln
Call a named function with the specified number of parameters
cscall0
Call the function on the stack with zero parameters
cscalln
Call the function on the stack with the specified number of parameters
cret
Return a value from the function. The value to return should be on the stack and will be stored in parameter register P3
cret0
Return no values from the function.

Parameters

All parameters are stored in the parameter pool starting at entry 0. Return values from functions are stored in parameter register P3.

Stack frame

The stack frame for C functions is as follows
previous ppp
return address
previous cpp
next ppp