Commit | Line | Data |
---|---|---|
e9977b56 C |
1 | |
2 | .globl _dmlad | |
3 | /* | |
4 | routine for destructive multiplication and addition to a bignum by | |
5 | two fixnums. | |
6 | ||
7 | from C, the invocation is dmlad(sdot,mul,add); | |
8 | where sdot is the address of the first special cell of the bignum | |
9 | mul is the multiplier, add is the fixnum to be added (The latter | |
10 | being passed by value, as is the usual case. | |
11 | ||
12 | ||
13 | Register assignments: | |
14 | ||
15 | r11 = current sdot | |
16 | r10 = carry | |
17 | r9 = previous sdot, for relinking. | |
18 | r8 = temporary kluge variable | |
19 | */ | |
20 | ||
21 | _dmlad: .word 0x0f00 | |
22 | movl 4(fp),r11 #initialize cell pointer | |
23 | movl 12(fp),r10 #initialize carry | |
24 | loop: emul 8(fp),(r11),r10,r0 #r0 gets cell->car times mul + carry | |
25 | ||
26 | ediv $0x40000000,r0,r10,r8 #cell->car gets prod % 2**30 | |
27 | movl r8,(r11) | |
28 | #carry gets quotient | |
29 | /* extzv $0,$30,r0,(r11) | |
30 | extv $30,$32,r0,r10 | |
31 | */ | |
32 | movl r11,r9 #save last cell for fixup at end. | |
33 | movl 4(r11),r11 #move to next cell | |
34 | bneq loop #done indicated by 0 for next sdot | |
35 | tstl r10 #if carry zero no need to allocate | |
36 | beql done #new bigit | |
37 | mcoml r10,r3 #test to see if neg 1. | |
38 | bneq alloc #if not must allocate new cell. | |
39 | tstl (r9) #make sure product isn't -2**30 | |
40 | beql alloc | |
41 | movl r0,(r9) #save old lower half of product. | |
42 | brb done | |
43 | alloc: callf $4,_newdot #otherwise allocate new bigit | |
44 | movl r10,(r0) #store carry | |
45 | movl r0,4(r9) #save new link cell | |
46 | done: movl 4(fp),r0 | |
47 | ret |