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  
 
 [ 3 post ] 

 Relevant Pages 

1. Division 32-Bit/32-Bit with 16-Bit Register

2. I need to calculate a CRC 16 bit

3. 31 bit vs 24 bit - two easy questions

4. Bit-by-bit ASM disk copier

5. 32 bit ST communicating with 16 bit VB

6. How to use SE at any color resolution (256, 16-bit, 32-bit)

7. Can I use 16 bit DLL and 32-bit exe together

8. Changing from 16-bit to 32-bit makes zillion duplicate symbols

9. 16-bit to 32-bit woes

10. Should I use 16 bit or 32 bit??

11. Graphics Error 16-bit vs 32-bit

12. Printing 16 bit and 32 bit

 

 
Powered by phpBB® Forum Software