98_al_ax_extend.c 940 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. asm (
  4. ".text;"
  5. ".globl _us;.globl _ss;.globl _uc;.globl _sc;"
  6. "_us:;_ss:;_uc:;_sc:;"
  7. "movl $0x1234ABCD, %eax;"
  8. "ret;"
  9. );
  10. #if 1
  11. #define us _us
  12. #define ss _ss
  13. #define uc _uc
  14. #define sc _sc
  15. #endif
  16. int main()
  17. {
  18. unsigned short us(void);
  19. short ss(void);
  20. unsigned char uc(void);
  21. signed char sc(void);
  22. unsigned short (*fpus)(void) = us;
  23. short (*fpss)(void) = ss;
  24. unsigned char (*fpuc)(void) = uc;
  25. signed char (*fpsc)(void) = sc;
  26. printf("%08X %08X\n", us() + 1, fpus() + 1);
  27. printf("%08X %08X\n", ss() + 1, fpss() + 1);
  28. printf("%08X %08X\n", uc() + 1, fpuc() + 1);
  29. printf("%08X %08X\n", sc() + 1, fpsc() + 1);
  30. printf("\n");
  31. printf("%08X %08X\n", fpus() + 1, us() + 1);
  32. printf("%08X %08X\n", fpss() + 1, ss() + 1);
  33. printf("%08X %08X\n", fpuc() + 1, uc() + 1);
  34. printf("%08X %08X\n", fpsc() + 1, sc() + 1);
  35. return 0;
  36. }