123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
-
-
-
- SYSEXIT = 60
- SYSREAD = 0
- SYSWRITE = 1
- STDIN = 0
- STDOUT = 1
- STDERR = 2
-
-
- number = 5
-
- n_size = 8
-
- .bss
- num: .space n_size
-
- .text
- .globl main
-
- fun:
-
-
-
-
-
-
-
-
- pushq %rbp
- movq %rsp, %rbp
- pushq %rbx
-
-
-
- cmpq $0, 16(%rbp)
- je x0
- cmpq $1, 16(%rbp)
- je x1
- cmpq $2, 16(%rbp)
- je x2
-
-
-
- movq 16(%rbp), %rax
- subq $2, %rax
- pushq %rax
- call fun
- popq %rbx
-
-
- movq 16(%rbp), %rax
- subq $3, %rax
- pushq %rax
- call fun
- popq %rax
- movq $2, %rcx
- mulq %rcx
-
- subq %rax, %rbx
-
-
- movq %rbx, 16(%rbp)
- jmp fun_end
-
-
- x0:
- movq $2, 16(%rbp)
- jmp fun_end
-
- x1:
- movq $1, 16(%rbp)
- jmp fun_end
-
- x2:
- movq $3, 16(%rbp)
-
- fun_end:
- popq %rbx
- popq %rbp
- ret
-
- main:
- movq $number, %rax
- pushq %rax
- call fun
- popq %rax
- movq %rax, num
-
-
- movq $SYSWRITE, %rax
- movq $STDOUT, %rdi
- movq $num, %rsi
- movq $n_size, %rdx
- syscall
-
-
- movq $SYSEXIT, %rax
- movq $0, %rdi
- syscall
|