| Affected Flags |
|||
| C | V | N | Z |
| X | X | ||
These tree instructions perform bitwise boolean and, or and xor operations. The following thruth tables show you the behavior of these functions.
|
|
|
||||||||||||||||||||||||||||||||||||
rx = source register
ry = destination register
| Form | Effect |
| and.b ry,rx |
rx <- rx and ry |
| and.w ry,rx |
|
| and.l ry,rx | |
| or.b ry,rx | rx <- rx or ry |
| or.w ry,rx | |
| or.l ry,rx | |
| xor.b ry,rx |
rx <- rx xor ry |
| xor.w ry,rx | |
| xor.l ry,rx |
S = Source register number
D = Destination register number
| Instruction | Op Code |
Cycles | Encoding |
| and.b ry,rx | 10 | 6 | 00010000 SSSSDDDD |
| and.w ry,rx | 50 | 6 | 01010000 SSSSDDDD |
| and.l ry,rx | 90 | 6 | 10010000 SSSSDDDD |
| or.b ry,rx | 11 | 6 | 00010001 SSSSDDDD |
| or.w ry,rx | 51 | 6 | 01010001 SSSSDDDD |
| or.l ry,rx | 91 | 6 | 10010001 SSSSDDDD |
| xor.b ry,rx | 12 | 6 | 00010010 SSSSDDDD |
| xor.w ry,rx | 52 | 6 | 01010010 SSSSDDDD |
| xor.l ry,rx | 92 | 6 | 10010010 SSSSDDDD |
Note: This example is for understanding and can be optimized.
// Example : Simple (naive) Checksum of a c-style text string
; r0 = pointer to string (in)
; r0 = result (out)
checksum: pushregs r1-r2
movex.b #0,r1
loop: move.b(r0),r2
beq out
inc #1,r0
add.b r2,r1
bra loop
out: move.b r1,r0
popregs r1-r2
rts
