Last change
on this file since 244 was 57, checked in by Ben Rietbroek, 10 years ago |
All source-files lowercased [v1.1.1-testing]
Some standard files like 'COPYING', 'LICENSE', etc. have not been
converted to lower case because they are usually distributed uppercased.
|
File size:
2.5 KB
|
Line | |
---|
1 | ; AiR-BOOT (c) Copyright 1998-2008 M. Kiewitz
|
---|
2 | ;
|
---|
3 | ; This file is part of AiR-BOOT
|
---|
4 | ;
|
---|
5 | ; AiR-BOOT is free software: you can redistribute it and/or modify it under
|
---|
6 | ; the terms of the GNU General Public License as published by the Free
|
---|
7 | ; Software Foundation, either version 3 of the License, or (at your option)
|
---|
8 | ; any later version.
|
---|
9 | ;
|
---|
10 | ; AiR-BOOT is distributed in the hope that it will be useful, but WITHOUT ANY
|
---|
11 | ; WARRANTY: without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
12 | ; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
---|
13 | ; details.
|
---|
14 | ;
|
---|
15 | ; You should have received a copy of the GNU General Public License along with
|
---|
16 | ; AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | ;
|
---|
18 | ;---------------------------------------------------------------------------
|
---|
19 | ; AiR-BOOT / MATH
|
---|
20 | ;---------------------------------------------------------------------------
|
---|
21 |
|
---|
22 |
|
---|
23 | ; ----------------------
|
---|
24 | ; Rousseau: # MATH.ASM #
|
---|
25 | ; ----------------------
|
---|
26 | ; This module contains 32-bit multiply.
|
---|
27 | ; Other math-stuff should be placed here.
|
---|
28 |
|
---|
29 |
|
---|
30 | IFDEF MODULE_NAMES
|
---|
31 | DB 'MATH',0
|
---|
32 | ENDIF
|
---|
33 |
|
---|
34 | ; Multiply two 32-bit operands
|
---|
35 | ; In: DX:AX - operand 1
|
---|
36 | ; BX:CX - operand 2
|
---|
37 | ; Out: BX:CX:DX:AX 64-bit result
|
---|
38 | MATH_Mul32 Proc Near
|
---|
39 | local p3:word
|
---|
40 | local p2:word
|
---|
41 | local p1:word
|
---|
42 | local p0:word
|
---|
43 | local fb1:word
|
---|
44 | local fb0:word
|
---|
45 | local fa1:word
|
---|
46 | local fa0:word
|
---|
47 |
|
---|
48 | ; Save parameters
|
---|
49 | mov [fb1],bx
|
---|
50 | mov [fb0],cx
|
---|
51 | mov [fa1],dx
|
---|
52 | mov [fa0],ax
|
---|
53 |
|
---|
54 | ; Clear return value
|
---|
55 | xor ax,ax
|
---|
56 | mov [p3],ax
|
---|
57 | mov [p2],ax
|
---|
58 | mov [p1],ax
|
---|
59 | mov [p0],ax
|
---|
60 |
|
---|
61 | ; Multiply high words
|
---|
62 | mov ax,[fa1]
|
---|
63 | mul [fb1]
|
---|
64 | mov [p2],ax
|
---|
65 | mov [p3],dx
|
---|
66 |
|
---|
67 | ; Multiply high with low
|
---|
68 | mov ax,[fa1]
|
---|
69 | mul [fb0]
|
---|
70 | add [p1],ax
|
---|
71 | adc [p2],dx
|
---|
72 | adc [p3],0
|
---|
73 |
|
---|
74 |
|
---|
75 | ; Multiply low with high
|
---|
76 | mov ax,[fa0]
|
---|
77 | mul [fb1]
|
---|
78 | add [p1],ax
|
---|
79 | adc [p2],dx
|
---|
80 | adc [p3],0
|
---|
81 |
|
---|
82 | ; Multiply low words
|
---|
83 | mov ax,[fa0]
|
---|
84 | mul [fb0]
|
---|
85 | mov [p0],ax
|
---|
86 | add [p1],dx
|
---|
87 | adc [p2],0
|
---|
88 | adc [p3],0
|
---|
89 |
|
---|
90 | ; Return value BX:CX:DX:AX is QWORD result
|
---|
91 | mov bx,[p3]
|
---|
92 | mov cx,[p2]
|
---|
93 | mov dx,[p1]
|
---|
94 | mov ax,[p0]
|
---|
95 |
|
---|
96 | ret
|
---|
97 | MATH_Mul32 Endp
|
---|
Note:
See
TracBrowser
for help on using the repository browser.