リスト13 リスト14 リスト15 リスト16 リスト17


〔リスト13〕生成関数式によってstruct fooを生成するコード(1)の例(test55.c)
	#include <stdio.h>
	struct foo {int a; char b[2];} structure;
	void test(int x,int y);
	int main(void)
	{
	 int x;
	 int y;
	 scanf("%d",&x);
	 scanf("%d",&y);
	 test(x,y);
	 return;
	}
	void test(int x,int y)
	{
	 structure = ((struct foo) {x + y, 'a', 0});
	}


〔リスト14〕コード(1)で生成されたアセンブラ(test55.s)
	 .file "test55.c"
	 .version "01.01"
	gcc2_compiled.:
	.section .rodata
	.LC0:
	 .string "%d"
	.text
	 .align 4
	.globl main
	 .type  main,@function
	main:
	 pushl %ebp
	 movl %esp,%ebp
	 subl $24,%esp
	 addl $-8,%esp
	 leal -4(%ebp),%eax
	 pushl %eax
	 pushl $.LC0
	 call scanf
	 addl $16,%esp
	 addl $-8,%esp
	 leal -8(%ebp),%eax
	 pushl %eax
	 pushl $.LC0
	 call scanf
	 addl $16,%esp
	 addl $-8,%esp
	 movl -8(%ebp),%eax
	 pushl %eax
	 movl -4(%ebp),%eax
	 pushl %eax
	 call test
	 addl $16,%esp
	 jmp .L2
	 .p2align 4,,7
	.L2:
	 movl %ebp,%esp
	 popl %ebp
	 ret
	.Lfe1:
	 .size  main,.Lfe1-main
	 .align 4
	.globl test
	 .type  test,@function
	test:
	 pushl %ebp
	 movl %esp,%ebp
	 pushl %ebx
	 movl 8(%ebp),%ecx
	 movl 12(%ebp),%ebx
	 addl %ebx,%ecx
	 movl %ecx,%eax
	 xorl %ecx,%ecx
	 movb $97,%cl
	 movw %cx,%dx
	 movl %eax,structure
	 movl %edx,structure+4
	.L3:
	 movl -4(%ebp),%ebx
	 movl %ebp,%esp
	 popl %ebp
	 ret
	.Lfe2:
	 .size  test,.Lfe2-test
	 .comm structure,8,4
	 .ident "GCC: (GNU) 2.95.3 20010315 (release)"


〔リスト15〕最適化オプション-O3を付加してコード(1)で生成されたアセンブラ(test56.s)
	 .file "test56.c"
	 .version "01.01"
	gcc2_compiled.:
	.section .rodata
	.LC0:
	 .string "%d"
	 .comm structure,8,4
	.text
	 .align 4
	.globl test
	 .type  test,@function
	test:
	 pushl %ebp
	 movl %esp,%ebp
	 movl 12(%ebp),%eax
	 movl 8(%ebp),%edx
	 addl %eax,%edx
	 movl $97,%eax
	 movw %ax,%cx
	 movl %edx,structure
	 movl %ecx,structure+4
	 movl %ebp,%esp
	 popl %ebp
	 ret
	.Lfe1:
	 .size  test,.Lfe1-test
	 .align 4
	.globl main
	 .type  main,@function
	main:
	 pushl %ebp
	 movl %esp,%ebp
	 subl $24,%esp
	 addl $-8,%esp
	 leal -4(%ebp),%eax
	 pushl %eax
	 pushl $.LC0
	 call scanf
	 addl $-8,%esp
	 leal -8(%ebp),%eax
	 pushl %eax
	 pushl $.LC0
	 call scanf
	 movl -8(%ebp),%eax
	 addl $32,%esp
	 addl $-8,%esp
	 pushl %eax
	 movl -4(%ebp),%eax
	 pushl %eax
	 call test
	 movl %ebp,%esp
	 popl %ebp
	 ret
	.Lfe2:
	 .size  main,.Lfe2-main
	 .ident "GCC: (GNU) 2.95.3 20010315 (release)"


〔リスト16〕生成関数式によってstruct fooを生成するコード(2)の例(test57.c)
	#include <stdio.h>
	struct foo {int a; char b[2];} structure;
	void test(int x,int y);
	int main(void)
	{
	 int x;
	 int y;
	 scanf("%d",&x);
	 scanf("%d",&y);
	 test(x,y);
	 return;
	}
	void test(int x,int y)
	{
	 struct foo temp = {x + y, 'a', 0};
	 structure = temp;
	}


〔リスト17〕コード(2)で生成されたアセンブラ(test57.s)
	 .file "test57.c"
	 .version "01.01"
	gcc2_compiled.:
	.section .rodata
	.LC0:
	 .string "%d"
	.text
	 .align 4
	.globl main
	 .type  main,@function
	main:
	 pushl %ebp
	 movl %esp,%ebp
	 subl $24,%esp
	 addl $-8,%esp
	 leal -4(%ebp),%eax
	 pushl %eax
	 pushl $.LC0
	 call scanf
	 addl $16,%esp
	 addl $-8,%esp
	 leal -8(%ebp),%eax
	 pushl %eax
	 pushl $.LC0
	 call scanf
	 addl $16,%esp
	 addl $-8,%esp
	 movl -8(%ebp),%eax
	 pushl %eax
	 movl -4(%ebp),%eax
	 pushl %eax
	 call test
	 addl $16,%esp
	 jmp .L2
	 .p2align 4,,7
	.L2:
	 movl %ebp,%esp
	 popl %ebp
	 ret
	.Lfe1:
	 .size  main,.Lfe1-main
	 .align 4
	.globl test
	 .type  test,@function
	test:
	 pushl %ebp
	 movl %esp,%ebp
	 subl $20,%esp
	 pushl %ebx
	 movl 8(%ebp),%ecx
	 movl 12(%ebp),%ebx
	 addl %ebx,%ecx
	 movl %ecx,%eax
	 xorl %ecx,%ecx
	 movb $97,%cl
	 movw %cx,%dx
	 movl %eax,-8(%ebp)
	 movl %edx,-4(%ebp)
	 movl -8(%ebp),%eax
	 movl -4(%ebp),%edx
	 movl %eax,structure
	 movl %edx,structure+4
	.L3:
	 movl -24(%ebp),%ebx
	 movl %ebp,%esp
	 popl %ebp
	 ret
	.Lfe2:
	 .size  test,.Lfe2-test
	 .comm structure,8,4
	 .ident "GCC: (GNU) 2.95.3 20010315 (release)"