>ANDN always clears if the mask is zero?
Zero before or after the N in ANDN inverts it?
clk_pin long %00000000000000000000000010000000 ' P7
ANDN OUTA, clk_pin
The N will invert that to %11111111111111111111111101111111 before it ANDs it with OUTA (for example)
As you can see,
all the locations with a 1 will leave the source the same and only the single 0 will change the source bit to a 0
MASK is a mask where the 1's set indicate the positions I am interrested in e.g. the IO-Pins
then:
OR OUTA, MASK \ is equivalent to SETbyMASK OUTA, MASK and sets the positions given by 1's in MASK to 1
ANDN OUTA, MASK \ is equivalent to CLEARbyMASK OUTA, MASK and clears the positions given by 1's in MASK to 0
this allows to use only one mask for set and clear and not two different ones that you would need with OR and AND only.
if there were MACROS I would define SETbyMASK and CLEARbyMASK to make the meaning more obvious
Thanks to all who help with corrections and suggestions for edits for this small set of Beginner PASM notes. I just replaced the original version with an updated pdf in the original thread post.
Comments
Zero before or after the N in ANDN inverts it?
clk_pin long %00000000000000000000000010000000 ' P7
ANDN OUTA, clk_pin
The N will invert that to %11111111111111111111111101111111 before it ANDs it with OUTA (for example)
As you can see,
all the locations with a 1 will leave the source the same and only the single 0 will change the source bit to a 0
MASK is a mask where the 1's set indicate the positions I am interrested in e.g. the IO-Pins
then:
OR OUTA, MASK \ is equivalent to SETbyMASK OUTA, MASK and sets the positions given by 1's in MASK to 1
ANDN OUTA, MASK \ is equivalent to CLEARbyMASK OUTA, MASK and clears the positions given by 1's in MASK to 0
this allows to use only one mask for set and clear and not two different ones that you would need with OR and AND only.
if there were MACROS I would define SETbyMASK and CLEARbyMASK to make the meaning more obvious
Erlend