-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfactorial_macos.s
55 lines (53 loc) · 1.39 KB
/
factorial_macos.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
.section __TEXT,__text,regular,pure_instructions
.build_version macos, 14, 0 sdk_version 14, 4
.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 $16, %rsp
movl $0, -4(%rbp)
leaq L_.str(%rip), %rdi
movb $0, %al
callq _printf
movl $10, -8(%rbp)
movl $1, -12(%rbp)
movl $0, -16(%rbp)
LBB0_1: ## =>This Inner Loop Header: Depth=1
movl -16(%rbp), %eax
cmpl -8(%rbp), %eax
jge LBB0_4
## %bb.2: ## in Loop: Header=BB0_1 Depth=1
movl -12(%rbp), %eax
movl -16(%rbp), %ecx
addl $1, %ecx
imull %ecx, %eax
movl %eax, -12(%rbp)
## %bb.3: ## in Loop: Header=BB0_1 Depth=1
movl -16(%rbp), %eax
addl $1, %eax
movl %eax, -16(%rbp)
jmp LBB0_1
LBB0_4:
movl -8(%rbp), %esi
movl -12(%rbp), %edx
leaq L_.str.1(%rip), %rdi
movb $0, %al
callq _printf
xorl %eax, %eax
addq $16, %rsp
popq %rbp
retq
.cfi_endproc
## -- End function
.section __TEXT,__cstring,cstring_literals
L_.str: ## @.str
.asciz "Hello from Factorial!\n"
L_.str.1: ## @.str.1
.asciz "%d factorial is %d\n"
.subsections_via_symbols