1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-06-03 07:29:37 +00:00
kickc/src/test/kc/library/test3-calc-lib/calc_lib.c
Flight_Control 00df07b7bf - Fixed test cases. Full retest of all test cases.
- Treat global variables of libraries, as part of the .asm library .namespace.
- Fix bugs.
- Assign meaningful struct names to .asm internal variables and labels. (Remove the $x notation).
2024-04-20 07:03:31 +03:00

44 lines
1.2 KiB
C

/*
Generate a calculation library that:
- Defines an exported library function plus_min to do some calculation.
This function parameters are allocated on zero-page, following the __varcall
calling convention.
- Define two internal functions plus and min.
These functions are internally to the library, and therefore,
will be optimized following the current calling convention.
Internal functions following the __phicall calling convention,
when compiled with uplift, the parameters to this function will be
uplifted to A, X or Y registers, including local variables etc.
- Validate the resulting calc_lib.asm and calc_lib_asm.h files.
*/
#pragma encoding(screencode_mixed)
#pragma var_model(zp)
#pragma asm_library
#pragma calling(__varcall)
#pragma asm_export(plus_min)
#pragma calling(__phicall)
// Compiled using __varcall calling convention.
char plus_min(char a, char p, char m) {
char pr = plus(a,p);
char mr = min(pr,m);
return mr;
}
// Compiled using __phicall calling convention.
char plus(char a, char b) {
return a+b;
}
// Compiled using __phicall calling convention.
char min(char a, char b) {
return a-b;
}