Reed Solomon DSP Encoding
Our TI C54x DSP Code
 
   
 Site Index
 
[Title Page] [Our DSP Code]
[Fun With Reed Solomon Codes] [MS-Word Report] [References]

  
Here is our DSP code for the Texas Instruments C54x DSP.  The code presented here is by no means optimized to be the fastest and tightest code available. 
 
Know Issues: 
There are no known issues at this time
The Code: 
Download (right click and choose 'save as'): Gold Edition 
Note: You may have to rename the file to a ASM extension.
 
ASM code:  

**************************************************************************** 
* EE113L -Fall 2000 
 
* Reed Solomon Encoder - Main Program 
 
* *************************************************************************** 

 .setsect ".data",   0x5000,1 
 .setsect ".text",   0x500,0 

;=========================data for encoding==================== 
.data 

pb  .word 0,0,0,0,0,0    ; Parity Bits aka bb 
indata  .word 5,5,5,5,5,5,5,5,5         ; In Data 
alpha  .word   1,2,4,8,3,6,12,11,5,10,7,14,15,13,9,0   ; Galois Field Coeff 
index  .word   -1,0,1,4,2,8,5,10,3,14,9,7,6,13,11,12   ; Index Field 
gg  .word   6,9,6,4,14,10,0,0,0,0,0,0,0,0,0,0       ; Generator Polymonial Coeff 
feedback  .word  0 
counti  .word 8     ; i counter 
countj  .word 5     ; j counter 

;============================================================== 
 .text 
;============ Main Code =========== 

  AR0 = #540h  ; Memory address of counti 

mainloop nop 
  A = *AR0 
  if(ALT) goto done 

  AR7 = #505h  ; AR7 points to mem location 1005, pb[5] 
  A = *AR7  ; Store value of pb[5] in Acc. A 
  nop 
  nop 
  AR7 = #indata 
  B = AR7  ; Mem address of first data point 
  nop 
  nop 
  B = B + *AR0 
  AR7 = B 
  nop 
  nop 
  B = *AR7  ; Store value of data[counti] in Acc B 
  nop 
  nop 
  A = A ^ B  ; Acc A = data[counti] XOR pb[5] 

  AR7 = A 
  nop 
  nop 
  AR6 = #index 
  A = AR6 
  nop 
  nop 
  B = AR7 
  nop 
  nop 
  A = A + B  ; Points to Index[ data[counti] XOR pb[5] ] 

  AR6 = #feedback 
  AR7 = A 
  nop 
  nop 
  A = *AR7 
  *AR6 = A  ; Store the value in Index[ data[counti] XOR pb[5] ] into feedback memory location 
  nop 
  nop 

  A = *AR6  ; Store value of feedback into Acc A 
  nop 
  nop 
  if (ALT) goto else1 ; If Acc A < 0 goto else1 

  AR1 = #countj  ; Store location of countj into AR1 
  *AR1 = #5 

innerloop AR1 = #countj  ; Store location of countj into AR1 
  A = *AR1 
  nop 
  nop 
  if(AEQ) goto finishinner 

  AR7 = #gg 
  A = AR7 
  nop 
  nop 
  B = *AR1 
  nop 
  nop 
  A = A + B 
  AR7 = A   ; Mem location of gg[countj] stored in AR7 
  nop 
  nop 
  A = *AR7  ; Store value of gg[countj] into Acc A 
  nop 
  nop 
   
  if (ALT) goto else2 ; If gg[countj] < 0 then goto else2 

  AR6 = #feedback 
  B = *AR6 
  nop 
  nop 
  A = A + B  ; Acc A = value of gg[countj] + feedback 
   
  ;============ Calculate (gg[countj] + feedback) MOD 15 =================== 

  B = A 
  A = A - #15 
  if (AEQ) goto equal30 ; If less than or equal to 15 goto less15 
  if (ALT) goto less15 
  goto less30 
  

less15 A = B   ; Store MOD value in Acc A 
  goto continue 

less30 B = A 
  A = A - #15 
  if (AEQ) goto equal30 ; If the sum = 30 then MOD result should equal 0, therefore goto equal30 
  A = B   ; Store MOD value in Acc A 

  goto continue 
