Re: Why does this code prints not a real cos(60) value but always 1? HELP!!!
- From: rmaudsley <spamtrap@xxxxxxxxxx>
- Date: Wed, 12 Dec 2007 12:46:42 -0800 (PST)
On Dec 12, 3:15 pm, empardoo <spamt...@xxxxxxxxxx> wrote:
.686
extrn __write : near
extrn _ExitProcess@4 : near
public _main
_DATA SEGMENT dword public 'DATA' use32
milion dd 100000
numer dq ?
jeden dd 1.0
dwa dd 2.0
dwd dd 60
stoosiemdziesiat dd 180.0
hyhy db 21 dup(' ')
_DATA ENDS
_TEXT SEGMENT dword public 'CODE' use32
ASSUME cs:_TEXT, ds:_DATA
wczytaj PROC
finit ;inicjacja koprocesora
;obliczenie cos(2a^3-1)
fld dwd
fcos
fimul milion ;ile miejsc po przecinku
fimul milion
fimul milion
fistp numer
mov eax, dword ptr numer
mov edx, dword ptr numer+4
ret
wczytaj ENDP
wypisz PROC
mov ecx, 20; liczba obiegow petli
mov ebx, 19; poczatkowa wartosc indexu
mov esi, 10; dzielnik
petla:
mov ebp, eax
mov eax, edx
mov edx, 0
div esi
xchg ebp, eax ; zamien rejestry
div esi
add dl, 30H ; zamiana na ascii
mov hyhy[ebx], dl ; odeslanie cyfry do tab
sub ebx, 1 ;zmniejszenie indexu o 1
cmp ebx, 4 ; jesli 4 to umiesc tam przecinek
jne kropka
mov hyhy[ebx],'.'
dec ebx
kropka:
mov edx, ebp
or ebp, eax
jne petla
jmp koniec
loop petla
koniec:
push dword ptr 21
push dword ptr offset hyhy
push 1
call __write
add esp, 12
ret
wypisz ENDP
_main:
call wczytaj
call wypisz
push dword ptr 0
call _ExitProcess@4
_TEXT ENDS
END
fcos expects an angle in radians, not degrees.
.
- References:
- Prev by Date: Re: Freeing DOS memory
- Next by Date: Re: Why does this code prints not a real cos(60) value but always 1? HELP!!!
- Previous by thread: Why does this code prints not a real cos(60) value but always 1? HELP!!!
- Next by thread: Re: Why does this code prints not a real cos(60) value but always 1? HELP!!!
- Index(es):
Relevant Pages
|
|