[an error occurred while processing this directive]
To L.A., bialix и всем любопытствующим по поводу вычисления полинома с предыдущей страницы.
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено Bill 06 июня 2003 г. 10:16

Как обещал, показываю свой код. Размер кода - 13 команд, малость ошибся.


#define _XK_ 0
#ifdef _XK_
#define POLY_COUNT 5
#else
#define POLY_COUNT 3
#endif
;
; ** Poly -- the routine to evaluate polynomial A + Bx + Cx^2 + Dx^3 + Ex^4 + Fx^5
;
Poly: movlw POLY_COUNT ; Set loop counter
movwf LCount ;
call Clr.F ; Set summ initial value to F coefficient
movlw Poly_coeff-FPConsTbl ;
call Add.FC ;
@polyLoop: ; Evaluation loop
movlw ?Us ; Multiply the summ by the x value
call Mul.FV ;
movfw Index ; Add the current coefficient
call Add.FC ;
decfsz LCount, f ; Bump the loop counter
goto @polyLoop ; and continue if not done yet

movlw ?fVal ; Store the result
goto Put.FA ;

GetByte:
movfw Index ; Get table index
incf Index, f ;
addwf PCL, f ; Point at the table entry
;
; Floating point constant table
;
FPConsTbl:
;
; Polynomial coefficients
;
Poly_coeff:
#ifdef _XK_ // XK termocouple
dt 0x6D, 0x1A, 0xD5, 0x4F ; f = 4.61439e-06
dt 0x73, 0xA8, 0xFD, 0x0F ; e = -0.00032232
dt 0x78, 0x25, 0x11, 0x95 ; d = 0.010074993
dt 0x7C, 0xF0, 0x2F, 0x15 ; c = -0.23455460
dt 0x82, 0x7D, 0x71, 0x10 ; b = 15.84010334
dt 0x71, 0x07, 0x76, 0x36 ; a = 6.45932e-05
#else // XA termocouple
dt 0x75, 0x48, 0xEF, 0x7B ; d = 0.001533016
dt 0x7B, 0xBF, 0x51, 0x8E ; c = -0.09341727
dt 0x83, 0x4B, 0xC0, 0x9F ; b = 25.46905341
dt 0x7E, 0xF0, 0x1B, 0xB9 ; a = -0.93792301
#endif


Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru