/* powerc-hello.c - first program for Power C on the C64 * * Prints a small table and demonstrates 16-bit int wrap-around, * so it exercises printf(), a counting loop and int arithmetic. * * Build on the Power C disk (examples/powerc-hello.d81 already holds * the compiled result): * * cc hello.c * link -s * > hello.o * > ^ (pull in stdlib.l + syslib.l) * > (empty RETURN) * output file name: hello * * This file is plain ASCII; Power C needs PETSCII source with CR line * endings, so convert it before writing it to the image: * * c1541 powerc-hello.d81 -write hello.pet "hello.c,s" * * Then run it with -autostart "powerc-hello.d81:hello", or from BASIC: * LOAD"HELLO",8 : RUN */ #include main() { int i, v; printf("power c on the c64\n"); printf("==================\n\n"); for (i = 1; i <= 5; i++) { v = i * i; printf("%d squared is %d\n", i, v); } v = 32767; v = v + 1; printf("\nint is 16-bit: 32767 + 1 = %d\n", v); }