1 | ; $Id: __I4D.asm 96407 2022-08-22 17:43:14Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; Compiler support routines.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2012-2022 Oracle and/or its affiliates.
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox base platform packages, as
|
---|
10 | ; available from https://www.virtualbox.org.
|
---|
11 | ;
|
---|
12 | ; This program is free software; you can redistribute it and/or
|
---|
13 | ; modify it under the terms of the GNU General Public License
|
---|
14 | ; as published by the Free Software Foundation, in version 3 of the
|
---|
15 | ; License.
|
---|
16 | ;
|
---|
17 | ; This program is distributed in the hope that it will be useful, but
|
---|
18 | ; WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | ; General Public License for more details.
|
---|
21 | ;
|
---|
22 | ; You should have received a copy of the GNU General Public License
|
---|
23 | ; along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | ;
|
---|
25 | ; SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | ;
|
---|
27 |
|
---|
28 |
|
---|
29 | ;*******************************************************************************
|
---|
30 | ;* Exported Symbols *
|
---|
31 | ;*******************************************************************************
|
---|
32 | public __I4D
|
---|
33 |
|
---|
34 | if VBOX_BIOS_CPU lt 80386
|
---|
35 | extrn NeedToImplementOn8086__I4D:near
|
---|
36 | endif
|
---|
37 |
|
---|
38 | ; MASM (ML.EXE) is used for PXE and no longer understands the .8086 directive.
|
---|
39 | ; WASM is used for the BIOS and understands it just fine.
|
---|
40 | ifdef __WASM__
|
---|
41 | .8086
|
---|
42 | endif
|
---|
43 |
|
---|
44 |
|
---|
45 | _TEXT segment public 'CODE' use16
|
---|
46 | assume cs:_TEXT
|
---|
47 |
|
---|
48 | ;;
|
---|
49 | ; 32-bit signed division.
|
---|
50 | ;
|
---|
51 | ; @param dx:ax Dividend.
|
---|
52 | ; @param cx:bx Divisor.
|
---|
53 | ; @returns dx:ax Quotient.
|
---|
54 | ; cx:bx Remainder.
|
---|
55 | ;
|
---|
56 | __I4D:
|
---|
57 | pushf
|
---|
58 | if VBOX_BIOS_CPU ge 80386
|
---|
59 | .386
|
---|
60 | push eax
|
---|
61 | push edx
|
---|
62 | push ecx
|
---|
63 |
|
---|
64 | rol eax, 16
|
---|
65 | mov ax, dx
|
---|
66 | ror eax, 16
|
---|
67 | xor edx, edx
|
---|
68 |
|
---|
69 | shr ecx, 16
|
---|
70 | mov cx, bx
|
---|
71 |
|
---|
72 | idiv ecx ; eax:edx / ecx -> eax=quotient, edx=remainder.
|
---|
73 |
|
---|
74 | mov bx, dx
|
---|
75 | pop ecx
|
---|
76 | shr edx, 16
|
---|
77 | mov cx, dx
|
---|
78 |
|
---|
79 | pop edx
|
---|
80 | ror eax, 16
|
---|
81 | mov dx, ax
|
---|
82 | add sp, 2
|
---|
83 | pop ax
|
---|
84 | rol eax, 16
|
---|
85 | ifdef __WASM__
|
---|
86 | .8086
|
---|
87 | endif
|
---|
88 |
|
---|
89 | else
|
---|
90 | call NeedToImplementOn8086__I4D
|
---|
91 | endif
|
---|
92 | popf
|
---|
93 | ret
|
---|
94 |
|
---|
95 |
|
---|
96 | _TEXT ends
|
---|
97 | end
|
---|
98 |
|
---|