diff --git a/py65/funcs.c02 b/py65/funcs.c02 new file mode 100644 index 0000000..d3ec6bb --- /dev/null +++ b/py65/funcs.c02 @@ -0,0 +1,70 @@ +/******************************* + * CONDS - Test Function Calls * + *******************************/ + +#include +#include +#include +#include + +char i; //index value +char n; //result of function call +char s[128]; //for Numeric to String conversions +char z; //Function Parameters + +char passed = " Passed."; +char failed = " Failed."; + +main: + +for (i=1;i<5;i++) test(i); +putln("Testing complete."); + +goto exit; + +//Test Use of Variable as Parameter +void test(z) { + select(z) { + case 1: test1(); + case 2: test2(); + case 3: test3(); + case 4: test4(); + default: printf(z, "Bad test value %d\n."); + } +} + + +void test1() { + puts("atoc(\"1\") = "); + n = atoc("1"); + prtnum(n); checkn(1); +} + +void test2() { + puts("atoc(\"2\") = "); + n = atoc("2"); + prtnum(n); checkn(2); +} + +void test3() { + puts("atoc(\"1\") + atoc(\"2\") = "); + n = atoc("1") + atoc("2"); + prtnum(n); checkn(3); +} + +void test4() { + puts("abs(atoc(\"255\") + abs(atoc(\"7\")) = "); + n = abs(atoc("255")) + abs(atoc("7")); + prtnum(n); checkn(8); +} + + +//uses explicit passing of accumulator +void checkn() {if (A == n) pass(); else fail();} + +//uses implicit passing of accumulator +void prtnum() {ctoa(&s); puts(&s); putc(':');} + +//one more level of function calls - just because +void pass() {putln(&passed);} +void fail() {putln(&failed);} diff --git a/test/funcs.c02 b/test/funcs.c02 index 92736f8..0a1660a 100644 --- a/test/funcs.c02 +++ b/test/funcs.c02 @@ -59,5 +59,7 @@ c, z[i], f = testfn(); //Return 3 Values with Array r[i], z[j] = testfn(); //Return 2 Values with Arrays r[i], z[j], f = testfn(); //Return 2 Values with Arrays +f = fnx(b) + fny(c); //Function in regular term + //A, Y = testfn(); //Error - Registers not Allowed when returning multiple values //r[i], z[j], f[b] = testfn(); //Error - Array Element not Allowed with STX assignment