Subversion Repositories planix.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#define	BDNZ	BC	16,0,
2
#define	BDNE	BC	0,2,
3
 
4
/*
5
 *	mpvecsub(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *diff)
6
 *
7
 *		diff[0:alen-1] = a[0:alen-1] - b[0:blen-1]
8
 *
9
 *	prereq: alen >= blen, diff has room for alen digits
10
 *
11
 *		R3 == a
12
 *		R4 == alen
13
 *		R5 == b
14
 *		R6 == blen
15
 *		R7 == diff
16
 *		R8 == temporary
17
 *		R9 == temporary
18
 */
19
TEXT	mpvecsub(SB),$-4
20
 
21
	MOVW	alen+4(FP),R4
22
	MOVW	b+8(FP),R5
23
	MOVW	blen+12(FP),R6
24
	MOVW	diff+16(FP),R7
25
	SUB	R6, R4		/* calculate counter for second loop (alen > blen) */
26
	SUB	$4, R3		/* pre decrement for MOVWU's */
27
	SUB	$4, R5		/* pre decrement for MOVWU's */
28
	SUBC	$4, R7		/* pre decrement for MOVWU's and set carry */
29
 
30
	/* skip subraction if b is zero */
31
	CMP	R0,R6
32
	BEQ	_sub1
33
 
34
	/* diff[0:blen-1],borrow = a[0:blen-1] - b[0:blen-1] */
35
	MOVW	R6, CTR
36
_subloop1:
37
	MOVWU	4(R3), R8
38
	MOVWU	4(R5), R9
39
	SUBE	R9, R8, R8
40
	MOVWU	R8, 4(R7)
41
	BDNZ	_subloop1
42
 
43
_sub1:
44
	/* skip subtraction if a is zero */
45
	CMP	R0, R4
46
	BEQ	_subend
47
 
48
	/* diff[blen:alen-1] = a[blen:alen-1] - 0 + carry */
49
	MOVW	R4, CTR
50
_subloop2:
51
	MOVWU	4(R3), R8
52
	SUBE	R0, R8
53
	MOVWU	R8, 4(R7)
54
	BDNZ	_subloop2
55
_subend:
56
	RETURN
57