equal30  A = #0   

  ;========================================================================= 

continue AR7 = #alpha  ; Store first alpha memory location into AR7 
  B = AR7 
  nop 
  nop 
  A = A + B  ; Mem location of alpha[junk MOD 15] 
  AR7 = A   ; Store correct alpha memory location index into AR7 
  nop 
  nop 

  AR6 = #pb 
  A = *AR1 
  nop 
  nop 
  A = A - #1 
  B = AR6 
  nop 
  nop 
  A = A + B  ; Memory location of pb[countj-1] 
  AR6 = A 
  nop 
  nop 
  B = *AR7  ; Store value of alpha[junk MOD 15] into B 
  nop 
  nop 
  A = *AR6  ; Store value of pb[countj - 1] into A 
  nop 
  nop 
  A = A ^ B  ; Acc A = pb[countj - 1] XOR alpha[junk MOD 15] 
  AR7 = #pb 
  B = *AR1 
  nop 
  nop 
  B = B + #500h  ; Mem location of pb[countj] 
  AR7 = B 
  nop 
  nop 
  *AR7 = A  ; Stuff Acc A into pb[countj] 
  nop 
  nop 
  goto jcount 
   

else2  AR7 = #pb 
  A = #AR7 
  nop 
  nop 
  A = A + *AR1  ; Mem location of pb[countj] 
  AR7 = A 
  nop 
  nop 
  A = A - #1  ; Mem location of pb[countj - 1] 
  AR6 = A 
  nop 
  nop 
  A = *AR6 
  *AR7 = A  ; Set pb[countj] = pb[countj - 1] 
  nop 
  nop 
  goto jcount 
 
  

finishinner AR7 = #pb 
  AR6 = #feedback 
  AR5 = #gg 
  A = *AR6 
  nop 
  nop 
  A = A + *AR5  ; Value of gg[0] + feedback 

  ;============ Calculate (gg[0] + feedback) MOD 15 =================== 

  B = A 
  A = A - #15 
  if (AEQ) goto equal30b ; If less than or equal to 15 goto less15 
  if (ALT) goto less15b 
  goto less30b 

less15b A = B   ; Store MOD value in Acc A 
  goto continue2 

less30b B = A 
  A = A - #15 
  if (AEQ) goto equal30b ; If the sum = 30 then MOD result should equal 0, therefore goto equal30 
  A = B   ; Store MOD value in Acc A 
  goto continue2 
equal30b A = #0   
   
  ;========================================================================= 

continue2 AR7 = #alpha 
  B = AR7 
  nop 
  nop 
  A = A + B  ; Memory location of alpha[junk MOD 15] 
  AR6 = A 
  nop 
  nop 
  A = *AR6  ; Put value of alpha[junk MOD 15] into Acc A 
  nop 
  nop 
  AR7 = #pb 
  *AR7 = A  ; pb[0] = alpha[junk MOD 15] 
  nop 
  nop 
  goto icounter 
   
jcount  AR1 = #countj  
  A = *AR1 
  nop 
  nop 
  A = A - #1 
  *AR1 = A 
  nop 
  nop 
  goto innerloop 
 ;======= if block 1 end ================ 

else1  AR7 = #505h 
  AR6 = #504h 
  A = *AR6- 
  nop 
  nop 
  *AR7- = A  ; pb[5] = pb[4] 
  nop 
  nop 
  A = *AR6- 
  nop 
  nop 
  *AR7- = A  ; pb[4] = pb[3] 
  nop 
  nop 
  A = *AR6- 
  nop 
  nop 
  *AR7- = A  ; pb[3] = pb[2] 
  nop 
  nop 
  A = *AR6- 
  nop 
  nop 
  *AR7- = A  ; pb[2] = pb[1] 
  nop 
  nop 
  A = *AR6- 
  nop 
  nop 
  *AR7- = A  ; pb[1] = pb[0] 
  nop 
  nop 

  *AR7 = #0  ; pb[0] = #0 

icounter AR0 = #counti 
  A = *AR0 
  nop 
  nop 
  A = A - #1 
  *AR0 = A 
  nop 
  nop 
  goto mainloop 

;============ End Program =========   
done nop 
 goto   done 

 .end 
 


 
.end