Text file
src/runtime/vlop_386.s
1 // Inferno's libkern/vlop-386.s
2 // https://bitbucket.org/inferno-os/inferno-os/src/master/libkern/vlop-386.s
3 //
4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
5 // Revisions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com). All rights reserved.
6 // Portions Copyright 2009 The Go Authors. All rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 // THE SOFTWARE.
25
26 #include "textflag.h"
27
28 /*
29 * C runtime for 64-bit divide.
30 */
31
32 // runtime·_mul64x32(lo64 *uint64, a uint64, b uint32) (hi32 uint32)
33 // sets *lo64 = low 64 bits of 96-bit product a*b; returns high 32 bits.
34 TEXT runtime·_mul64by32(SB), NOSPLIT, $0
35 MOVL lo64+0(FP), CX
36 MOVL a_lo+4(FP), AX
37 MULL b+12(FP)
38 MOVL AX, 0(CX)
39 MOVL DX, BX
40 MOVL a_hi+8(FP), AX
41 MULL b+12(FP)
42 ADDL AX, BX
43 ADCL $0, DX
44 MOVL BX, 4(CX)
45 MOVL DX, AX
46 MOVL AX, hi32+16(FP)
47 RET
48
49 TEXT runtime·_div64by32(SB), NOSPLIT, $0
50 MOVL r+12(FP), CX
51 MOVL a_lo+0(FP), AX
52 MOVL a_hi+4(FP), DX
53 DIVL b+8(FP)
54 MOVL DX, 0(CX)
55 MOVL AX, q+16(FP)
56 RET
57
View as plain text