arch/alpha/lib/divide.S

Source file repositories/reference/linux-study-clean/arch/alpha/lib/divide.S

File Facts

System
Linux kernel
Corpus path
arch/alpha/lib/divide.S
Extension
.S
Size
4408 bytes
Lines
200
Domain
Architecture Layer
Bucket
arch/alpha
Inferred role
Architecture Layer: exported/initcall integration point
Status
integration implementation candidate

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

#include <linux/export.h>
#define halt .long 0

/*
 * Select function type and registers
 */
#define mask	$0
#define divisor	$1
#define compare $28
#define tmp1	$3
#define tmp2	$4

#ifdef DIV
#define DIV_ONLY(x,y...) x,##y
#define MOD_ONLY(x,y...)
#define func(x) __div##x
#define modulus $2
#define quotient $27
#define GETSIGN(x) xor $24,$25,x
#define STACK 48
#else
#define DIV_ONLY(x,y...)
#define MOD_ONLY(x,y...) x,##y
#define func(x) __rem##x
#define modulus $27
#define quotient $2
#define GETSIGN(x) bis $24,$24,x
#define STACK 32
#endif

/*
 * For 32-bit operations, we need to extend to 64-bit
 */
#ifdef INTSIZE
#define ufunction func(lu)
#define sfunction func(l)
#define LONGIFY(x) zapnot x,15,x
#define SLONGIFY(x) addl x,0,x
#else
#define ufunction func(qu)
#define sfunction func(q)
#define LONGIFY(x)
#define SLONGIFY(x)
#endif

.set noat
.align	3
.globl	ufunction
.ent	ufunction
ufunction:
	subq	$30,STACK,$30
	.frame	$30,STACK,$23
	.prologue 0

7:	stq	$1, 0($30)
	bis	$25,$25,divisor
	stq	$2, 8($30)
	bis	$24,$24,modulus
	stq	$0,16($30)
	bis	$31,$31,quotient
	LONGIFY(divisor)
	stq	tmp1,24($30)
	LONGIFY(modulus)
	bis	$31,1,mask
	DIV_ONLY(stq tmp2,32($30))
	beq	divisor, 9f			/* div by zero */

#ifdef INTSIZE
	/*
	 * shift divisor left, using 3-bit shifts for

Annotation

Implementation Notes