News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

if statement for signed value

Started by Farabi, March 11, 2010, 04:01:14 AM

Previous topic - Next topic

Farabi

I recall somebody already answered it but I forget where it is, anyone can re-explain?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

qWord


.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)



FPU in a trice: SmplMath
It's that simple!

Farabi

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

MichaelW

What version(s) of ML recognize SQWORD?
eschew obfuscation

jj2007

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

qWord

SQWORD ptr can be used with jwasm in 64Bit mode  :cheekygreen: - for ml it wont work.
FPU in a trice: SmplMath
It's that simple!

jj2007

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