close
.section .data
output: .asciz "總和: %d\n"
msg: .asciz "降冪加總( n + ... + 1 ), n= "
ifmt: .asciz "%d"
n: .int 0
.section .text
.globl _main
_main:
pushl $msg
call _printf
addl $4, %esp
pushl $n # 輸入整數存入 n
pushl $ifmt # 即 scanf("%d", &n);
call _scanf
addl $8, %esp
movl n, %ecx
movl $0, %eax
loop1:
addl %ecx, %eax
loop loop1
pushl %eax
pushl $output
call _printf
add $8, %esp
pushl $0
call _exit
全站熱搜
留言列表

