; TMS320C6x assembly language code to perform ordered dithering ; We assume that the thresholds are periodic, and hence, will be ; circularly addressed. The first two lines set up the modulo ; addressing. Remove them if the thresholds are in a linear array. MVK .S1 0x0001,AMR ; modulo block size 2^2 MVKH .S1 0x4000,AMR ; modulo addr reg B6 ; initialize ; A6 address of pixels ; B6 address of thresholds ; B0 number of pixels to threshold .trip 100 ; minimum loop count dith: LDB .D1 *A6++,A4 ; read pixel || LDB .D2 *B6++,B4 ; read threshold || CMPGTU .L1x A4,B4,A1 ; threshold pixel || ZERO .S1 A5 ; 0 if <= threshold [A1] MVK .S1 255,A5 ; 255 if > threshold || STB .D1 A5,*A6++ ; store result ||[B0] SUB .L2 B0,1,B0 ; decrement counter ||[B0] B .S2 dith ; branch if not zero