college/ws2010/gdi3/u5/2_rbg_faehig.asm
2011-10-18 11:17:11 +02:00

58 lines
929 B
NASM

.data
# Eingabe
a: .float 2.3
b: .float 0.7
c: .float 4.7
d: .float 1.7
e: .float 3.0
f: .float 2.0
g: .float 9.0
h: .float 3.0
i: .float 1.0
x: .float 1.0
intout:
.string "Ergebnis: %f\n"
.text
.globl main
main:
fld a # Lade a auf FPU-Stack # st(3)
fsub x # a - x
fadd b # + b
fld c # Lade c auf FPU-Stack # st(2)
fsub d # c - d
fld e # Lade e auf FPU-Stack # st(1)
fmul f # e * f
fld g # Lade g auf FPU-Stack # st(0)
fdiv h # g / h
fadd i # g / h + i
fxch # Tausche st(0) <-> st(1)
fsubp # (e * f - (g / h + i)) # dekrementiere stack
fxch # Tausche st(0) <-> st(1)
fmulp # (c - d) * (e * f - (g / h + i)) # dekrementiere stack
fxch # Tausche st(0) <-> st(1)
fdivp # ((a - x) + b) / ((c - d) * (e * f - (g / h + i))) # dekrementiere stack
fstpl(%esp) # Ausgabe von st(0)
.end:
# Wert ausgeben
pushl $intout
call printf
# Exit
movl $1, %eax
int $0x80