byte mask negation

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi
how to write fast this

PORTD     1 0 0 0 1 0 00 (8bit unsigned char)
NEGATION  ! 0 0 0 0 ! 00 (8bit unsigned char negation mask)
--------------------------
Result    0 0 0 0 1 1 00

is it possible use any special ASM instruction or I have to use slow for/cycle statement mask compare and set result byte ?

I am not sure if XOR is best solution in this case ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

-Pantelis

Professor of Applied Murphology, University of W.T.F.Justhappened.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think you'll find the xor is the common solution.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Looks like problem is possible solve with XOR
I was not sure if is the only solution
I am trying develop GSM alarm with NC/NO/C
inputs and need have internal single logic alarm=log1 in variable som from this reason I am inverting some pins depends on NC/NO