英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流

标题: 大林算法在pic16f877上的实现 [打印本页]

作者: winnie    时间: 2009-5-23 14:59
标题: 大林算法在pic16f877上的实现
面是我的大林算法的程序。*********大林算法程序********************************************************
*该程序的功能是实现U(K)=6.974* E(K)0.797* E(K-1)0.1144* U (K-1)+U(K-3)的迭代*********
*********入口:E1须为规格化数***********************************************
*********出口:OP1也为规格化数***********************************************
LIST
P=16F877
INCLUDE P16F877.INC
ACCALO
EQU
20
ACCAHI
EQU
21
EXPA
EQU

22
ACCBLO
EQU
23
ACCBHI
EQU
24
EXPB
EQU
25
ACCCLO
EQU
26
ACCCHI
EQU
27
ACCDLO
EQU
28
ACCDHI
EQU
29
TEMP
EQU
2A
TEMP1
EQU
30
TIMES
EQU
31
SIGN
EQU
2B
COUNT
EQU
2F
ACCEHI
EQU
30
ACCELO
EQU
31
OP1LO
EQU
32
OP1HI
EQU
33
OP1EX
EQU
34
;U(K)
OP2LO
EQU
35
OP2HI
EQU
36
OP2EX
EQU
37
;U(K-1)
OP3LO
EQU
38
OP3HI
EQU
39
OP3EX
EQU
3A
U(K-2)
OP4LO
EQU
3B
OP4HI
EQU
3C
OP4EX
EQU
3D
U(K-3)
E1LO
EQU
3E
E1HI
EQU
3F
E1EX
EQU
40
E(K)
E2LO
EQU
41
E2HI
EQU
42
E2EX
EQU
43

E(K-1)
TEM1LO
EQU
44
TEM1HI
EQU
45
TEM1EX
EQU
46
TEM2LO
EQU
47
TEM2HI
EQU
48
TEM2EX
EQU
49

ORG
0X000
START
GOTO
DALIN
DALIN
MOVLW
0XCA

MOVWF
ACCBLO

MOVLW
0X37
MOVWF
ACCBHI
MOVLW
0X03
MOVWF
EXPB
MOVF
E1LO,0
MOWF
ACCALO
MOVF
E1HI,0
MOWF
ACCAHI
MOVF
E1EX,0
MOWF
EXPA
6.974* E(K)
CALL
F_mpy
;调用乘法子程序
MOVF
ACCBLO,0
MOVWF
TEM1LO
MOVF
ACCBHI,0
MOVWF
TEM1HI
MOVF
EXPB,0
MOVWF
TEM1EX
;将积存入tem1
MOVLW
0X01
MOVWF
ACCBLO
MOVLW
0X33
MOVWF
ACCBHI
MOVLW
0X00
MOVWF
EXPB
MOVF
E2LO,0
MOWF
ACCALO
MOVF
E2HI,0
MOWF
ACCAHI
MOVF
E2EX,0
MOWF
EXPA
0.797* E(K-1)
CALL
F_mpy
;调用乘法子程序
MOVF
TEM1LO,0
MOVWF
ACCALO
MOVF
TEM1HI,0
MOVWF
ACCAHI
MOVF
TEM1EX,0
MOVWF
EXPA
; 6.974* E(K)0.797* E(K-1)
CALL
F_sub
;调用加法子程序
MOVF
ACCBLO,0
MOVWF
TEM1LO
MOVF
ACCBHI,0
MOVWF
TEM1HI
MOVF
EXPB,0
MOVWF
TEM1EX
;将6.974* E(K)0.797* E(K-1)的和存入
tem1
MOVLW
0X92
MOVWF
ACCBLO
MOVLW
0X3A
MOVWF
ACCBHI
MOVLW
0XFD
MOVWF
EXPB
MOVF
E1LO,0
MOWF
ACCALO
MOVF
E1HI,0
MOWF
ACCAHI
MOVF
E1EX,0
MOWF
EXPA
0.1144* U (K-1)
CALL
F_mpy
;调用乘法子程序
MOVF
TEM1LO,0
MOVWF
ACCALO
MOVF
TEM1HI,0
MOVWF
ACCAHI
MOVF
TEM1EX,0
MOVWF
EXPA
; 6.974* E(K)0.797* E(K-1)0.1144* U (K-1)
CALL
F_add
;调用加法子程序
MOVF
ACCBLO,0
MOVWF
TEM1LO
MOVF
ACCBHI,0
MOVWF
TEM1HI
MOVF
EXPB,0
;将6.974* E(K)0.797* E(K-1) 0.1144* U (K-1)
MOVWF
TEM1EX
;的和存入
tem1
MOVLW
0X2D
MOVWF
ACCBLO
MOVLW
0X38
MOVWF
ACCBHI
MOVLW
0X00
MOVWF
EXPB
MOVF
OP4LO,0
MOWF
ACCALO
MOVF
OP4HI,0
MOWF
ACCAHI
MOVF
OP4EX,0
MOWF
EXPA
0.8856*U(K-3)
CALL
F_mpy
;调用乘法子程序
MOVF
TEM1LO,0
MOVWF
ACCALO
MOVF
TEM1HI,0
MOVWF
ACCAHI
MOVF
TEM1EX,0
MOVWF
EXPA
; 6.974* E(K)0.797* E(K-1)0.1144* U (K-1)+U(K-3)
CALL
F_add
;调用加法子程序得到最终的输出值U(K)
MOVF
E1LO,0
MOVWF
E2LO
MOVF
E1HI,0
MOVWF
E2HI
MOVF
E1EX,0
MOVWF
E2EX
;将 E(K) 的值传递到E(K-1)
MOVF
OP3LO,0
MOVWF
OP4LO
MOVF
OP3HI,0
MOVWF
OP4HI
MOVF
OP3EX,0
MOVWF
OP4EX
;将 U(K-2) 的值传递到U(K-3)
MOVF
OP2LO,0
MOVWF
OP3LO
MOVF
OP2HI,0
MOVWF
OP3HI
MOVF
OP2EX,0
MOVWF
OP3EX
;将 U(K-1) 的值传递到U(K-2)
MOVF
OP1LO,0
MOVWF
OP2LO
MOVF
OP1HI,0
MOVWF
OP2HI
MOVF
OP1EX,0
MOVWF
OP2EX
;将 U(K) 的值传递到U(K-1)
MOVF
ACCBLO,0
MOVWF
OP1LO
MOVF
ACCBHI,0
MOVWF
OP1HI
MOVF
EXPB,0

MOVWF
OP1EX
;将最终的输出值赋给OP1寄存器以便下一次运算使用




欢迎光临 英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 (http://enroobbs.com/) Powered by Discuz! X3.2