arch/m68k/fpsp040/binstr.S

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

File Facts

System
Linux kernel
Corpus path
arch/m68k/fpsp040/binstr.S
Extension
.S
Size
4302 bytes
Lines
140
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

|
|	binstr.sa 3.3 12/19/90
|
|
|	Description: Converts a 64-bit binary integer to bcd.
|
|	Input: 64-bit binary integer in d2:d3, desired length (LEN) in
|          d0, and a  pointer to start in memory for bcd characters
|          in d0. (This pointer must point to byte 4 of the first
|          lword of the packed decimal memory string.)
|
|	Output:	LEN bcd digits representing the 64-bit integer.
|
|	Algorithm:
|		The 64-bit binary is assumed to have a decimal point before
|		bit 63.  The fraction is multiplied by 10 using a mul by 2
|		shift and a mul by 8 shift.  The bits shifted out of the
|		msb form a decimal digit.  This process is iterated until
|		LEN digits are formed.
|
|	A1. Init d7 to 1.  D7 is the byte digit counter, and if 1, the
|		digit formed will be assumed the least significant.  This is
|		to force the first byte formed to have a 0 in the upper 4 bits.
|
|	A2. Beginning of the loop:
|		Copy the fraction in d2:d3 to d4:d5.
|
|	A3. Multiply the fraction in d2:d3 by 8 using bit-field
|		extracts and shifts.  The three msbs from d2 will go into
|		d1.
|
|	A4. Multiply the fraction in d4:d5 by 2 using shifts.  The msb
|		will be collected by the carry.
|
|	A5. Add using the carry the 64-bit quantities in d2:d3 and d4:d5
|		into d2:d3.  D1 will contain the bcd digit formed.
|
|	A6. Test d7.  If zero, the digit formed is the ms digit.  If non-
|		zero, it is the ls digit.  Put the digit in its place in the
|		upper word of d0.  If it is the ls digit, write the word
|		from d0 to memory.
|
|	A7. Decrement d6 (LEN counter) and repeat the loop until zero.
|
|	Implementation Notes:
|
|	The registers are used as follows:
|
|		d0: LEN counter
|		d1: temp used to form the digit
|		d2: upper 32-bits of fraction for mul by 8
|		d3: lower 32-bits of fraction for mul by 8
|		d4: upper 32-bits of fraction for mul by 2
|		d5: lower 32-bits of fraction for mul by 2
|		d6: temp for bit-field extracts
|		d7: byte digit formation word;digit count {0,1}
|		a0: pointer into memory for packed bcd string formation
|

|		Copyright (C) Motorola, Inc. 1990
|			All Rights Reserved
|
|       For details on the license for this file, please see the
|       file, README, in this same directory.

|BINSTR    idnt    2,1 | Motorola 040 Floating Point Software Package

	|section	8

#include "fpsp.h"

Annotation

Implementation Notes