Intranet Catprocess
  1. news...
  2. about Blackvoxel
  3. download
  4. manual
  5. videos
  6. about us
  1. Inc/Dec/Inclr/Declr - Incrementation instructions

    inc : Register = Register + x
    dec : Register = Register - x
    inclr: LastRegister = LastRegister + x

    declr: LastRegister = LastRegister +x

    Affected Flags
    C V N Z
      X X X

    The inc and dec instructions are used to respectively increment and decrement the value in a register by the amount of a specified immediate value. The specified value can be 4 bit, so the value added can be from 1 to 16 included.
    The inclr and declr forms are compact and fast forms dedicated to increment/decrement the index register used in indirect addressing modes of the move instruction. These instructions are a kind of postincrementation/postdecrementation option. The incremented/decremented register is the last register used as an index in an indirect addressing mode. The register number is stored in the R field of the status register. The amount of the incrementation/decrementation is usualy 1 but depend on the size of the last access stored in the S field of the status register.

    Forms and variants

    rx = register

    Form Effect
    inc.l #4bitsImmediateValue,rx
    rx <- rx + 4bitsImmediateValue
    dec.l #4bitsImmediateValue,rx rx <- rx - 4bitsImmediateValue
    inclr Increment the last used index register
    declr Decrement the last used index register

    Instruction encoding

    I = 4 bit value to add minus 1 (to add 1 : 0000, to add 16 : 1111)
    D = working register number
    Instruction Op
    Code
    Cycles Encoding
    inc.l #4BitSignedValue,rx 0D 6 00001101 IIIIDDDD
    dec.l #4BitSignedValue,rx 4D 6 01001101 IIIIDDDD
    inclr.l  8D 2 10001101
    declr.l  CD 2 11001101

    Code Examples

    Note: This example is for understanding and can be optimized.

    // Example : Memory Copy 

    ; r0 = Memory portion to copy
    ; r1 = Destination buffer
    ; r2 = Bytes to copy

    copy: pushregs r3
    loop: move.b (r0),r3
    move.b r3,(r1)
    inc.l #1, r0
    inc.l #1, r1
    dec.l #1, r2
    bne loop
    popregs r3
    rts
     
  2. Google+