47 lines
529 B
NASM
47 lines
529 B
NASM
.data
|
|
i: .long 2
|
|
result: .long 1
|
|
n: .long 12
|
|
|
|
intout:
|
|
.string "Fakultaet: %d\n"
|
|
|
|
.text
|
|
|
|
.globl main
|
|
|
|
main:
|
|
|
|
movl i, %ebx # %ebx = i
|
|
movl result, %eax # %eax = result
|
|
movl n, %ecx # %ecx = n
|
|
|
|
subl %ebx, %ecx # %ecx = n - i
|
|
|
|
inc %ecx # Anzahl der Schleifendurchläufe + 1
|
|
|
|
|
|
|
|
.schleife:
|
|
cmp $0, %ecx # %ecx = 0 ? -> jump .end
|
|
je .end
|
|
|
|
mull %ebx # %eax *= %ebx (result *= i)
|
|
inc %ebx # i++
|
|
dec %ecx
|
|
|
|
jmp .schleife
|
|
|
|
|
|
|
|
.end:
|
|
|
|
# Wert im %eax ausgeben
|
|
pushl %eax
|
|
pushl $intout
|
|
call printf
|
|
|
|
|
|
# Exit
|
|
movl $1, %eax
|
|
int $0x80 |