objlink.c 922 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * test source file for assembling to Microsoft 16-bit .OBJ
  3. * build with (16-bit Microsoft C):
  4. * nasm -f obj objtest.asm
  5. * cl /AL objtest.obj objlink.c
  6. * other compilers should work too, provided they handle large
  7. * model in the same way as MS C
  8. */
  9. #include <stdio.h>
  10. #include <inttypes.h>
  11. int8_t text[] = "hello, world\n";
  12. extern void function(int8_t *);
  13. extern int bsssym, commvar;
  14. extern void *selfptr;
  15. extern void *selfptr2;
  16. int main(void)
  17. {
  18. printf("these should be identical: %p, %p\n",
  19. (int32_t)selfptr, (int32_t)&selfptr);
  20. printf("these should be equivalent but different: %p, %p\n",
  21. (int32_t)selfptr2, (int32_t)&selfptr2);
  22. printf("you should see \"hello, world\" twice:\n");
  23. bsssym = 0xF00D;
  24. commvar = 0xD00F;
  25. function(text);
  26. printf("this should be 0xF00E: 0x%X\n", bsssym);
  27. printf("this should be 0xD00E: 0x%X\n", commvar);
  28. return 0;
  29. }