-
-
Save cuihaoleo/c52141d1a35479094d57 to your computer and use it in GitHub Desktop.
test struct init
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
struct test { | |
int a, b, c; | |
}; | |
int main() { | |
struct test st = { | |
.b = 15, | |
}; | |
printf("%d %d %d", st.a, st.b, st.c); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.file "a.c" | |
.section .rodata | |
.LC0: | |
.string "%d %d %d" | |
.text | |
.globl main | |
.type main, @function | |
main: | |
.LFB0: | |
.cfi_startproc | |
pushq %rbp | |
.cfi_def_cfa_offset 16 | |
.cfi_offset 6, -16 | |
movq %rsp, %rbp | |
.cfi_def_cfa_register 6 | |
subq $16, %rsp | |
movq $0, -16(%rbp) // st.a = st.b = 0 | |
movl $0, -8(%rbp) // st.c = 0 | |
movl $15, -12(%rbp) // st.b | |
movl -8(%rbp), %ecx | |
movl -12(%rbp), %edx | |
movl -16(%rbp), %eax | |
movl %eax, %esi | |
movl $.LC0, %edi | |
movl $0, %eax | |
call printf | |
movl $0, %eax | |
leave | |
.cfi_def_cfa 7, 8 | |
ret | |
.cfi_endproc | |
.LFE0: | |
.size main, .-main | |
.ident "GCC: (GNU) 5.2.0" | |
.section .note.GNU-stack,"",@progbits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment