1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-19 06:31:31 +00:00
cc65/test/val/trampoline.c

54 lines
741 B
C
Raw Normal View History

2017-05-02 15:48:31 +00:00
/*
!!DESCRIPTION!! trampoline pragma
!!ORIGIN!! cc65 regression tests
!!LICENCE!! Public Domain
!!AUTHOR!! Lauri Kasanen
*/
static unsigned char flag;
static void trampoline_set() {
asm("ldy tmp4");
asm("sty %v", flag);
asm("jsr callptr4");
}
void trampoline_inc() {
asm("inc %v", flag);
asm("jsr callptr4");
}
void func3() {
}
unsigned char array[30];
#pragma wrapped-call(push, array, 0)
#pragma wrapped-call(pop)
2017-05-02 15:48:31 +00:00
#pragma wrapped-call(push, trampoline_inc, 0)
2017-05-02 15:48:31 +00:00
void func2() {
func3();
}
#pragma wrapped-call(push, trampoline_set, 4)
2017-05-02 15:48:31 +00:00
void func1(void);
#pragma wrapped-call(pop)
#pragma wrapped-call(pop)
2017-05-02 15:48:31 +00:00
void func1() {
func2();
}
int main(void)
{
flag = 0;
func1();
return flag == 5 ? 0 : 1;
}