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 24 Aug 2009, 03:02
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: 4624
Location: Argentina
LocoDelAssembly 24 Aug 2009, 03:18
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 24 Aug 2009, 03:38
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: 4624
Location: Argentina
LocoDelAssembly 24 Aug 2009, 03:41
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 24 Aug 2009, 03:48
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: 20617
Location: In your JS exploiting you and your system
revolution 24 Aug 2009, 03:52
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 24 Aug 2009, 03:55
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.