News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

.if eax

Started by Magnum, April 06, 2013, 07:00:20 AM

Previous topic - Next topic

Magnum

I see this a lot and am trying to understand why it's used.

If eax is ORed with itself, it sets any bits that are 1 to 1.
What is the purpose of it ?

Is it the only way to determine success or failure ?

  .IF (eax) ; same as OR eax,eax

; Each bit of the result of the OR instruction is 0 if both corresponding bits of the operands
; are 0; otherwise, each bit is 1.


Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

many windows API functions return zero or non-zero
OR EAX,EAX sets the zero flag is eax if zero, clears it if not
as a side effect, it always clears the carry flag, as do most logical operations (AND, OR, XOR)
and - the sign flag will be set to the same value as the high bit of the register

as for ".if eax" - if eax is non-zero or true

ragdog

Hi

.if eax !=0    = cmp eax, 0
.if eax          =  or eax, eax

Or eax,eax is a one byte smaller and faster

this bracket in a if else statment .if (eax) is only cosmetics
for better read a code  ;)


Gel Jochen


jj2007

Intel(R) Celeron(R) M CPU        420  @ 1.60GHz (SSE3)
loop overhead is approx. 189/100 cycles

239     cycles for 100 * 3*Test
240     cycles for 100 * 3*And
240     cycles for 100 * 3*Or
234     cycles for 100 * 3*cmp 0

240     cycles for 100 * 3*Test
240     cycles for 100 * 3*And
239     cycles for 100 * 3*Or
240     cycles for 100 * 3*cmp 0

ragdog

AMD Athlon(tm) II P360 Dual-Core Processor (SSE3)
++++++14 of 20 tests valid, loop overhead is approx. 239/100 cycles

73      cycles for 100 * 3*Test
73      cycles for 100 * 3*And
73      cycles for 100 * 3*Or
73      cycles for 100 * 3*cmp 0

73      cycles for 100 * 3*Test
73      cycles for 100 * 3*And
73      cycles for 100 * 3*Or
544     cycles for 100 * 3*cmp 0

510     cycles for 100 * 3*Test
675     cycles for 100 * 3*And
566     cycles for 100 * 3*Or
542     cycles for 100 * 3*cmp 0

18      bytes for 3*Test
18      bytes for 3*And
18      bytes for 3*Or
21      bytes for 3*cmp 0


--- ok ---

hutch--

I confess I am highly UNtrusting of abbreviated notation, as a left over from the logic I did many years ago I use the expanded form most of the time.


.if eax == 0
  ; do something
.else
  ; do something else
.endif

dedndave

you could use a similar syntax in old IBM/MS Basic   :P

X=X+Y
IF X THEN ... ELSE ...


bitwise operations were one thing i liked about basic