How to calculate bit-by-bit ?
Author Message How to calculate bit-by-bit ?

Hi all,

Do you know how to handle bit-by-bit calculation in assembly ?

i.e.

NUM1   DW 11111111111111111111111b
NUM2   DW 00000100101010101010101b

adding NUM1 and NUM2 what can I do ?

Regards.

Sat, 28 Aug 1999 03:00:00 GMT  How to calculate bit-by-bit ?

Quote:

> Hi all,

>        Do you know how to handle bit-by-bit calculation in assembly ?

> i.e.

>   NUM1   DW 11111111111111111111111b
>   NUM2   DW 00000100101010101010101b

>   adding NUM1 and NUM2 what can I do ?

That depends mostly on what you're trying to do!

a) Result = NUM1 + NUM2

mov ax,[num1]
add ax,[num2]

b) Result = Binary (bit-by-bit) addition

mov ax,[num1]
xor ax,[num2]

At this point AX has 1 bits where either NUM1 or NUM2 (but not both) has
a 1 bit.

Terje

--

Using self-discipline, see http://www.eiffel.com/discipline
"almost all programming can be viewed as an exercise in caching"

Sat, 28 Aug 1999 03:00:00 GMT  How to calculate bit-by-bit ?

:
: Hi all,
:
:
:        Do you know how to handle bit-by-bit calculation in assembly ?
:
: i.e.
:
:   NUM1   DW 11111111111111111111111b
:   NUM2   DW 00000100101010101010101b
:
:   adding NUM1 and NUM2 what can I do ?
:
: Regards.

For addition and subtraction bit-by-bit operations are best handled on
a minimum of a byte basis.  If you REALLY want you can put 1 bit per
byte and use xor to do the add... but you might as well just stick
with the add instruction.

David

Sat, 28 Aug 1999 03:00:00 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages

Powered by phpBB® Forum Software