logical or
Author Message
logical or

I appreciate,

The code is:

or cl,cl  ;  is cl is zero?
jnz somewhere
:
:

I know what the logical or does bitwise, how does it have anything to
do with the loop condition. I cannot find any place that tells me the
flags (if any) are set by the OR. ( if it is, is it set when OR'ing the CL
register only?)

Thank you very much.
Harring Figueiredo

Fri, 27 Aug 1999 03:00:00 GMT
logical or

[snip]

Quote:
>         The code is:

>         or cl,cl  ;  is cl is zero?
>         jnz somewhere
>          :
>          :

>     I know what the logical or does bitwise, how does it have anything to
> do with the loop condition. I cannot find any place that tells me the
> flags (if any) are set by the OR. ( if it is, is it set when OR'ing the CL
> register only?)

[snip]

You must have pretty scarce resources... The OR instruction does
indeed set processor flags:

OF, CF = 0
SF, ZF, PF = as "regularly"
AF = undefined

BTW, the code snippet you presented is probably
sub-optimal. For better performance on PPro you
should write:

test    cl,cl
jnz     somewhere
...

If you have to do a lot of assembler programming (or debugging
or ...) you should really get some good assembler tutorial/reference.
Try Randall Hyde's "The Art of Assembly Language". You can find it
through his assembly language page at

http://webster.ucr.edu/Page_asm/

==> Vesa Karvonen

An optimizing programmer can always beat a C programmer.

Sat, 28 Aug 1999 03:00:00 GMT
logical or

:
:
:       I appreciate,
:
:       The code is:
:
:       or cl,cl  ;  is cl is zero?
:         jnz somewhere
:        :
:        :
:
:     I know what the logical or does bitwise, how does it have anything to
: do with the loop condition. I cannot find any place that tells me the
: flags (if any) are set by the OR. ( if it is, is it set when OR'ing the CL
: register only?)
:
:       Thank you very much.
: Harring Figueiredo

:

OR CL,CL does a bitwise or, which is a nop because oring something with itself
is generally not useful mathematically.  However, it has the side effect that
it causes the flags in the flags register to be updated based on the new
contents of CL, which happen to be the same as the original contents of
cl because of the reason given above.  One of the flags that gets set if the
result is zero is
called the ZERO flag... and the subsequent branch does NOT look at CL, it
looks at the ZERO flag.  So the combination of these two instructions
is effectively to branch of CL is non-zero... but this would NOT be the
result if EITHER of the two instructions was left out.

LOOP instructions automatically do something similar to the above
two-instruction sequence... they do this:

dec cx
jnz theloop

That works because one of the things the DEC instruction does is
set the ZERO flag if CX becomes zero.

David
:
:

Sat, 28 Aug 1999 03:00:00 GMT
logical or

Quote:
>    or cl,cl  ;  is cl is zero?
>         jnz somewhere

>     I know what the logical or does bitwise, how does it have anything to
> do with the loop condition. I cannot find any place that tells me the
> flags (if any) are set by the OR. ( if it is, is it set when OR'ing the
CL
> register only?)

The OR instruction affects the ZERO FLAG such that if the destination
becomes zero ZF is set, otherwise, ZF is cleared.  JNZ tests if ZF is set,
and if so, jumps to SOMEWHERE.

Vij

(remove XX to make email address valid)

Sat, 28 Aug 1999 03:00:00 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages