VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/math/watcom/I8D-x86-32.asm@ 96810

Last change on this file since 96810 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1; $Id: I8D-x86-32.asm 96407 2022-08-22 17:43:14Z vboxsync $
2;; @file
3; BS3Kit - 32-bit Watcom C/C++, 64-bit signed integer division.
4;
5
6;
7; Copyright (C) 2007-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; The contents of this file may alternatively be used under the terms
26; of the Common Development and Distribution License Version 1.0
27; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28; in the VirtualBox distribution, in which case the provisions of the
29; CDDL are applicable instead of those of the GPL.
30;
31; You may elect to license modified versions of this file under the
32; terms and conditions of either the GPL or the CDDL or both.
33;
34; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35;
36
37%include "iprt/asmdefs.mac"
38
39
40BEGINCODE
41
42extern __U8D
43
44
45;;
46; 64-bit signed integer division.
47;
48; @returns EDX:EAX Quotient, ECX:EBX Remainder.
49; @param EDX:EAX Dividend.
50; @param ECX:EBX Divisor
51;
52global __I8D
53__I8D:
54 ;
55 ; We use __U8D to do the work, we take care of the signedness.
56 ;
57 or edx, edx
58 js .negative_dividend
59
60 or ecx, ecx
61 js .negative_divisor_positive_dividend
62 jmp __U8D
63
64
65.negative_divisor_positive_dividend:
66 ; negate the divisor, do unsigned division, and negate the quotient.
67 neg ecx
68 neg ebx
69 sbb ecx, 0
70
71 call __U8D
72
73 neg edx
74 neg eax
75 sbb edx, 0
76 ret
77
78.negative_dividend:
79 neg edx
80 neg eax
81 sbb edx, 0
82
83 or ecx, ecx
84 js .negative_dividend_negative_divisor
85
86.negative_dividend_positive_divisor:
87 ; negate the dividend (above), do unsigned division, and negate both quotient and remainder
88 call __U8D
89
90 neg edx
91 neg eax
92 sbb edx, 0
93
94.return_negated_remainder:
95 neg ecx
96 neg ebx
97 sbb ecx, 0
98 ret
99
100.negative_dividend_negative_divisor:
101 ; negate both dividend (above) and divisor, do unsigned division, and negate the remainder.
102 neg ecx
103 neg ebx
104 sbb ecx, 0
105
106 call __U8D
107 jmp .return_negated_remainder
108
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette