Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .386
- .model flat, stdcall
- option casemap : none
- include \masm32\include\kernel32.inc
- include \masm32\include\masm32.inc
- include \masm32\include\msvcrt.inc
- includelib \masm32\lib\kernel32.lib
- includelib \masm32\lib\masm32.lib
- includelib \masm32\lib\msvcrt.lib
- include \masm32\macros\macros.asm
- .data
- fstart dq 10.0
- a dq 0.0
- b dq 100.0
- mid dq 0.0
- num dq 32.0
- n dd 5
- m dd 0
- eps dq 0.00001
- two dq 2.0
- zero dq 0.0
- one dq 1.0
- res dq 1.0
- x dq 0.0
- resMul dq 1.0
- .code
- fun proc
- fstp x
- fld one
- fstp res
- mov eax, n
- mov m, eax
- cicle:
- mov eax, m
- cmp eax, 0
- je exitFun
- mov ebx, 2
- mov edx, 0
- div ebx
- cmp edx, 0
- jne notzero
- mov m, eax
- fld x
- fmul x
- fstp x
- jmp cicle
- notzero:
- mov eax, m
- sub eax, 1
- mov m, eax
- fld res
- fmul x
- fstp res
- jmp cicle
- exitFun:
- fld num
- fsub res
- fstp res
- ret
- fun endp
- start:
- finit
- cicleMain:
- fld one
- fstp resMul
- fld b
- fsub a
- fcom eps
- fstsw ax
- sahf
- jb close
- fld b
- fadd a
- fdiv two
- fstp mid
- fld mid
- call fun
- ffree st
- fld resMul
- fmul res
- fstp resMul
- fld a
- call fun
- ffree st
- fld resMul
- fmul res
- fst resMul
- fcom zero
- fstsw ax
- sahf
- ja positive
- fld mid
- fstp b
- ffree st
- jmp cicleMain
- positive:
- fld mid
- fstp a
- ffree st
- jmp cicleMain
- close:
- printf("%llf", mid)
- xor eax, eax
- ret
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement