arch/m68k/fpsp040/decbin.S

Source file repositories/reference/linux-study-clean/arch/m68k/fpsp040/decbin.S

File Facts

System
Linux kernel
Corpus path
arch/m68k/fpsp040/decbin.S
Extension
.S
Size
15728 bytes
Lines
506
Domain
Architecture Layer
Bucket
arch/m68k
Inferred role
Architecture Layer: arch/m68k
Status
atlas-only

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

|
|	decbin.sa 3.3 12/19/90
|
|	Description: Converts normalized packed bcd value pointed to by
|	register A6 to extended-precision value in FP0.
|
|	Input: Normalized packed bcd value in ETEMP(a6).
|
|	Output:	Exact floating-point representation of the packed bcd value.
|
|	Saves and Modifies: D2-D5
|
|	Speed: The program decbin takes ??? cycles to execute.
|
|	Object Size:
|
|	External Reference(s): None.
|
|	Algorithm:
|	Expected is a normal bcd (i.e. non-exceptional; all inf, zero,
|	and NaN operands are dispatched without entering this routine)
|	value in 68881/882 format at location ETEMP(A6).
|
|	A1.	Convert the bcd exponent to binary by successive adds and muls.
|	Set the sign according to SE. Subtract 16 to compensate
|	for the mantissa which is to be interpreted as 17 integer
|	digits, rather than 1 integer and 16 fraction digits.
|	Note: this operation can never overflow.
|
|	A2. Convert the bcd mantissa to binary by successive
|	adds and muls in FP0. Set the sign according to SM.
|	The mantissa digits will be converted with the decimal point
|	assumed following the least-significant digit.
|	Note: this operation can never overflow.
|
|	A3. Count the number of leading/trailing zeros in the
|	bcd string.  If SE is positive, count the leading zeros;
|	if negative, count the trailing zeros.  Set the adjusted
|	exponent equal to the exponent from A1 and the zero count
|	added if SM = 1 and subtracted if SM = 0.  Scale the
|	mantissa the equivalent of forcing in the bcd value:
|
|	SM = 0	a non-zero digit in the integer position
|	SM = 1	a non-zero digit in Mant0, lsd of the fraction
|
|	this will insure that any value, regardless of its
|	representation (ex. 0.1E2, 1E1, 10E0, 100E-1), is converted
|	consistently.
|
|	A4. Calculate the factor 10^exp in FP1 using a table of
|	10^(2^n) values.  To reduce the error in forming factors
|	greater than 10^27, a directed rounding scheme is used with
|	tables rounded to RN, RM, and RP, according to the table
|	in the comments of the pwrten section.
|
|	A5. Form the final binary number by scaling the mantissa by
|	the exponent factor.  This is done by multiplying the
|	mantissa in FP0 by the factor in FP1 if the adjusted
|	exponent sign is positive, and dividing FP0 by FP1 if
|	it is negative.
|
|	Clean up and return.  Check if the final mul or div resulted
|	in an inex2 exception.  If so, set inex1 in the fpsr and
|	check if the inex1 exception is enabled.  If so, set d7 upper
|	word to $0100.  This will signal unimp.sa that an enabled inex1
|	exception occurred.  Unimp will fix the stack.
|

|		Copyright (C) Motorola, Inc. 1990
|			All Rights Reserved

Annotation

Implementation Notes