flat assembler
Message board for the users of flat assembler.

Index > Windows > GetTickCount and fdiv problem :/

Author
Thread Post new topic Reply to topic
dieboy



Joined: 30 Dec 2004
Posts: 41
Location: Poland, Elblag
dieboy 23 Jun 2005, 15:26
Ok, I'm going to change miliseconds to seconds, and why this code didn't work ?

Code:
format PE GUI 4.0
entry main

include '%fasminc%/win32a.inc'

section '.data' data readable writeable

buffer db '%d', 0
text rb 50
time dd ?
newtime dd ?
value dd 1000

section '.code' code readable executable

main:
    invoke GetTickCount
    mov [time], eax
    finit
    fld [value]      ;st0 = time
    fld [time]       ;st1 = time, st0 = value
    fdiv st0, st1    ;st0 = st0 / st1
    fstp [time]
    invoke wsprintf, text, buffer, [time]
    invoke MessageBox, NULL, text, NULL, MB_OK
    invoke ExitProcess, 0

section '.idata' import data readable

library kernel32, 'KERNEL32.DLL',\
        user32, 'USER32.DLL'

include '%fasminc%/apia/kernel32.inc'
include '%fasminc%/apia/user32.inc    

_________________
...
Post 23 Jun 2005, 15:26
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 23 Jun 2005, 15:27
You are operating on integers, not floating point values - use "fild" and "fistp" instead of "fld" and "fstp".
Or even better do it without FPU:
Code:
    invoke GetTickCount
    xor edx,edx
    mov ebx,1000
    div ebx
    mov [time],eax    
Post 23 Jun 2005, 15:27
View user's profile Send private message Visit poster's website Reply with quote
dieboy



Joined: 30 Dec 2004
Posts: 41
Location: Poland, Elblag
dieboy 23 Jun 2005, 15:30
Thank you very much ! Wink
Post 23 Jun 2005, 15:30
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.