flat assembler
Message board for the users of flat assembler.

Index > Windows > how to declare an unsigned double word?

Author
Thread Post new topic Reply to topic
nazha



Joined: 05 Mar 2009
Posts: 40
Location: Beijing, China
nazha
Using dword variable can only store 2^31-1, the max signed integer: 2147483647, how to declare an unsigned double word to store max unsigned integer, 2^32-1, 4294967295.

_________________
Assembly Asker
Post 24 Aug 2009, 03:02
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Code:
dd 4294967295    
Works for me.

fasm doesn't support signed/unsigned constraints for data defines so this will also provide the same result as above:
Code:
dd -1    
Post 24 Aug 2009, 03:18
View user's profile Send private message Reply with quote
nazha



Joined: 05 Mar 2009
Posts: 40
Location: Beijing, China
nazha
it's strange, pls see following code I used:

myint dd 4294967295
invoke sprintf,szTemp,"%d", [myint]
invoke MessageBox,HWND_DESKTOP,szTemp,"ok",MB_OK

it return "-1", and if compare with 0, it return less than 0

cmp [myint], 0

is this normal?

Tks.
Post 24 Aug 2009, 03:38
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Try with this: invoke sprintf,szTemp,"%u", [myint]

Take in mind that memory contents does not understand the sign concept nor the processor actually (except for floats), it thinks it is signed and unsigned at the same time and then you pick your desired interpretation based on the EFLAGS or whatever.
Post 24 Aug 2009, 03:41
View user's profile Send private message Reply with quote
nazha



Joined: 05 Mar 2009
Posts: 40
Location: Beijing, China
nazha
if using %u the return is correct, thanks.
but how to do comparison? it treat 4294967295 as -1 if compare it with other integer.
Post 24 Aug 2009, 03:48
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17249
Location: In your JS exploiting you and your system
revolution
You choose signed/unsigned results by selecting the jump to use after cmp:

ja - unsigned
jg - signed

jb - unsigned
jl - signed
Post 24 Aug 2009, 03:52
View user's profile Send private message Visit poster's website Reply with quote
nazha



Joined: 05 Mar 2009
Posts: 40
Location: Beijing, China
nazha
Thanks
Post 24 Aug 2009, 03:55
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-2020, Tomasz Grysztar.

Powered by rwasa.