fork download
  1. //Course: CPSC240
  2. //Assignment: Example of an X86-64 program called by a C driver.
  3. //Due: 2011-Feb-7
  4. //File: triangle64.c
  5. //Purpose: Demonstrate use of C subprograms printf and scanf for IO actions.
  6. //
  7. //Data passing from the X86-64 program to the C subprograms follows the standard 64-bit calling
  8. //convention. In this case the program was tested successfully on a 64-bit machine Ubuntu platform.
  9. //
  10. //
  11. //Compile only: gcc -c -Wall -m64 -std=c99 -l triangle.lis -o triangle.o triangle.c
  12. //Link only: gcc -m64 -o triangle.out perimeter.o triangle.o
  13. //Execute in 64-bit protected mode: ./triangle.out
  14. //
  15. //
  16. #include <stdio.h>
  17. #include <stdint.h> //For C99.
  18. //C99 is presently the newest standard for C-language. Most modern C-compilers conform to the C99
  19. //standard. The GNU compiler known as gcc is C99 compliant. Assembly languages then must be C99
  20. //compliant in order for the assembly object files to be linked to C object files.
  21.  
  22. //Traditional prototype follows.
  23. extern unsigned long int computeperimeter();
  24.  
  25. int main()
  26. {
  27. int x = 32;
  28. int* p = &x;
  29. x = p;
  30. printf("%x", x);
  31. }
  32.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
cdb8d5c4