flat assembler
Message board for the users of flat assembler.

Index > Windows > 64bit(2x32bit division)

Author
Thread Post new topic Reply to topic
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex 27 Jul 2010, 23:53
I need to do some math with a 64bit number.
Can't use LARGE_INTEGER, because it's a union (right?).
I can declare a quad word, which is 64bit, but I don't know how to put the number (from HW and LW of a FILETIME structure) in it.

(1)Any ideas for how to get the whole 64bit number and work with it (and the possible complications such as portability or 64bit number math) are greatly appreciated.

For now, I'm using two 32bit numbers as HW and LW of the 64bit number.
So far I've implemented substracting.
But I need to divide a lot to get fractions - seconds, minutes, hours from the structure.

If (1) is not possible or if there are a lot of complications involved, please suggest a method for the above (division).
Post 27 Jul 2010, 23:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 28 Jul 2010, 00:55
Code:
proc format_time
     locals
              time            FILETIME
            milliseconds    dd ?
                seconds         dd ?
                minutes         dd ?
                hours           dd ?
                days            dd ?
        endl
        invoke  GetSystemTimeAsFileTime,addr time
   mov     eax,[time.dwLowDateTime]
    mov     edx,[time.dwHighDateTime
        stdcall divide_64_by_32,eax,edx,10000
       stdcall divide_64_by_32,eax,edx,1000                    ;get milliseconds
   mov     [milliseconds],ecx
  stdcall divide_64_by_32,eax,edx,60                      ;get seconds
        mov     [seconds],ecx
       stdcall divide_64_by_32,eax,edx,60                      ;get minutes
        mov     [minutes],ecx
       stdcall divide_64_by_32,eax,edx,24                      ;get hours
  mov     [hours],ecx
 mov     [days],eax
;...
;print something here
;...
 ret
endp

proc divide_64_by_32 numerator_low,numerator_high,denominator
    ;return edx:eax = 64-bit result
 ;       ecx = remainder
     cmp     [denominator],0
     jz      .overflow
   xor     edx,edx
     mov     eax,[numerator_high]
        div     [denominator]
       mov     ecx,eax
     mov     eax,[numerator_low]
 div     [denominator]
       xchg    edx,ecx
     ret
    .overflow:
   mov     ecx,[denominator]
   or      edx,-1
      or      eax,-1
      ret
endp    
Post 28 Jul 2010, 00:55
View user's profile Send private message Visit poster's website Reply with quote
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex 28 Jul 2010, 13:51
Too bad you're from Narnia. :D
I would surely buy you a drink otherwise.

Thanks again.
Post 28 Jul 2010, 13:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 28 Jul 2010, 14:57
jumpex wrote:
Too bad you're from Narnia. Very Happy
I would surely buy you a drink otherwise.
This has been offered before
Post 28 Jul 2010, 14:57
View user's profile Send private message Visit poster's website Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 28 Jul 2010, 15:04
revolution wrote:
jumpex wrote:
Too bad you're from Narnia. Very Happy
I would surely buy you a drink otherwise.
This has been offered before

Lol) will Taser fit?*)
__
*) Watch the next fasmcon for the answers))

_________________
Any offers?
Post 28 Jul 2010, 15:04
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 28 Jul 2010, 15:49
Dude, I would definitely get drunk with revolution. That would be awesome. As long as it's in Italy... I can't legally get drunk with anyone in the US.
Post 28 Jul 2010, 15:49
View user's profile Send private message Reply with quote
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex 28 Jul 2010, 19:03
A glass of water for revolution in Sahara.
My 4KB alarm clock (I know it's big) is now working.
Post 28 Jul 2010, 19:03
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 28 Jul 2010, 22:48
I wanna see. Can you post the exe? Just add .txt to the end.
Post 28 Jul 2010, 22:48
View user's profile Send private message Reply with quote
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex 29 Jul 2010, 01:24
Optimizing.
Will post when polished.
Post 29 Jul 2010, 01:24
View user's profile Send private message Reply with quote
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex 31 Jul 2010, 20:24
After all said and done, it came out at 16KB.
I just added a lot more stuff that I didn't plan.
(it was originally meant to work with command line arguments, for one)

Hope somebody finds something wrong with it AND tells me about it.
Any comments appreciated, actually.
(the "application" sucks, but it would be nice anyway)

Attachment is a renamed .EXE, as suggested.


Description: Rename to .exe
Download
Filename: 0xac.txt
Filesize: 16 KB
Downloaded: 183 Time(s)

Post 31 Jul 2010, 20:24
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 31 Jul 2010, 20:40
I was going to try it, but Norton removed it. I know I was the one who suggested renaming it to a .txt, maybe if you zipped it, Norton wouldn't be suspicious.

Note: I'm not saying it's a virus, AVs get false hits all the time. There's actually a few thread accusing Fasm of being a virus.
Post 31 Jul 2010, 20:40
View user's profile Send private message Reply with quote
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex 31 Jul 2010, 21:12
Zipped versions of TXT and EXE file.
Should you get to the point of starting it and have an error message displayed, please post it, if you have the time. (whole error message in MessageBox body)


Description: Rename to .exe
Download
Filename: 0xac-txt.zip
Filesize: 3.79 KB
Downloaded: 157 Time(s)

Description: Norton, it is not a Virus.
Download
Filename: 0xac-exe.zip
Filesize: 3.79 KB
Downloaded: 164 Time(s)

Post 31 Jul 2010, 21:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 31 Jul 2010, 22:18
Why no source?
Post 31 Jul 2010, 22:18
View user's profile Send private message Visit poster's website Reply with quote
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex 31 Jul 2010, 22:27
Tyler wanted the EXE.
I guess that's why.

Do you want the source?
Post 31 Jul 2010, 22:27
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 31 Jul 2010, 22:56
Posting exe's can be troublesome (as you have seen). At least with source we don't have to worry about AVs getting paranoid. And people are better able to point out any improvements in algorithms or techniques, or to learn from others some new things.
Post 31 Jul 2010, 22:56
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 02 Aug 2010, 11:04
Server 2008 R2 x64 says:
"An attempt was made to reference a token that does not exist.
cntdnt: SetDlgItemTextA(1008)"

when its docked to tray. It doesn't crash, but says it every single time.
I guess its some Windows 7 thingy Razz
Post 02 Aug 2010, 11:04
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex 03 Aug 2010, 22:49
I got this one.
(I removed the error checking for the function and the program works)

But it was tested on Windows 7.
The lanugage of the OS wasn't english, though.
So maybe that's the problem - what's yours?
Post 03 Aug 2010, 22:49
View user's profile Send private message 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.