Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/*
2
 *	mpvecsub(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *diff)
3
 *
4
 *		diff[0:alen-1] = a[0:alen-1] - b[0:blen-1]
5
 *
6
 *	prereq: alen >= blen, diff has room for alen digits
7
 */
8
TEXT	mpvecsub(SB),$0
9
 
10
	MOVL	a+0(FP),SI
11
	MOVL	b+8(FP),BX
12
	MOVL	alen+4(FP),DX
13
	MOVL	blen+12(FP),CX
14
	MOVL	diff+16(FP),DI
15
	SUBL	CX,DX
16
	XORL	BP,BP			/* this also sets carry to 0 */
17
 
18
	/* skip subraction if b is zero */
19
	TESTL	CX,CX
20
	JZ	_sub1
21
 
22
	/* diff[0:blen-1],borrow = a[0:blen-1] - b[0:blen-1] */
23
_subloop1:
24
	MOVL	(SI)(BP*4),AX
25
	SBBL	(BX)(BP*4),AX
26
	MOVL	AX,(DI)(BP*4)
27
	INCL	BP
28
	LOOP	_subloop1
29
 
30
_sub1:
31
	INCL	DX
32
	MOVL	DX,CX
33
	LOOP	_subloop2
34
	RET
35
 
36
	/* diff[blen:alen-1] = a[blen:alen-1] - 0 */
37
_subloop2:
38
	MOVL	(SI)(BP*4),AX
39
	SBBL	$0,AX
40
	MOVL	AX,(DI)(BP*4)
41
	INCL	BP
42
	LOOP	_subloop2
43
	RET
44