www.pudn.com > viterbi_wlan_c54.rar > wlan_enc.asm


;**************************************************************** 
; Filename:    wlan_enc.asm 
; Function:    Convolutional encoder 
; Version:     1.00 
; Processor:   C54xx 
; Author:      LiuKai		vikingpro@163.com 
; Description: Implements the 802.11 convolutional encoder 
;              C-callable 
; 
; Useage: ushort  wlan_enc(int *frame, 
;                            int *output, 
;                            ushort frame_sz, 
;                           ) 
; 
; Convolutional encoder for 802.11:  R=1/2, K=7 
; 
;  G0 = x(n) +          x(n-2) + x(n-3) + x(n-5) + x(n-6)           
;  G1 = x(n) + x(n-1) + x(n-2) + x(n-3) +          x(n-6) 
; 
;  This code operates on packed input data and outputs packed output data 
;  in the form G0(15-0), G1(15-0), G0(31-16), G1(31-16), etc.  The first 
;  word, G0/G1[17-16], sets the top 6 unused bits to zero. 
; 
;**************************************************************** 
 
	.mmregs 
 
; Far-mode adjustment 
; ------------------- 
 
         .if __far_mode 
OFFSET   .set  2 
         .else 
OFFSET   .set  1 
         .endif 
 
 
FRAME_SZ       .set 0 
 
REG_SAVE_SZ    .set 0 
 
PARAM_OFFSET   .set FRAME_SZ + REG_SAVE_SZ + OFFSET  
 
; Register usage 
; -------------- 
     
      .asg    0 + REG_SAVE_SZ + FRAME_SZ, RETURN_ADDR ; ???? 
      .asg    0 + PARAM_OFFSET, output 
      .asg    1 + PARAM_OFFSET, frame_sz 
     
	 
	.asg	AR3, output_ptr 
	.asg	AR4, frame_ptr 
 
	.asg	BRC, rptb_cnt 
 
;************************************************************************** 
	.global _wlan_enc 
_wlan_enc 
 
; 
; Copy arguments to their local locations as necessary         
;---------------------------------------------------------------- 
 
      STLM    A, frame_ptr                        ; 1 cycle     
      MVDK   *sp(output), output_ptr              ; 2 cycles 
     
; 
; Set outer loop count by subtracting 1 from nsamps and       
; storing into block repeat count register                    
;---------------------------------------------------------------- 
 
        LD     *sp(frame_sz), A                  ; 1 cycle 
        SUB     #1, A                            ; 2 cycles 
        STLM    A, rptb_cnt                      ; 1 cycle 
        NOP										 ; 1 cycle 
 
; 
; Begin outer loop on # samples                                
;---------------------------------------------------------------- 
;_start: 
         
         RPTB    ENCODE_END-1       ; 4 cycles     	; do i= rptb_cnt,0 
         LD     *frame_ptr+,16,A    ; 1 cycle      	;  AHI = X[n    :(n-15)] 
         OR     *frame_ptr-,A       ; 1 cycle       ;  ALO = X[n-16):(n-31)] 
         LD     *frame_ptr+,16,B    ; 1 cycle 	    ;  BHI = X[n    :(n-15)] 
         OR     *frame_ptr,B        ; 1 cycle       ;  BLO = X[n-16 :(n-31)] 
         XOR    B,2,A               ; 1 cycle       ;  A = X(n) XOR X(n-2) 
         XOR    B,3,A               ; 1 cycle       ;  A = X(n) XOR X(n-2) XOR X(n-3) 
         XOR    B,6,A               ; 1 cycle       ;  A = X(n) XOR X(n-2) XOR X(n-3) XOR X(n-6)                  
         XOR    B,5,A               ; 1 cycle       ;  A = X(n) XOR X(n-2) XOR X(n-3) XOR X(n-6) XOR X(n-5)	 
         STH    A,*output_ptr+      ; 1 cycle       ;  save G0[n:(n-15)] 
         XOR    B,5,A				    ;  A = X(n) XOR X(n-2) XOR X(n-3) XOR X(n-6)          
         XOR    B,1,A               ; 1 cycle       ;  A = X(n) XOR X(n-2) XOR X(n-3) XOR X(n-6) XOR X(n-1) 
         STH    A,*output_ptr+      ; 1 cycle       ;  save G1[n:(n-15)] 
          
ENCODE_END: 
                                    ; Last loop has low word = 0000h 
         LD     *frame_ptr,16,A     ; 1 cycle      ; AHI = X[15:0] 
         LD     *frame_ptr,16,B     ; 1 cycle      ; BHI = X[15:0] 
          
         XOR    B,2,A               ; 1 cycle       ;  A = X(n) XOR X(n-2) 
         XOR    B,3,A               ; 1 cycle       ;  A = X(n) XOR X(n-2) XOR X(n-3) 
         XOR    B,6,A               ; 1 cycle       ;  A = X(n) XOR X(n-2) XOR X(n-3) XOR X(n-6) 
         XOR    B,5,A               ; 1 cycle       ;  A = X(n) XOR X(n-2) XOR X(n-3) XOR X(n-6) XOR X(n-5)	 
         STH    A,*output_ptr+      ; 1 cycle       ;  save G0[n:(n-15)] 
         XOR    B,5,A				    ;  A = X(n) XOR X(n-2) XOR X(n-3) XOR X(n-6) 
         XOR    B,1,A               ; 1 cycle       ;  A = X(n) XOR X(n-2) XOR X(n-3) XOR X(n-6) XOR X(n-1) 
         STH    A,*output_ptr-      ; 1 cycle       ;  save G1[n:(n-15)] 
 
_end: 
;       
; Restore stack to previous value, FRAME, etc..             
;---------------------------------------------------------------- 
 
RETURN: 
  
 
        .if __far_mode 
           FRETD                    ; 4 cycles 
        .else 
	   RET              			; 3 cycles                                   
        .endif 
 
;END 
 
;end of file. please do not remove. it is left here to ensure that no lines of code are removed by any editor