0
,我得到一個無限循環只打印零:斐波納契不GAS彙編語言工作執行此代碼後
(我仔細地研究它,但我仍然無法找出什麼地方錯了)
.section .data
N:
.int 35
output:
.asciz "%f"
.section .text
.globl _start
_start:
nop
pushl $5
call fibonacci
.type fibonacci, @function
fibonacci:
pushl %ebp
movl %esp, %ebp
sub $8, %esp
pushl $0
pushl $1
.L2:
cmpl $2, 8(%ebp)
jg .L5
jmp .L3
.L5:
movl -4(%ebp), %ecx
addl -8(%ebp), %ecx
pushl %ecx
pushl $output
call printf
movl -8(%ebp), %edx
movl %edx,-4(%ebp)
movl %ecx,-8(%ebp)
jmp .L2
.L3:
pushl $0
call exit
感謝您指出這些錯誤。我現在修好了,但現在我只打印了0張。 – Attilah
MOV $ 2,%eax中 .L2: CMPL%eax中,8(%EBP) JG .L5 JMP .L3 .L5: (...) ADDL $ 1,%eax中 – Attilah