looking at the asm... i'm aware that my asm skills sucks, but, i don't understand why they used the line in red...
w already hold 0x00 and they reload it again for the next MOVWF? BTW i would use CLRF instead... no big deal, it remove 4 instructions... long run, it may decrease a little bit the calculation latency. OK OK no big improvement, but... i couldn't resist. maybe i'll find something else?Code:ATAN banksel _Z_H ; Z_H & Z_L is loaded with 0x0000 movlw 0x00 ; Y & X is the input movwf _Z_H ; X(i+1) = Xi - Yi*_Di*2^-i movlw 0x00 ; Y(I+1) = Yi + Xi*_Di*2^-i movwf _Z_L ; Z(i+1) = Zi - _Di*ATAN(2^-i) banksel _Di ; _Di = 1 if Yi < 0 ELSE _Di = 0 bsf RV ; Set Vectoring Mode goto CORDIC_Alg SINCOS banksel _Y_L ; Z_H & Z_L is the input movlw 0x00 ; Y_H & Y_L is loaded with 0x0000 movwf _Y_L ; X_H & X_L is loaded with 6070 (1/An constant) movlw 0x00 movwf _Y_H movlw LOW .6070 movwf _X_L ; X(i+1) = Xi - Yi*_Di*2^-i movlw HIGH .6070 ; Y(I+1) = Yi + Xi*_Di*2^-i movwf _X_H ; Z(i+1) = Zi - _Di*ATAN(2^-i) banksel _Di ; _Di = 0 if Zi < 0 ELSE _Di = 1 bcf RV ; Set Rotational Mode
so, once modified, the above code section should look like...
But yeah, i think we're not at the optimization stage yetCode:ATAN CHK?RP _Z_H ; Z_H & Z_L is loaded with 0x0000 ; Y & X is the input clrf _Z_H ; X(i+1) = Xi - Yi*_Di*2^-i ; Y(I+1) = Yi + Xi*_Di*2^-i clrf _Z_L ; Z(i+1) = Zi - _Di*ATAN(2^-i) CHK?RP _Di ; _Di = 1 if Yi < 0 ELSE _Di = 0 bsf RV ; Set Vectoring Mode goto CORDIC_Alg SINCOS CHK?RP _Y_L ; Z_H & Z_L is the input ; Y_H & Y_L is loaded with 0x0000 clrf _Y_L ; X_H & X_L is loaded with 6070 (1/An constant) clrf _Y_H movlw LOW .6070 movwf _X_L ; X(i+1) = Xi - Yi*_Di*2^-i movlw HIGH .6070 ; Y(I+1) = Yi + Xi*_Di*2^-i movwf _X_H ; Z(i+1) = Zi - _Di*ATAN(2^-i) CHK?RP _Di ; _Di = 0 if Zi < 0 ELSE _Di = 1 bcf RV ; Set Rotational Mode![]()




Bookmarks