News:

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

about "OR" instruction

Started by anuradha, June 01, 2007, 10:44:06 PM

Previous topic - Next topic

anuradha

hi people
what is the usage of instruction "OR"  ?
I mean falgs

OR   AX,CX
JL   EXIT

like above code how can anyone do tests using "OR" instruction?

please help me
thanks

dsouza123

The CF and OF flags are both cleared, they each get a value of 0.
The SF takes the final bit value of the high bit of the destination,
ZF is 1 (set) if the value of destination is 0, if the destination is non zero ZF is 0 (cleared),
PF (parity flag) value is determined using the normal rule for generating parity,
the value of AF is undefined.


dsouza123

The main result of OR is a bitwise inclusive or of the two values.

Each bit in the destination is 1 if the analogous bit in either/both source and destination is/are 1
if both are 0 then the destination is 0.


Subhadeep.Ghosh

Hello anuradha,

The C/C++ equivalent of "OR  AX, CX" would be something like, "AX |= CX;". In this case, the values stored in 'AX' is bitwise OR'ed to the values stored in 'CX' and the result is then stored in 'AX' (I hope you know the difference between bitwise OR'ing and logical OR'ing).

When the 'OR' instruction is executed, certain CPU flags are modified, depending on the outcome of the 'OR' operation. Those flags are,
CF - the carry flag, which is set if there is a carry
OF - the overflow flag, which is set if an overflow occurs
PF - the parity flag, which is set if the number of set bits in the result is odd
SF - the sign flag, which is set if the most significant bit in the result is set
ZF - the zero flag, which is set if the result is zero

JL - is the jump if less (signed) instruction. This instruction makes the instruction pointer jump to the specified location if SF != OF.

How a combination of these two instructions work in your code, is dependent upon your code.

Regards,
Subhadeep Ghosh

anuradha

dsouza123 and Subhadeep.Ghosh  thanks. its great :U :U