The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on November 08, 2009, 03:00:52 PM

Title: Ja (Jump if above)
Post by: ragdog on November 08, 2009, 03:00:52 PM
Hi

I have a question to ja register (Jump if above)
Is this in the high level syntax

;cmp eax,ebx
;ja @return   

.if eax>=ebx

Is this correct?

Greets,
      
   
Title: Re: Ja (Jump if above)
Post by: jj2007 on November 08, 2009, 03:24:29 PM
These are two examples. Check the attachment for a more complete list (opens in WordPad, MS Word or RichMasm).
Quote.if eax>=0
   nop
.endif
test eax, eax
jb @F
   nop
@@:

.if sdword ptr eax>=0
   nop
.endif
test eax, eax
jl @F
   nop
@@:
Title: Re: Ja (Jump if above)
Post by: ragdog on November 08, 2009, 03:33:45 PM
Thanks for you reply

>= is JAE (jump if above or equal) ?

I think i must set >

.if eax >ebx jmp if greater or jmp if above

or is this wrong?

Gives a complete opcodes list with this signs (high leve syntax?)

greets
Title: Re: Ja (Jump if above)
Post by: dedndave on November 08, 2009, 03:52:52 PM
from Randall's instruction ref...

http://www.arl.wustl.edu/~lockwood/class/cs306/books/artofasm/Chapter_6/CH06-5.html#HEADING5-226
Title: Re: Ja (Jump if above)
Post by: jj2007 on November 08, 2009, 05:44:57 PM
Quote from: ragdog on November 08, 2009, 03:33:45 PM
>= is JAE (jump if above or equal) ?

Yes it is, but watch your step: the high level says .if eax<XXX then do something, the low level says jump, i.e. do nothing if it is above or equal.
Title: Re: Ja (Jump if above)
Post by: dedndave on November 08, 2009, 07:30:37 PM
hiyas Jochen - Z sends a K
how do you know if you are using signed or unsigned jumps ?
Title: Re: Ja (Jump if above)
Post by: jj2007 on November 08, 2009, 08:38:50 PM
Quote from: dedndave on November 08, 2009, 07:30:37 PM
hiyas Jochen - Z sends a K
how do you know if you are using signed or unsigned jumps ?

hiyas Dave - 2K back ;-)
See attachment above - the red ones are signed. In high level syntax, either use a signed variable: MySignedVar SDWORD -123, or .if sdword ptr eax

One frequent source of trouble is .if eax<0 - that condition is never true...

include \masm32\include\masm32rt.inc

.code
start:
mov eax, -123
.if eax<0
inkey "Wow, eax is less than zero"
.else
inkey "Surprise, eax seems higher than zero...!"
.endif
exit
end start
Title: Re: Ja (Jump if above)
Post by: ragdog on November 08, 2009, 09:19:43 PM
Thanks for your info and help
Title: Re: Ja (Jump if above)
Post by: Farabi on November 09, 2009, 01:09:46 AM
And also if Im not mistaken the "<" compare sign is unsigned, it cannot compare a signed number.
Title: Re: Ja (Jump if above)
Post by: dedndave on November 09, 2009, 01:29:47 AM
yes - i remember something about gt and lt - lol

Jochen - the J's i know - i was asking about the macro stuffage
is it ".gt" for signed ? - or something like that
of course, if i wasn't completely lazy, i could rtfm - lol
Title: Re: Ja (Jump if above)
Post by: jj2007 on November 09, 2009, 05:55:30 AM
Quote from: Farabi on November 09, 2009, 01:09:46 AM
And also if Im not mistaken the "<" compare sign is unsigned, it cannot compare a signed number.

It can, it can... just use .if sdword ptr eax in my example above

Quote from: dedndave on November 09, 2009, 01:29:47 AM
yes - i remember something about gt and lt - lol

Jochen - the J's i know - i was asking about the macro stuffage
is it ".gt" for signed ? - or something like that
of course, if i wasn't completely lazy, i could rtfm - lol

It is gt, but test yourself if that is signed or not - no idea...
Title: Re: Ja (Jump if above)
Post by: ragdog on November 13, 2009, 10:06:58 PM
Thanks for your help

ebx 123

I use .if eax>ebx ;if eax greater than ebx
           jmp out
         ; or
       ; .break for stop a  loop this
       .endif

Thanks
Title: Re: Ja (Jump if above)
Post by: jj2007 on November 13, 2009, 11:18:31 PM
Quote.if sdword ptr eax>ebx ;if eax greater than ebx: SIGNED
  nop
.endif

.if eax>ebx ;if eax above ebx: UNSIGNED
  nop
.endif