[41604] | 1 | ; $Id: __I4D.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 | ;*******************************************************************************
|
---|
| 32 | public __I4D
|
---|
[60484] | 33 |
|
---|
| 34 | if VBOX_BIOS_CPU lt 80386
|
---|
| 35 | extrn NeedToImplementOn8086__I4D: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 |
|
---|
| 45 | _TEXT segment public 'CODE' use16
|
---|
| 46 | assume cs:_TEXT
|
---|
| 47 |
|
---|
| 48 | ;;
|
---|
[42059] | 49 | ; 32-bit signed division.
|
---|
| 50 | ;
|
---|
| 51 | ; @param dx:ax Dividend.
|
---|
| 52 | ; @param cx:bx Divisor.
|
---|
| 53 | ; @returns dx:ax Quotient.
|
---|
[58723] | 54 | ; cx:bx Remainder.
|
---|
[42059] | 55 | ;
|
---|
| 56 | __I4D:
|
---|
| 57 | pushf
|
---|
[60484] | 58 | if VBOX_BIOS_CPU ge 80386
|
---|
| 59 | .386
|
---|
[42059] | 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 |
|
---|
[58723] | 72 | idiv ecx ; eax:edx / ecx -> eax=quotient, edx=remainder.
|
---|
[42059] | 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
|
---|
[86686] | 85 | ifdef __WASM__
|
---|
[60484] | 86 | .8086
|
---|
[86686] | 87 | endif
|
---|
| 88 |
|
---|
[60484] | 89 | else
|
---|
| 90 | call NeedToImplementOn8086__I4D
|
---|
| 91 | endif
|
---|
[42059] | 92 | popf
|
---|
| 93 | ret
|
---|
| 94 |
|
---|
| 95 |
|
---|
[41604] | 96 | _TEXT ends
|
---|
| 97 | end
|
---|
| 98 |
|
---|