root/modules/reversebytes.S

/* [<][>][^][v][top][bottom][index][help] */
   1 .text
   2 // function name changed to support DNG double buffering (when there are two RAW buffers)
   3 .global reverse_bytes_order2
   4 // void reverse_bytes_order2(char* from, char*to, int count)
   5 // quickly reverse the order of a large number of bytes
   6 // NOTE we will go to count rounded up to the nearest 32
   7 reverse_bytes_order2:
   8         STMFD   SP!, {R4-R12,LR}
   9         ldr     r12, =0xFF00FF          // r12 = mask, r0 = from, r1 = to, r2 = count
  10 loop:
  11         ldmia   r0!, {r4-r11}           // load 8 words and increment
  12 // digic 6 have rev instruction
  13 // TODO could do more registers per iteration, but need to handle rounding
  14 // if bytes per iteration doesn't match dng chunk size
  15 #ifdef THUMB_FW
  16         rev16 r4,r4
  17         rev16 r5,r5
  18         rev16 r6,r6
  19         rev16 r7,r7
  20         rev16 r8,r8
  21         rev16 r9,r9
  22         rev16 r10,r10
  23         rev16 r11,r11
  24 #else
  25         // out = ((in>>8) & 0xFF00FF) | ((in&0xFF00FF) << 8);
  26         and     r3, r12, r4, lsr #8             // r3 = 0xFF00FF & (in >> 8)
  27         and     r4, r4, r12                             // r4 = in & 0xFF00FF
  28         orr     r4, r3, r4, asl #8              // out = r3 | (r4 << 8)
  29 
  30         and     r3, r12, r5, lsr #8
  31         and     r5, r5, r12
  32         orr     r5, r3, r5, asl #8
  33 
  34         and     r3, r12, r6, lsr #8
  35         and     r6, r6, r12
  36         orr     r6, r3, r6, asl #8
  37 
  38         and     r3, r12, r7, lsr #8
  39         and     r7, r7, r12
  40         orr     r7, r3, r7, asl #8
  41 
  42         and     r3, r12, r8, lsr #8
  43         and     r8, r8, r12
  44         orr     r8, r3, r8, asl #8
  45 
  46         and     r3, r12, r9, lsr #8
  47         and     r9, r9, r12
  48         orr     r9, r3, r9, asl #8
  49 
  50         and     r3, r12, r10, lsr #8
  51         and     r10, r10, r12
  52         orr     r10, r3, r10, asl #8
  53 
  54         and     r3, r12, r11, lsr #8
  55         and     r11, r11, r12
  56         orr     r11, r3, r11, asl #8
  57 #endif
  58         stmia   r1!, {r4-r11}   // store and increment
  59 
  60         subs    r2, r2, #32
  61         bgt     loop
  62         LDMFD  SP!, {R4-R12,LR}
  63         bx lr

/* [<][>][^][v][top][bottom][index][help] */