アセンブリ言語の教科書 第3章 数値のカウント(再帰で)
.text .global main main: push %ebp mov %esp,%ebp mov $10, %eax push %eax call count pop %eax mov $0, %eax leave ret count: push %ebp mov %esp,%ebp mov 8(%ebp),%eax push %eax push $count_s call printf pop %eax pop %eax dec %eax cmp $0, %eax je 1f push %eax call count pop %eax 1: leave ret .data count_s: .string "count : %d\n"
% gcc -o count count.s % ./count count : 10 count : 9 ...(略 count : 2 count : 1
追記
あ、decで再代入してる。