- & - Bitwise AND
Usage: <expr1> & <expr2>
Effect: ANDs <expr1> with <expr2>
Example: MASK = @00001111 & @00000010
Result: MASK = @00000010 - | - Bitwise OR
Usage: <expr1> | <expr2> (| is the UNIX pipe symbol)
Effect: ORs <expr1> with <expr2>
Example: MASK = @00001111 | @11110000
Result: MASK = @11111111 - ^ - Bitwise exclusive-OR (XOR)
Usage: <expr1> ^ <expr2>
Effect: XORs <expr1> with <expr2>
Example: MASK = @01011010 ^ @11111111
Result: MASK = @10100101 - ! - NOT
Usage: !<expr>; ! is a unary operator
Effect: Negates <expr>
Example: FLAG = !0
Result: FLAG = 1 - << - Left shift
Usage: <expr> << N
Effect: Left shifts <expr> N times; N may be any valid integer expression
Example: MASK = @00000001 << 4
Result: MASK = @00010000 - >> - Right shift
Usage: <expr> >> N
Effect: Right shifts <expr> N times; N may be any valid integer expression
Example: MASK = @10000000 >> 1
Result: MASK = @01000000 - == - Is equal to
Usage: <expr1> == <expr2>
Effect: Checks for equality
Example: FLAG = 4 == 3
Result: FLAG = 1 (false)
Example: FLAG = 4 == 4
Result: FLAG = 0 (true) - != - Is not equal to
Usage: <expr1> != <expr2>
Effect: Checks for inequality
Example: FLAG = 4 != 3
Result: FLAG = 0 (true)
Example: FLAG = 4 != 4
Result: FLAG = 1 (false) - % - Modulo
Usage: <expr1> % <expr2>
Effect: Returns the remainder of <expr1> / <expr2>
Example: FLAG = 12 % 5
Result: FLAG = 2 - ~ - Ones complement
Usage: ~<expr>; ~ is a unary operator
Effect: Computes ones complement of <expr>
Example: STEP = ~$01
Result: STEP = $FE
The following code illustrates how this stuff works. Paste it into a new code window in the simulator, assemble and press [Alt-6] to view the results.
Code: Select all
.opt proc65c02,caseinsensitive
;
test0001 =@00001111
test0002 =test0001 << 4 ;shift left 4 times
test0003 =test0002 >> 4 ;shift right 4 times, will be same as test0001
test0004 =test0001 & test0002 ;bitwise AND, will be zero
test0005 =test0001 | test0002 ;bitwise OR
test0006 =@01011010^test0005 ;bitwise XOR
test0007 =!0 ;logical NOT
test0008 =4 == 3 ;equality test
test0009 =4 == 4 ;equality test
test0010 =4 != 3 ;inequality test
test0011 =4 != 4 ;inequality test
test0012 =12 % 5 ;modulo
test0013 =~1 ;1s complement
;
.endEdit: made some corrections