正弦函数代码及调试运行过程.docVIP

  • 12
  • 0
  • 约4.19千字
  • 约 5页
  • 2018-03-07 发布于河南
  • 举报
正弦函数代码及调试运行过程

程序 正弦波源程序清单sin.asm和vectors.asm ;This function generates the sine wave of angle using the Taylor series expansion ;sin(theta)=x( I-x 2/2 * 3(1-x2/4 * 5(1-x 2/6 * 7(1-x2/8 * 9)))) ;cos(theta)=1-x2/2(1-x2/3 * 4(1-x2/5 * 6(1-x2/7 * 8))) ;sin(2 * theta)=2 * sin(theta) * cos(theta) .title sin.asm .mmregs .def _c_int00 sin_x: .usect sin_x,360 STACK: .usect STACK ,10 k_theta .set 286 PA0 .set 0 _c_int00: .text STM #STACK + 10, SP STM k_theta, AR0 STM 0,AR1 STM #sin_x, AR6 STM #90, BRC RPTB loop1-1 LDM AR1, A LD # d_xs, DP STL A,@d_xs STL A,@d_xc CALL sinx CALL cosx LD #d_sinx,DP LD @d_sinx,16,A MPYA @d_cosx STH B,1, *AR6+ MAR *AR1+0 loop1: STM #sin_x+89,AR7 STM #88, BRC RPTB loop2-1 LD *AR7-,A STL A, *AR6+ loop2: STM #179 , BRC STM #sin_x, AR7 RPTB loop3-1 LD *AR7+, A NEG A STL A, *AR6+ loop3: STM #sin_x, AR6 STM #1, AR0 STM #360,BK loop4: PORTW *AR6+0%, PA0 B loop4 sinx: .def d_xs,d_sinx .data table_s .word 01c7h .word 030bh .word 0666h .word 1556h d_coef_s .usect coef_s,4 d_xs .usect sin_vars ,1 d_squr_xs .usect sin_vars ,1 d_temp_s .usect sin_vars ,1 d_sinx .usect sin_vars ,1 c_1_s .usect sin_vars ,1 .text SSBX FRCT STM #d_coef_s, AR5 RPT #3 MVPD #table_s, *AR5+ STM #d_coef_s, AR3 STM #d_xs, AR2 STM #c_1_s, AR4 ST #7FFFh, c_1_s SQUR *AR2+, A ST A, *AR2 ||LD *AR4, B MASR *AR2+, *AR3+, B, A MPYA A STH A, *AR2 MASR *AR2-, *AR3+, B, A MPYA *AR2+ ST B, *AR2 ||LD *AR4, B MASR *AR2- , *AR3+, B, A MPYA *AR2+ ST B, *AR2 ||LD *AR4, B

文档评论(0)

1亿VIP精品文档

相关文档