Computer Hardware User's Guide

Fast Logarithms on a Floating-Point Device
5-48
Figure 5–23. Fast Logarithm for FFT Displays
**************************************************************** *
* FAST Logarithm for FFT displays *
* >>>> NEED ONLY ADD ONE INSTRUCTION IN MANY CASES <<<< *
******************************************************************
|| || ;
MPYF REAL,REAL,R0 ; calculate the magnitude
MYPF IMAG,IMAG,R1 ; Note: sign bit is zero
ADDF R1,R0 ;
ASH –1,R0 ; <–One instruction logarithm!
STR R0,OUT ; scaled externally in DAC
|| || ;
**********************************************************************
* _log_E.asm DEVICE: TMS320C30 *
**********************************************************************
.global_log_E
_log_E:POP AR1 ; return address –> AR1
POPF R0 ; X –> R0
LDF R0,R1 ; use R1 to accumulate answer
LDI 2,RC ; repeat 3x
RPTB loop ;
ASH 7,R1 ;
LDE 1.0,R0 ; EXP = 0
MPYF R0,R0 ; mant^2
MPYF R0,R0 ; mant^4
MPYF R0,R0 ; mant^8
MPYF R0,R0 ; mant^16
MPYF R0,R0 ; mant^32
MPYF R0,R0 ; mant^64
MPYF R0,R0 ; mant^128
PUSHF R1 ; PUSH EXP and Mantissa (sign is now data!)
POP R0 ; POP as ianteger (EXP+FRACTION)
BD AR1 ;
FLOAT R0 ; convert EXP+FRACTION to float
MPYF @CONST,R0 ; scale the result by 2^–24 and change base
ADDI 1,SP ; restore stack pointer
.data
CONST_ADR: .word CONST
CONST .long 0e7317219h ;;Base e hand calc w/1 lsb round
.end