Difference between revisions of "Logical Operators and Bit Shifting"
(→Shift Right) 

Line 116:  Line 116:  
 style="verticalalign:top;"    style="verticalalign:top;"   
==Shift Right==  ==Shift Right==  
−  [[Shift Right]] moves each bit in a byte one space to the right. The rightmost bit is thrown away, and  +  [[Shift Right]] moves each bit in a byte one space to the right. The rightmost bit is thrown away, and the empty space is filled with a 0. 
−  { class="wikitable"  +  { class="wikitable" 
 '''Original Byte'''   '''Original Byte'''  
 1   1 
Revision as of 17:20, 28 December 2018
The 6502 Microprocessor supports the logical operators AND, OR, and XOR and Shift Left and Shift Right bit shifting.
ANDAND performs a logical AND on an entire byte. The result switches all bits to 0 unless both are 1. Below is a truth table for every possible condition at the bit level.

OROR performs a logical OR on an entire byte. The result switches all bits to 1 if any bit is 1, and 0 if both bits are 0. Below is a truth table for every possible condition at the bit level.

XORXOR performs a logical Exclusive OR on an entire byte. The result switches all bits to 1 if they are different or 0 if they are the same. Below is a truth table for every possible condition at the bit level.

Shift LeftShift Left moves each bit in a byte one space to the left. The leftmost bit is thrown away, and a the empty space is filled with a 0.

Shift RightShift Right moves each bit in a byte one space to the right. The rightmost bit is thrown away, and the empty space is filled with a 0.
