The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Farabi on March 11, 2010, 04:01:14 AM

Title: if statement for signed value
Post by: Farabi on March 11, 2010, 04:01:14 AM
I recall somebody already answered it but I forget where it is, anyone can re-explain?
Title: Re: if statement for signed value
Post by: qWord on March 11, 2010, 04:10:00 AM

.if eax < 0              ; unsigned compare - this condition will never become true

.if SDWORD ptr eax < 0   ;make signed dword-compare
(SWORD ptr, SBYTE ptr, SQWORD ptr)



Title: Re: if statement for signed value
Post by: Farabi on March 11, 2010, 04:13:59 AM
Thanks
Title: Re: if statement for signed value
Post by: MichaelW on March 11, 2010, 10:35:38 AM
What version(s) of ML recognize SQWORD?
Title: Re: if statement for signed value
Post by: jj2007 on March 11, 2010, 11:30:48 AM
Version 9.0 recognises the MySQW SQWORD 123 but gives error A2070:invalid instruction operands for the .if:
include \masm32\include\masm32rt.inc

.code
MyVar dd 123, 456
MySQW SQWORD 123

start: mov eax, offset MyVar
.if sqword ptr [eax]<0
nop
.endif
exit
end start
Title: Re: if statement for signed value
Post by: qWord on March 11, 2010, 04:55:45 PM
SQWORD ptr can be used with jwasm in 64Bit mode  :cheekygreen: - for ml it wont work.
Title: Re: if statement for signed value
Post by: jj2007 on March 11, 2010, 06:38:41 PM
Quote from: qWord on March 11, 2010, 04:55:45 PM
SQWORD ptr can be used with jwasm in 64Bit mode  :cheekygreen: - for ml it wont work.

There are the usual workarounds :lol

include \masm32\include\masm32rt.inc

.code
MyVar dd 123, 456
SQpos SQWORD 123
SQneg SQWORD -123

start:
mov eax, offset SQpos
.if sbyte ptr [eax+sqword-1]<0
print "SQpos is negative", 13, 10
.else
print "SQpos is positive", 13, 10
.endif
mov eax, offset SQneg
.if sbyte ptr [eax+sqword-1]<0
print "SQneg is negative", 13, 10
.else
print "SQneg is positive", 13, 10
.endif
inkey chr$(13, 10, 10, "Hit any key to get outta here")
exit
end start