2017-05-02 15:48:31 +00:00
|
|
|
/*
|
2017-05-18 14:14:26 +00:00
|
|
|
!!DESCRIPTION!! wrapped-call pragma used for trampolines
|
2017-05-02 15:48:31 +00:00
|
|
|
!!ORIGIN!! cc65 regression tests
|
|
|
|
!!LICENCE!! Public Domain
|
|
|
|
!!AUTHOR!! Lauri Kasanen
|
|
|
|
*/
|
|
|
|
|
|
|
|
static unsigned char flag;
|
|
|
|
|
2019-07-16 17:16:02 +00:00
|
|
|
static void trampoline_set(void) {
|
2019-02-12 21:50:49 +00:00
|
|
|
asm("ldy tmp4");
|
|
|
|
asm("sty %v", flag);
|
|
|
|
asm("jsr callptr4");
|
2017-05-02 15:48:31 +00:00
|
|
|
}
|
|
|
|
|
2019-07-16 17:16:02 +00:00
|
|
|
void trampoline_inc(void) {
|
2019-02-12 21:50:49 +00:00
|
|
|
asm("inc %v", flag);
|
|
|
|
asm("jsr callptr4");
|
2017-05-02 15:48:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void func3() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void func2() {
|
2019-02-12 21:50:49 +00:00
|
|
|
func3();
|
2017-05-02 15:48:31 +00:00
|
|
|
}
|
|
|
|
|
2023-12-09 16:47:10 +00:00
|
|
|
#pragma wrapped-call(push, trampoline_inc, 0)
|
2017-05-02 15:48:31 +00:00
|
|
|
|
2023-12-09 16:47:10 +00:00
|
|
|
void func2(void);
|
2017-05-02 15:48:31 +00:00
|
|
|
|
2023-12-09 16:47:10 +00:00
|
|
|
#pragma wrapped-call(push, trampoline_set, 4)
|
2017-05-02 15:48:31 +00:00
|
|
|
|
2019-07-16 17:16:02 +00:00
|
|
|
void func1(void) {
|
2019-02-12 21:50:49 +00:00
|
|
|
func2();
|
2017-05-02 15:48:31 +00:00
|
|
|
}
|
|
|
|
|
2023-12-09 16:47:10 +00:00
|
|
|
#pragma wrapped-call(pop)
|
|
|
|
#pragma wrapped-call(pop)
|
|
|
|
|
2017-05-02 15:48:31 +00:00
|
|
|
int main(void)
|
|
|
|
{
|
2019-02-12 21:50:49 +00:00
|
|
|
flag = 0;
|
2017-05-02 15:48:31 +00:00
|
|
|
|
2019-02-12 21:50:49 +00:00
|
|
|
func1();
|
2017-05-02 15:48:31 +00:00
|
|
|
|
2019-02-12 21:50:49 +00:00
|
|
|
return flag == 5 ? 0 : 1;
|
2017-05-02 15:48:31 +00:00
|
|
|
}
|