1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-06-03 07:29:37 +00:00
kickc/src/test/kc/call-banked-stack-case-5-far-0.c
Sven Van de Velde 477499b97b - Fixed #pragma nobank parameter issue.
- Optimized logic for #pragma bank.
- Updated test cases and references.
- Made #pragma NAME parameters optional.
- Retested all test cases.
2023-04-11 13:41:14 +02:00

48 lines
1.3 KiB
C

/**
* @file call-banked-stack-case-5-far-0.c
* @author Sven Van de Velde (sven.van.de.velde@telenet.be),
* @author Jesper Gravgaard
* @brief Test a procedure with calling convention PHI - case #5.
* The compiler will throw an error because the far call is a __stackcall
* and this is not (yet) implemented and supported.
* @version 0.1
* @date 2023-04-11
*
* @copyright Copyright (c) 2023
*
* The following cases exist in banked calling implementations:
*
* - case #1 - unbanked to unbanked and no banking areas
* - case #2 - unbanked to banked to any bank area
* - case #3 - banked to unbanked from any bank area
* - case #4 - banked to same bank in same bank area
* - case #5 - banked to different bank in same bank area
* - case #6 - banked to any bank between different bank areas
*
* This brings us to the call types:
*
* - near = case #1, #3, #4
* - close = case #2, #6
* - far = case #5
*
*/
#pragma link("call-banked-phi.ld")
char* const SCREEN = (char*)0x0400;
#pragma code_seg(Code)
void main(void) {
SCREEN[0] = plus('0', 7); // close call
}
#pragma code_seg(RAM_Bank1)
__bank(cx16_ram, 1) char plus(char a, char b) {
return min(a, b); // far call
}
#pragma code_seg(RAM_Bank2)
__stackcall __bank(cx16_ram, 2) char min(char a, char b) {
return a+b;
}