mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-06-03 07:29:37 +00:00
Small test program to test parameters.
This commit is contained in:
parent
53a918025a
commit
5e6622b2a8
35
src/test/kc/library/example1/lib.asm
Normal file
35
src/test/kc/library/example1/lib.asm
Normal file
|
@ -0,0 +1,35 @@
|
|||
// File Comments
|
||||
/* compile with C64 */
|
||||
// Library
|
||||
.namespace lib {
|
||||
// Upstart
|
||||
.cpu _65c02
|
||||
|
||||
#if __asm_import__
|
||||
#else
|
||||
.segmentdef Code [start=$80d]
|
||||
.segmentdef Data [startAfter="Code"]
|
||||
#endif
|
||||
// Global Constants & labels
|
||||
.segment Code
|
||||
// plus
|
||||
// __zp(2) char plus(__zp(2) char a, __zp(2) char b)
|
||||
plus: {
|
||||
.label a = 2
|
||||
.label b = 2
|
||||
.label return = 2
|
||||
.label plus__0 = 2
|
||||
// a+b
|
||||
// [0] plus::$0 = plus::a + plus::b -- vbuz1=vbuz1_plus_vbuz1
|
||||
lda.z plus__0
|
||||
asl
|
||||
sta.z plus__0
|
||||
// return a+b;
|
||||
// [1] plus::return = plus::$0
|
||||
// plus::@return
|
||||
// }
|
||||
// [2] return
|
||||
rts
|
||||
}
|
||||
// File Data
|
||||
}
|
11
src/test/kc/library/example1/lib.c
Normal file
11
src/test/kc/library/example1/lib.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* compile with C64 */
|
||||
|
||||
#pragma link("lib.ld")
|
||||
#pragma encoding(screencode_mixed)
|
||||
#pragma var_model(zp)
|
||||
#pragma asm_library("lib")
|
||||
#pragma asm_export("lib", __varcall, plus)
|
||||
|
||||
char plus(char a, char b) {
|
||||
return a+b;
|
||||
}
|
6
src/test/kc/library/example1/lib.ld
Normal file
6
src/test/kc/library/example1/lib.ld
Normal file
|
@ -0,0 +1,6 @@
|
|||
|
||||
#if __asm_import__
|
||||
#else
|
||||
.segmentdef Code [start=%P]
|
||||
.segmentdef Data [startAfter="Code"]
|
||||
#endif
|
1
src/test/kc/library/example1/lib_proto.h
Normal file
1
src/test/kc/library/example1/lib_proto.h
Normal file
|
@ -0,0 +1 @@
|
|||
extern __varcall __asm_import(lib) __zp(2) char plus(__zp(2) char a, __zp(2) char b);
|
9
src/test/kc/library/example1/main.c
Normal file
9
src/test/kc/library/example1/main.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
|
||||
#include "lib_proto.h"
|
||||
|
||||
__export char r;
|
||||
|
||||
void main() {
|
||||
|
||||
r = plus(4,5);
|
||||
}
|
Loading…
Reference in New Issue
Block a user