aouttest.c 938 B

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