25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.0KB

  1. /* powerc-hello.c - first program for Power C on the C64
  2. *
  3. * Prints a small table and demonstrates 16-bit int wrap-around,
  4. * so it exercises printf(), a counting loop and int arithmetic.
  5. *
  6. * Build on the Power C disk (examples/powerc-hello.d81 already holds
  7. * the compiled result):
  8. *
  9. * cc hello.c
  10. * link -s
  11. * > hello.o
  12. * > ^ (pull in stdlib.l + syslib.l)
  13. * > (empty RETURN)
  14. * output file name: hello
  15. *
  16. * This file is plain ASCII; Power C needs PETSCII source with CR line
  17. * endings, so convert it before writing it to the image:
  18. *
  19. * c1541 powerc-hello.d81 -write hello.pet "hello.c,s"
  20. *
  21. * Then run it with -autostart "powerc-hello.d81:hello", or from BASIC:
  22. * LOAD"HELLO",8 : RUN
  23. */
  24. #include <stdio.h>
  25. main()
  26. {
  27. int i, v;
  28. printf("power c on the c64\n");
  29. printf("==================\n\n");
  30. for (i = 1; i <= 5; i++) {
  31. v = i * i;
  32. printf("%d squared is %d\n", i, v);
  33. }
  34. v = 32767;
  35. v = v + 1;
  36. printf("\nint is 16-bit: 32767 + 1 = %d\n", v);
  37. }

Powered by TurnKey Linux.