VirtualBox

Ignore:
Timestamp:
Feb 7, 2023 3:39:28 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
155759
Message:

IPRT/vcc: Working on 64-bit integer support routines for the 32-bit Visual C++ compilers. bugref:10261

Location:
trunk/src/VBox/Runtime/common/compiler/vcc
Files:
8 added
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/compiler/vcc/x86-alldvrm.asm

    r98477 r98493  
    11; $Id$
    22;; @file
    3 ; BS3Kit - 32-bit Watcom C/C++, 64-bit signed integer division.
     3; IPRT - Visual C++ Compiler - signed 64-bit division support, x86.
    44;
    55
    66;
    7 ; Copyright (C) 2007-2023 Oracle and/or its affiliates.
     7; Copyright (C) 2023 Oracle and/or its affiliates.
    88;
    99; This file is part of VirtualBox base platform packages, as
     
    3535;
    3636
     37
     38;*********************************************************************************************************************************
     39;*  Header Files                                                                                                                 *
     40;*********************************************************************************************************************************
    3741%include "iprt/asmdefs.mac"
    3842
    3943
    40 BEGINCODE
    41 
    42 extern __U8D
     44;*********************************************************************************************************************************
     45;*  External Symbols                                                                                                             *
     46;*********************************************************************************************************************************
     47extern __aulldvrm
    4348
    4449
    4550;;
    46 ; 64-bit signed integer division.
     51; Division of signed 64-bit values, returning both the quotient and reminder.
    4752;
    48 ; @returns  EDX:EAX Quotient, ECX:EBX Remainder.
    49 ; @param    EDX:EAX     Dividend.
    50 ; @param    ECX:EBX     Divisor
     53; @returns  EDX:EAX Quotient, EBX:ECX Remainder.
     54; @param    [esp+04h] [ebp+08h]     Dividend (64-bit)
     55; @param    [esp+0ch] [ebp+10h]     Divisor (64-bit)
    5156;
    52 global __I8D
    53 __I8D:
     57; @note     The remainder registers are swapped compared to Watcom's I8D and U8D.
     58;
     59BEGINPROC_RAW   __alldvrm
    5460        ;
    55         ; We use __U8D to do the work, we take care of the signedness.
     61        ; Load high parts so we can examine them for negativity.
     62        ;
     63        mov     edx, [esp + 08h]            ; dividend_hi
     64        mov     ecx, [esp + 10h]            ; divisor_hi
     65
     66        ;
     67        ; We use __aullrem to do the work, we take care of the signedness.
    5668        ;
    5769        or      edx, edx
     
    6072        or      ecx, ecx
    6173        js      .negative_divisor_positive_dividend
    62         jmp     __U8D
     74
     75        ; Both positive, so same as unsigned division.
     76        jmp     __aulldvrm
    6377
    6478
     79        ;
     80        ; The rest of the code sets up a stack frame using EBP as it makes
     81        ; calls rather than tail jumps.
     82        ;
     83
    6584.negative_divisor_positive_dividend:
    66         ; negate the divisor, do unsigned division, and negate the quotient.
     85        push    ebp
     86        mov     ebp, esp
     87
     88        ; Load the low values to as we will be pushing them and probably negating them.
     89        mov     eax, dword [ebp + 08h]      ; dividend_lo
     90        mov     ebx, dword [ebp + 10h]      ; divisor_lo
     91
     92        ; negate the divisor, do unsigned division(, and negate the quotient).
    6793        neg     ecx
    6894        neg     ebx
    6995        sbb     ecx, 0
    7096
    71         call    __U8D
     97        push    ecx
     98        push    ebx
     99        push    edx
     100        push    eax
     101        call    __aulldvrm                  ; cleans up the the stack.
    72102
    73103        neg     edx
    74104        neg     eax
    75105        sbb     edx, 0
    76         ret
     106
     107        leave
     108        ret     10h
    77109
    78110.negative_dividend:
     111        push    ebp
     112        mov     ebp, esp
     113
     114        ; Load the low values to as we will be pushing them and probably negating them.
     115        mov     eax, dword [ebp + 08h]      ; dividend_lo
     116        mov     ebx, dword [ebp + 10h]      ; divisor_lo
     117
    79118        neg     edx
    80119        neg     eax
     
    86125.negative_dividend_positive_divisor:
    87126        ; negate the dividend (above), do unsigned division, and negate both quotient and remainder
    88         call    __U8D
     127
     128        push    ecx
     129        push    ebx
     130        push    edx
     131        push    eax
     132        call    __aulldvrm                  ; cleans up the the stack.
    89133
    90134        neg     edx
     
    93137
    94138.return_negated_remainder:
     139        neg     ebx
    95140        neg     ecx
    96         neg     ebx
    97         sbb     ecx, 0
    98         ret
     141        sbb     ebx, 0
     142
     143        leave
     144        ret     10h
    99145
    100146.negative_dividend_negative_divisor:
     
    104150        sbb     ecx, 0
    105151
    106         call    __U8D
     152        push    ecx
     153        push    ebx
     154        push    edx
     155        push    eax
     156        call    __aulldvrm                  ; cleans up the the stack.
     157
    107158        jmp     .return_negated_remainder
     159ENDPROC_RAW     __alldvrm
    108160
Note: See TracChangeset for help on using the changeset viewer.

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