Guest User

Untitled

a guest
Dec 15th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. /***************************************************************************/
  2.  
  3. #include <stddef.h>
  4.  
  5. extern long xxx;
  6.  
  7. struct a {char x; char y;};
  8. struct b {short x; char y;};
  9.  
  10. extern void g_0(long,long,long,long);
  11. void f_0(long a,long b,long c)
  12. {
  13. return g_0(xxx,a,b,c);
  14. }
  15.  
  16. extern void g_1(struct a,struct a,struct b);
  17. void f_1(struct a a, struct b b)
  18. {
  19. return g_1((struct a){1,2},a,b);
  20. }
  21.  
  22. void foo(void)
  23. {
  24. extern void h(struct a, struct b);
  25. return h
  26. ((struct a){1,2}
  27. ,(struct b){33,44});
  28. }
  29.  
  30. void bar(void)
  31. {
  32. return g_1
  33. ((struct a){1,2}
  34. ,(struct a){5,7}
  35. ,(struct b){33,44});
  36. }
  37.  
  38. struct c {size_t x; char y;};
  39. extern void zzz(struct c, char);
  40.  
  41. void baz(void)
  42. {
  43. return zzz((struct c){-1,7},5);
  44. }
  45.  
  46. /***************************************************************************/
  47.  
  48. #if 0
  49. [m@monire ~]$ c2asm.sh < callconv_shift.c
  50. .file "tmp.8Pd8FsoyLu.c"
  51. .text
  52. .p2align 4,,15
  53. .globl f_0
  54. .type f_0, @function
  55. f_0:
  56. movq %rdx, %rcx
  57. movq %rsi, %rdx
  58. movq %rdi, %rsi
  59. movq xxx(%rip), %rdi
  60. jmp g_0
  61. .size f_0, .-f_0
  62. .p2align 4,,15
  63. .globl f_1
  64. .type f_1, @function
  65. f_1:
  66. subq $8, %rsp
  67. movl %esi, %edx
  68. movl %edi, %esi
  69. movl $513, %edi
  70. call g_1
  71. addq $8, %rsp
  72. ret
  73. .size f_1, .-f_1
  74. .p2align 4,,15
  75. .globl foo
  76. .type foo, @function
  77. foo:
  78. subq $8, %rsp
  79. movl $2883617, %esi
  80. movl $513, %edi
  81. call h
  82. addq $8, %rsp
  83. ret
  84. .size foo, .-foo
  85. .p2align 4,,15
  86. .globl bar
  87. .type bar, @function
  88. bar:
  89. subq $8, %rsp
  90. movl $2883617, %edx
  91. movl $1797, %esi
  92. movl $513, %edi
  93. call g_1
  94. addq $8, %rsp
  95. ret
  96. .size bar, .-bar
  97. .p2align 4,,15
  98. .globl baz
  99. .type baz, @function
  100. baz:
  101. subq $24, %rsp
  102. movq $-1, %rdi
  103. movl $5, %edx
  104. movb $7, 8(%rsp)
  105. movl 8(%rsp), %esi
  106. movq %rdi, (%rsp)
  107. call zzz
  108. addq $24, %rsp
  109. ret
  110. .size baz, .-baz
  111. .ident "GCC: (GNU) 4.6.0 20110115 (experimental)"
  112. .section .note.GNU-stack,"",@progbits
  113. #endif
  114.  
  115. /***************************************************************************/
  116.  
  117. #if 0
  118. [m@monire ~]$ c2asm_32.sh < callconv_shift.c
  119. .file "tmp.jFXnYPtufG.c"
  120. .text
  121. .p2align 4,,15
  122. .globl f_0
  123. .type f_0, @function
  124. f_0:
  125. subl $28, %esp
  126. movl 40(%esp), %eax
  127. movl %eax, 12(%esp)
  128. movl 36(%esp), %eax
  129. movl %eax, 8(%esp)
  130. movl 32(%esp), %eax
  131. movl %eax, 4(%esp)
  132. movl xxx, %eax
  133. movl %eax, (%esp)
  134. call g_0
  135. addl $28, %esp
  136. ret
  137. .size f_0, .-f_0
  138. .p2align 4,,15
  139. .globl f_1
  140. .type f_1, @function
  141. f_1:
  142. subl $28, %esp
  143. movl 36(%esp), %eax
  144. movw $513, (%esp)
  145. movl %eax, 8(%esp)
  146. movzwl 32(%esp), %eax
  147. movw %ax, 4(%esp)
  148. call g_1
  149. addl $28, %esp
  150. ret
  151. .size f_1, .-f_1
  152. .p2align 4,,15
  153. .globl foo
  154. .type foo, @function
  155. foo:
  156. subl $28, %esp
  157. movl $2883617, 4(%esp)
  158. movw $513, (%esp)
  159. call h
  160. addl $28, %esp
  161. ret
  162. .size foo, .-foo
  163. .p2align 4,,15
  164. .globl bar
  165. .type bar, @function
  166. bar:
  167. subl $28, %esp
  168. movl $2883617, 8(%esp)
  169. movw $1797, 4(%esp)
  170. movw $513, (%esp)
  171. call g_1
  172. addl $28, %esp
  173. ret
  174. .size bar, .-bar
  175. .p2align 4,,15
  176. .globl baz
  177. .type baz, @function
  178. baz:
  179. subl $28, %esp
  180. movl $5, 8(%esp)
  181. movl $-1, (%esp)
  182. movl $7, 4(%esp)
  183. call zzz
  184. addl $28, %esp
  185. ret
  186. .size baz, .-baz
  187. .ident "GCC: (GNU) 4.6.0 20110115 (experimental)"
  188. .section .note.GNU-stack,"",@progbits
  189. #endif
  190.  
  191. /***************************************************************************/
Add Comment
Please, Sign In to add comment