Commit | Line | Data |
---|---|---|
5c8a252f C |
1 | .align 1 |
2 | .globl _calqhat | |
3 | _calqhat: | |
4 | .word 0xffc | |
5 | movl 4(fp),r11 # &u[j] into r11 | |
6 | movl 8(fp),r10 # &v[1] into r10 | |
7 | cmpl (r10),(r11) # v[1] == u[j] ?? | |
8 | beql L102 | |
9 | # calculate qhat and rhat simultaneously, | |
10 | # qhat in r0 | |
11 | # rhat in r1 | |
12 | emul (r11),$0x40000000,4(r11),r4 # u[j]b+u[j+1] into r4,r5 | |
13 | ediv (r10),r4,r0,r1 # qhat = ((u[j]b+u[j+1])/v[1]) into r0 | |
14 | # (u[j]b+u[j+1] -qhat*v[1]) into r1 | |
15 | # called rhat | |
16 | L101: | |
17 | # check if v[2]*qhat > rhat*b+u[j+2] | |
18 | emul r0,4(r10),$0,r2 # qhat*v[2] into r3,r2 | |
19 | emul r1,$0x40000000,8(r11),r8 #rhat*b + u[j+2] into r9,r8 | |
20 | # give up if r3,r2 <= r9,r8, otherwise iterate | |
21 | addl2 $0,r2 # explicitly clear carry. | |
22 | subl2 r8,r2 # perform r3,r2 - r9,r8 | |
23 | sbwc r9,r3 | |
24 | bleq L103 # give up if negative or equal | |
25 | decl r0 # otherwise, qhat = qhat - 1 | |
26 | addl2 (r10),r1 # since dec'ed qhat, inc rhat by v[1] | |
27 | jbr L101 | |
28 | L102: | |
29 | # get here if v[1]==u[j] | |
30 | # set qhat to b-1 | |
31 | # rhat is easily calculated since if we substitute b-1 for qhat in | |
32 | # the formula, then it simplifies to (u[j+1] + v[1]) | |
33 | # | |
34 | addl3 4(r11),(r10),r1 # rhat = u[j+1] + v[1] | |
35 | movl $0x3fffffff,r0 # qhat = b-1 | |
36 | jbr L101 | |
37 | ||
38 | L103: | |
39 | ret | |
40 |