Intranet Catprocess
  1. news...
  2. about Blackvoxel
  3. download
  4. manual
  5. videos
  6. about us
  1. And/Or/Xor

    Affected Flags
    C V N Z
        X X
    and : Register2 = Register2 & Register1
    or : Register2 = Register2 | Register1
    xor : Register2 = Register2 ^ Register1

    These tree instructions perform bitwise boolean and, or and xor operations. The following thruth tables show you the behavior of these functions.

    And
     
    0 1
    0 0 0
    1 0 1
    Or
      0 1
    0 0 1
    1 1 1
    Xor
      0 1
    0 0 1
    1 1 0

    Forms and variants

    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

    Instruction encoding

    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

    Code Examples

    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

     
  2. Google+