- 论坛徽章:
- 0
|
回复 #23 OwnWaterloo 的帖子
以你的结构,结果:
[root@Server01 struct]# cat test2.c
typedef struct {
int x;
int y;
} Point2D32S;
Point2D32S point2d32s(int x,int y) {
Point2D32S result = {x,y};
return result;
}
typedef struct {
short x;
short y;
} Point2D16S;
Point2D16S point2d16s(short x,short y) {
Point2D16S result = {x,y};
return result;
}
typedef struct {
int val;
} atomic_t;
atomic_t atomic(int val) {
atomic_t result = {val};
return result;
}
int main()
{
Point2D32S a ;
a = point2d32s(0x55 , 0xAA) ;
return a.x > a.y ? 1 : 0 ;
}
[root@Server01 struct]# gcc -Wall -O2 -fomit-frame-pointer -S test2.c
[root@Server01 struct]#ls *.s
test2.s
[root@Server01 struct]# cat test2.s
.file "test2.c"
.text
.p2align 4,,15
.globl point2d32s
.type point2d32s, @function
point2d32s:
movl 4(%esp), %eax
movl 12(%esp), %edx
movl %edx, 4(%eax)
movl 8(%esp), %edx
movl %edx, (%eax)
ret $4
.size point2d32s, .-point2d32s
.p2align 4,,15
.globl point2d16s
.type point2d16s, @function
point2d16s:
movl 4(%esp), %eax
movl 12(%esp), %edx
movw %dx, 2(%eax)
movl 8(%esp), %edx
movw %dx, (%eax)
ret $4
.size point2d16s, .-point2d16s
.p2align 4,,15
.globl atomic
.type atomic, @function
atomic:
movl 4(%esp), %eax
movl 8(%esp), %edx
movl %edx, (%eax)
ret $4
.size atomic, .-atomic
.p2align 4,,15
.globl main
.type main, @function
main:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ecx
subl $20, %esp
leal 12(%esp), %eax
movl %eax, (%esp)
movl $170, 8(%esp)
movl $85, 4(%esp)
call point2d32s
subl $4, %esp
movl 12(%esp), %eax
movl 16(%esp), %edx
cmpl %eax, %edx
setl %al
addl $20, %esp
popl %ecx
movzbl %al, %eax
leal -4(%ecx), %esp
ret
.size main, .-main
.ident "GCC: (GNU) 4.1.1 20070105 (Red Hat 4.1.1-52)"
.section .note.GNU-stack,"",@progbits
[root@Server01 struct]# |
|