You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
786 B
NASM
89 lines
786 B
NASM
extern scanf
|
|
extern printf
|
|
global main
|
|
|
|
|
|
|
|
section .text
|
|
meow:
|
|
fld qword [x + 8 * ebx]
|
|
fld qword [n]
|
|
fcomp
|
|
fstsw ax
|
|
sahf
|
|
jnbe end
|
|
fld qword [n]
|
|
fxch
|
|
fsubr
|
|
|
|
fld qword [s]
|
|
fadd
|
|
fstp qword [s]
|
|
|
|
fld qword [x + 8 * ebx]
|
|
|
|
fld qword [q]
|
|
fxch
|
|
fdivr
|
|
|
|
inc ebx
|
|
|
|
fstp qword [x + 8 * ebx]
|
|
|
|
call meow
|
|
dec ebx
|
|
|
|
fld qword [x + 8 * ebx]
|
|
|
|
fld qword [w]
|
|
fxch
|
|
fdivr
|
|
inc ebx
|
|
|
|
fstp qword [x + 8 * ebx]
|
|
|
|
call meow
|
|
|
|
dec ebx
|
|
|
|
ret
|
|
|
|
end:
|
|
sub esp, 4
|
|
fstp dword [esp]
|
|
add esp, 4
|
|
|
|
ret
|
|
|
|
main:
|
|
|
|
xor ebx, ebx
|
|
push x
|
|
push i
|
|
call scanf
|
|
add esp, 8
|
|
|
|
call meow
|
|
|
|
fld qword [s]
|
|
sub esp, 8
|
|
fstp qword [esp]
|
|
push o
|
|
call printf
|
|
add esp, 12
|
|
|
|
xor eax, eax
|
|
ret
|
|
|
|
section .data
|
|
i db "%lf", 0
|
|
o db "%.10lf", 10, 13, 0
|
|
|
|
s dq 0.0
|
|
n dq 1.0
|
|
q dq 2.0
|
|
w dq 3.0
|
|
|
|
section .bss
|
|
x resq 100000
|