News:

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

.if X > 0

Started by oex, October 13, 2010, 01:53:27 AM

Previous topic - Next topic

oex

.if X > 0

OK I expected this to fail on X=-1.... What is signed equivelant?

I want:

cmp eax, 0
ja ....

But with nice formatted .if if possible

OK I have fixed the bug and might have had this the wrong way round but regardless still looking for .if equiv to jmp code signed/unsigned
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

i think it's
.if X .ge 0

myself, i just write
cmp eax, 0
ja ....

or
or eax,eax
ja ....

:bg

GregL

Unsigned

.IF X > 0


Signed

.IF SDWORD PTR X > 0



Quote from: MASM Programmer's GuideSigned and Unsigned Operands

Expression operators generate unsigned jumps by default. However, if either side of the operation is signed, the assembler considers the entire operation signed.

You can use the PTR operator to tell the assembler that a particular operand in a register or constant is a signed number, as in these examples:

    .WHILE  SWORD PTR [bx] <= 0
    .IF SWORD PTR mem1 >  0

Without the PTR operator, the assembler would treat the contents of BX as an unsigned value.

You can also specify the size attributes of operands in memory locations with SBYTE, SWORD, and SDWORD, for use with .IF, .WHILE, and .REPEAT.

    .DATA
    mem1    SBYTE   ?
    mem2    WORD    ?
    .CODE
    .IF mem1 > 0
    .WHILE  mem2 < bx
    .WHILE  SWORD PTR ax < count


oex

Awesome ty guys, I was using all jumps until recently but .if syntax is a little neater in certain circumstances
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

brethren

Quote from: oex on October 13, 2010, 01:53:27 AM

What is signed equivelant?

I want:

cmp eax, 0
ja ....


for signed numbers use jg and jl. ja and jb are for unsigned comparison