Skip to content

Instantly share code, notes, and snippets.

@yyasuda
Created January 14, 2023 00:21
Show Gist options
  • Save yyasuda/c5633cea0e9c9de303f15a3af4c5d324 to your computer and use it in GitHub Desktop.
Save yyasuda/c5633cea0e9c9de303f15a3af4c5d324 to your computer and use it in GitHub Desktop.
assemble code of structureinit.s
.section __TEXT,__text,regular,pure_instructions
.build_version macos, 12, 0 sdk_version 12, 0
.globl _sum ## -- Begin function sum
.p2align 4, 0x90
_sum: ## @sum
.cfi_startproc
## %bb.0:
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
movq %rdi, -32(%rbp)
movl %esi, -24(%rbp)
movq -32(%rbp), %rax
movq %rax, -16(%rbp)
movl -24(%rbp), %eax
movl %eax, -8(%rbp)
movl -16(%rbp), %eax
addl -12(%rbp), %eax
popq %rbp
retq
.cfi_endproc
## -- End function
.globl _main ## -- Begin function main
.p2align 4, 0x90
_main: ## @main
.cfi_startproc
## %bb.0:
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
subq $32, %rsp
movl $0, -4(%rbp)
movl $1, -16(%rbp)
movl $2, -12(%rbp)
movq -16(%rbp), %rax
movq %rax, -32(%rbp)
movl -8(%rbp), %eax
movl %eax, -24(%rbp)
movq -32(%rbp), %rdi
movl -24(%rbp), %esi
callq _sum
movl %eax, -8(%rbp)
movl -16(%rbp), %esi
movl -12(%rbp), %edx
movl -8(%rbp), %ecx
leaq L_.str(%rip), %rdi
movb $0, %al
callq _printf
xorl %eax, %eax
addq $32, %rsp
popq %rbp
retq
.cfi_endproc
## -- End function
.section __TEXT,__cstring,cstring_literals
L_.str: ## @.str
.asciz "%d %d %d\n"
.subsections_via_symbols
@yyasuda
Copy link
Author

yyasuda commented Jan 14, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment