Echelon Neuron Instrukcja Użytkownika Strona 48

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 237
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 47
For the value pi (π), you can use the following approximation: 355/113
(3.1415929203), which has an error relative to pi of 8.5 * 10
-8
.
To multiply two unsigned long integers, you can use the _mul16 system
function.
To calculate (a*b)/c with a 32-bit intermediate result, you can use the
standard Neuron C muldiv() function:
unsigned long muldiv(unsigned long a,
unsigned long b,
unsigned long c);
You can use general-purpose pointer registers for general 16-bit values,
not just for pointer values.
Thus, one possible algorithm for the carea function is:
carea := π * r
2
= π * r * r
= 355 * r * r / 113
= (355 * r) * r / 113
which becomes:
carea = muldiv(355*r, r, 113)
which finally becomes:
carea = muldiv(_mul16(355, r), r, 113)
The proposed solution uses a fixed-point approximation for pi (355/133), and a
combination of the _mul16 and muldiv() library functions. To translate the
solution into Neuron assembly instructions, read the algorithm from right to left:
1. Push the unsigned long value of 133 onto the stack.
2. Push the unsigned long radius value onto the stack. This value is the
carea function’s argument.
3. Push the unsigned long radius value onto the stack again.
4. Push the unsigned long constant 355 onto the stack.
5. Call the _mul16 function.
6. Call the muldiv() function.
The Neuron assembly implementation of this function is shown below:
IMPORT _mul16 ; (a(2), b(2) -- (a*b)(2))
IMPORT muldiv ; (a(2), b(2), c(2) -- (a*b/c)(2))
PIFACTOR EQU d’355
PIDIVISOR EQU d’113
; PIFACTOR/PIDIVISOR = PI = 3.14159…
SCRATCH16 EQU 0 ; 16-bit scratch register
%carea APEXP ; (r(2) -- (pi*r*r)(2))
; save r(2) to SCRATCH16 and put PIDIVISOR in place:
popd [SCRATCH16] ; ()
pushd #PIDIVISOR ; (piDiv(2))
; restore radius twice:
38 Writing a Neuron Assembly Utility Function
Przeglądanie stron 47
1 2 ... 43 44 45 46 47 48 49 50 51 52 53 ... 236 237

Komentarze do niniejszej Instrukcji

Brak uwag

Honeywell Smoke Alarm IPGSM-DP manuales

Manuales del propietario y guías del usuario para No Honeywell Smoke Alarm IPGSM-DP.
Ofrecemos 1 manuales en pdf Honeywell Smoke Alarm IPGSM-DP para descargar gratis por tipos de documentos: Manual de usuario






Más productos y manuales para No Honeywell

Modelos Tipo de documento
V4043 Manual de usuario   Honeywell V4043 User's Manual, 2 paginas
CT3100 Manual de usuario   Honeywell CT3100 User's Manual, 15 paginas
F113A Manual de usuario   Honeywell F113A User's Manual, 8 paginas
WEB-600-O-US Manual de usuario   Honeywell WEB-600-O-US User's Manual [en] , 4 paginas
DC300K-E Manual de usuario   Honeywell DC300K-E User's Manual, 12 paginas
Network Card 50010425-501 Manual de usuario   Honeywell Network Card 50010425-501 User's Manual, 1 paginas
SN0500 Manual de usuario   Honeywell SN0500 User's Manual, 8 paginas
Burner M9481 Manual de usuario   Honeywell Burner M9481 User's Manual, 12 paginas
Switch C437F Manual de usuario   Honeywell Switch C437F User's Manual, 8 paginas
VISTA-128BPT Manual de usuario   Honeywell VISTA-128BPT User's Manual, 13 paginas
TR75 Manual de usuario   Honeywell TR75 User's Manual, 4 paginas
Molded Fire/Water File Chest 1106 Manual de usuario   Honeywell Molded Fire/Water File Chest 1106 User's Manual, 4 paginas
Barcode Reader 3800 Manual de usuario   Honeywell Barcode Reader 3800 User's Manual, 2 paginas
RPLS731B Manual de usuario     Honeywell RPLS731B User's Manual, 6 paginas
G Manual de usuario   Honeywell G User's Manual, 8 paginas
R7184P Manual de usuario   Honeywell R7184P User's Manual, 8 paginas
S8600 Manual de usuario   Honeywell S8600 User's Manual, 20 paginas
CT3395 Manual de usuario   Honeywell CT3395 User's Manual, 1 paginas
4909 CPVC Manual de usuario   Honeywell 4909 CPVC User's Manual, 34 paginas
HVC0001 Manual de usuario      Honeywell HVC0001 User's Manual, 52 paginas