[41604] | 1 | ; $Id: __I4M.asm 98103 2023-01-17 14:15:46Z vboxsync $
|
---|
| 2 | ;; @file
|
---|
| 3 | ; Compiler support routines.
|
---|
| 4 | ;
|
---|
| 5 |
|
---|
| 6 | ;
|
---|
[98103] | 7 | ; Copyright (C) 2012-2023 Oracle and/or its affiliates.
|
---|
[41604] | 8 | ;
|
---|
[96407] | 9 | ; This file is part of VirtualBox base platform packages, as
|
---|
| 10 | ; available from https://www.virtualbox.org.
|
---|
[41604] | 11 | ;
|
---|
[96407] | 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 | ;
|
---|
[41604] | 27 |
|
---|
| 28 |
|
---|
| 29 | ;*******************************************************************************
|
---|
| 30 | ;* Exported Symbols *
|
---|
| 31 | ;*******************************************************************************
|
---|
[42059] | 32 | public __I4M
|
---|
[60484] | 33 |
|
---|
| 34 | if VBOX_BIOS_CPU lt 80386
|
---|
| 35 | extrn NeedToImplementOn8086__I4M:near
|
---|
[42059] | 36 | endif
|
---|
[41604] | 37 |
|
---|
[86686] | 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__
|
---|
[60484] | 41 | .8086
|
---|
[86686] | 42 | endif
|
---|
[41604] | 43 |
|
---|
| 44 | _TEXT segment public 'CODE' use16
|
---|
| 45 | assume cs:_TEXT
|
---|
| 46 |
|
---|
| 47 | ;;
|
---|
[58723] | 48 | ; 32-bit signed multiplication.
|
---|
[41604] | 49 | ;
|
---|
[42059] | 50 | ; @param dx:ax Factor 1.
|
---|
| 51 | ; @param cx:bx Factor 2.
|
---|
| 52 | ; @returns dx:ax Result.
|
---|
[41654] | 53 | ; cx, es may be modified; di is preserved
|
---|
| 54 | ;
|
---|
[42059] | 55 | __I4M:
|
---|
| 56 | pushf
|
---|
[60484] | 57 | if VBOX_BIOS_CPU ge 80386
|
---|
| 58 | .386
|
---|
[42059] | 59 | push eax
|
---|
| 60 | push edx
|
---|
| 61 | push ecx
|
---|
| 62 | push ebx
|
---|
| 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 | imul ecx ; eax * ecx -> edx:eax
|
---|
| 73 |
|
---|
| 74 | pop ebx
|
---|
| 75 | pop ecx
|
---|
| 76 |
|
---|
| 77 | pop edx
|
---|
| 78 | ror eax, 16
|
---|
| 79 | mov dx, ax
|
---|
| 80 | add sp, 2
|
---|
| 81 | pop ax
|
---|
| 82 | rol eax, 16
|
---|
[86686] | 83 | ifdef __WASM__
|
---|
[60484] | 84 | .8086
|
---|
[86686] | 85 | endif
|
---|
| 86 |
|
---|
[60484] | 87 | else
|
---|
| 88 | call NeedToImplementOn8086__I4M
|
---|
| 89 | endif
|
---|
[42059] | 90 |
|
---|
| 91 | popf
|
---|
| 92 | ret
|
---|
| 93 |
|
---|
| 94 |
|
---|
[41604] | 95 | _TEXT ends
|
---|
| 96 | end
|
---|
| 97 |
|
---|