{---------------------------------------------------------------------------- bitblt.asm - Bit Block Transfer (BitBlt) ----------------------------------------------------------------------------- Description: BitBlt, or Bit Block Transfer, is the transferring of N words of data to a destination where each destination word is formed by taking bits OFFSET-1 to 0 from the one source datum, and bits 31 down to OFFSET of the next source datum. For example, the following diagram shows BitBlt between two areas in memory, with OFFSET=b : SOURCE DATA DESTINATION DATA ----------------- ---------------- 31 b b-1 0 31 0 xxxxxxxxx AAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAA BBBBBBB BBBBBBBBBBBBBBBB BBBBBBBBB CCCCCCC CCCCCCCCCCCCCCCC CCCCCCCCC DDDDDDD DDDDDDDDDDDDDDDD etc... etc... Let X & Y denote registers which alternate in storing the source data to be transferred, let P & Q denote the registers in which the shifting of X & Y into the destination format will take place, and let OFFSET=b: 31 b b-1 0 X --> xxxxxxxxx PPPPPPP Y --> PPPPPPPPP QQQQQQQ X --> QQQQQQQQQ PPPPPPP Y --> PPPPPPPPP QQQQQQQ The task is then to read source words into X, to shift bits b-1 through 0 to bit positions 31 through 32-b in register P, then to "OR" in bits 31 through b from Y into positions 31-b through 0. Then the sequence repeats, alternating with registers Y and Q. The first operation is a logical shift left, and the second is a logical shift right with "OR". ----------------------------------------------------------------------------- Program Characteristics Calling Values: r0 N r1 OFFSET i0 pointer to start of source i1 pointer to start of destination m0 +1 Registers Altered: r0, r2-r6 Return Value: none Computation Time = 2N + 7 cycles = 12.5 million words / second @ 25MHz = 50 million bytes / second @ 25MHz ----------------------------------------------------------------------------- Author: Jim Donahue, Analog Devices DSP Division Revised: 8-APR-91 ----------------------------------------------------------------------------} #define N r0 /* number of 32-bit words to transfer */ #define OFFSET r1 /* bit offset for each word */ #define A r2 /* register used to assemble transfer */ #define B r2 /* register used to assemble transfer */ #define DM_SRC dm(i0,m0) /* transfer source */ #define DM_DEST dm(i1,m0) /* transfer destination */ #define X r3 /* a source word */ #define Y r4 /* another source word */ #define LREG r5 /* register storing left-shift value */ #define RREG r6 /* register storing right-shift value */ #define LEFT by LREG /* a more descriptive syntax for left-shift */ #define RIGHT by RREG /* " " for right-shift */ .SEGMENT /pm pm_code; bitblt: N = lshift N by -1; { iterations = N/2 } N = N - 1; { iterations = N/2 -1 } RREG = -OFFSET; LREG = 32; LREG = LREG + RREG, X = DM_SRC; A = lshift X LEFT, Y = DM_SRC; A = A or lshift Y RIGHT, X = DM_SRC; lcntr=N, do blt until lce; B = lshift Y LEFT, DM_DEST = A; B = B or lshift X RIGHT, Y = DM_SRC; A = lshift X LEFT, DM_DEST = B; blt: A = A or lshift Y RIGHT, X = DM_SRC; B = lshift Y LEFT, DM_DEST = A; B = B or lshift X RIGHT; DM_DEST = B; .ENDSEG;