cofftest.c 932 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * test source file for assembling to COFF
  3. * build with (under DJGPP, for example):
  4. * nasm -f coff cofftest.asm
  5. * gcc -o cofftest cofftest.c cofftest.o
  6. */
  7. #include <stdio.h>
  8. #include <inttypes.h>
  9. extern int lrotate(int32_t, int);
  10. extern void greet(void);
  11. extern int8_t asmstr[];
  12. extern void *selfptr;
  13. extern void *textptr;
  14. extern int integer, commvar;
  15. int main(void)
  16. {
  17. printf("Testing lrotate: should get 0x00400000, 0x00000001\n");
  18. printf("lrotate(0x00040000, 4) = 0x%08lx\n", lrotate(0x40000, 4));
  19. printf("lrotate(0x00040000, 14) = 0x%08lx\n", lrotate(0x40000, 14));
  20. printf("This string should read `hello, world': `%s'\n", asmstr);
  21. printf("The integers here should be 1234, 1235 and 4321:\n");
  22. integer = 1234;
  23. commvar = 4321;
  24. greet();
  25. printf("These pointers should be equal: %p and %p\n", &greet, textptr);
  26. printf("So should these: %p and %p\n", selfptr, &selfptr);
  27. }