Last active
November 17, 2016 13:11
-
-
Save drnickallgood/31da6e379f253b578560d69560a1ad55 to your computer and use it in GitHub Desktop.
Struct Assembly example
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> | |
int main(void) | |
{ | |
struct myStruct | |
{ | |
int id; | |
char *name; | |
}; | |
struct myStruct test; | |
test.id = 4; | |
test.name = "bacon"; | |
return 0; | |
} | |
##### gcc -S structasm.c ###### | |
.section __TEXT,__text,regular,pure_instructions | |
.macosx_version_min 10, 11 | |
.globl _main | |
.align 4, 0x90 | |
_main: ## @main | |
.cfi_startproc | |
## BB#0: | |
pushq %rbp | |
Ltmp0: | |
.cfi_def_cfa_offset 16 | |
Ltmp1: | |
.cfi_offset %rbp, -16 | |
movq %rsp, %rbp | |
Ltmp2: | |
.cfi_def_cfa_register %rbp | |
xorl %eax, %eax | |
leaq L_.str(%rip), %rcx | |
movl $0, -4(%rbp) | |
movl $4, -24(%rbp) | |
movq %rcx, -16(%rbp) | |
popq %rbp | |
retq | |
.cfi_endproc | |
.section __TEXT,__cstring,cstring_literals | |
L_.str: ## @.str | |
.asciz "bacon" | |
.subsections_via_symbols | |
### 32-bit using -m=32 ### | |
.section __TEXT,__text,regular,pure_instructions | |
.macosx_version_min 10, 11 | |
.globl _main | |
.align 4, 0x90 | |
_main: ## @main | |
## BB#0: | |
pushl %ebp | |
movl %esp, %ebp | |
subl $16, %esp | |
calll L0$pb | |
L0$pb: | |
popl %eax | |
xorl %ecx, %ecx | |
leal L_.str-L0$pb(%eax), %eax | |
movl $0, -4(%ebp) | |
movl $4, -16(%ebp) | |
movl %eax, -12(%ebp) | |
movl %ecx, %eax | |
addl $16, %esp | |
popl %ebp | |
retl | |
.section __TEXT,__cstring,cstring_literals | |
L_.str: ## @.str | |
.asciz "bacon" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment