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

全站熱搜
創作者介紹
創作者 alex2008 的頭像
alex2008

alex2008的部落格

alex2008 發表在 痞客邦 留言(0) 人氣()