2 ; Ullrich von Bassewitz, 06.08.1998
3 ; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
5 ; CC65 runtime: function epilogue
8 ; exit a function. pop stack and rts. The function comes in different
9 ; flavours that provide default values for the return val, or drop a local
10 ; stack frame with size in y.
12 .export leave00, leave0, leavey00, leavey0, leavey
29 jsr addysp ; drop stack frame
31 .if (.cpu .bitand ::CPU_ISET_65SC02)
33 leave: tay ; save A a sec
34 lda (sp) ; that's the pushed arg size
35 sec ; Count the byte, the count's stored in
40 L1: tya ; Get return value back
44 leave: pha ; save A a sec
46 lda (sp),y ; that's the pushed arg size
47 sec ; Count the byte, the count's stored in
52 L1: pla ; Get return value back