Propeller Manual

Table Of Contents
Appendix B: Math Samples and Function Tables
Anti-Log Table ($D000-$DFFF)
The anti-log table contains data used to convert base-2 exponents into unsigned numbers.
The anti-log table is comprised of 2,048 unsigned words which are each the lower 16-bits of a
17-bit mantissa (the 17
th
bit is implied and must be set separately). To use this table, shift the
top 11 bits of the exponent fraction (bits 15..5) into bits 11..1 and isolate. Add $D000 for the
anti-log table base. Read the word at that location into the result – this is the mantissa. Next,
shift the mantissa left to bits 30..15 and set bit 31 – the missing 17
th
bit of the mantissa. The
last step is to shift the result right by 31 minus the exponent integer in bits 20..16. The
exponent is now converted to an unsigned number.
Here is a routine that will convert a base-2 exponent into an unsigned number using the anti-
log table:
' Convert exponent to number
'
' on entry: exp holds 21-bit exponent with 5 integer bits and 16 fraction bits
' on exit: num holds 32-bit unsigned value
'
expnum mov num,exp 'get exponent into number
shr num,#15-11 'justify exponent fraction as word
offset
and num,table_mask 'isolate table offset bits
or num,table_antilog 'add anti-log table address
rdword num,num 'read mantissa word into number
shl num,#15 'shift mantissa into bits 30..15
or num,num0 'set top bit (17th bit of mantissa)
shr exp,#20-4 'shift exponent integer into bits 4..0
xor exp,#$1F 'inverse bits to get shift count
shr num,exp 'shift number into final position
expnum_ret ret '47..62 clocks
'(variance is due to HUB sync on
RDWORD)
num0 long $80000000 '17th bit of the mantissa
table_mask long $0FFE 'table offset mask
table_antilog long $C000 'anti-log table base
exp long 0 'input
num long 0 'output
Page 384 · Propeller Manual v1.1