Changeset 98493 in vbox for trunk/src/VBox/Runtime/common/compiler
- Timestamp:
- Feb 7, 2023 3:39:28 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 155759
- 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 1 1 ; $Id$ 2 2 ;; @file 3 ; BS3Kit - 32-bit Watcom C/C++, 64-bit signed integer division.3 ; IPRT - Visual C++ Compiler - signed 64-bit division support, x86. 4 4 ; 5 5 6 6 ; 7 ; Copyright (C) 20 07-2023 Oracle and/or its affiliates.7 ; Copyright (C) 2023 Oracle and/or its affiliates. 8 8 ; 9 9 ; This file is part of VirtualBox base platform packages, as … … 35 35 ; 36 36 37 38 ;********************************************************************************************************************************* 39 ;* Header Files * 40 ;********************************************************************************************************************************* 37 41 %include "iprt/asmdefs.mac" 38 42 39 43 40 BEGINCODE 41 42 extern __U8D 44 ;********************************************************************************************************************************* 45 ;* External Symbols * 46 ;********************************************************************************************************************************* 47 extern __aulldvrm 43 48 44 49 45 50 ;; 46 ; 64-bit signed integer division.51 ; Division of signed 64-bit values, returning both the quotient and reminder. 47 52 ; 48 ; @returns EDX:EAX Quotient, E CX:EBX Remainder.49 ; @param EDX:EAX Dividend.50 ; @param ECX:EBX Divisor53 ; @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) 51 56 ; 52 global __I8D 53 __I8D: 57 ; @note The remainder registers are swapped compared to Watcom's I8D and U8D. 58 ; 59 BEGINPROC_RAW __alldvrm 54 60 ; 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. 56 68 ; 57 69 or edx, edx … … 60 72 or ecx, ecx 61 73 js .negative_divisor_positive_dividend 62 jmp __U8D 74 75 ; Both positive, so same as unsigned division. 76 jmp __aulldvrm 63 77 64 78 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 65 84 .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). 67 93 neg ecx 68 94 neg ebx 69 95 sbb ecx, 0 70 96 71 call __U8D 97 push ecx 98 push ebx 99 push edx 100 push eax 101 call __aulldvrm ; cleans up the the stack. 72 102 73 103 neg edx 74 104 neg eax 75 105 sbb edx, 0 76 ret 106 107 leave 108 ret 10h 77 109 78 110 .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 79 118 neg edx 80 119 neg eax … … 86 125 .negative_dividend_positive_divisor: 87 126 ; 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. 89 133 90 134 neg edx … … 93 137 94 138 .return_negated_remainder: 139 neg ebx 95 140 neg ecx 96 neg ebx 97 sbb ecx, 0 98 ret 141 sbb ebx, 0 142 143 leave 144 ret 10h 99 145 100 146 .negative_dividend_negative_divisor: … … 104 150 sbb ecx, 0 105 151 106 call __U8D 152 push ecx 153 push ebx 154 push edx 155 push eax 156 call __aulldvrm ; cleans up the the stack. 157 107 158 jmp .return_negated_remainder 159 ENDPROC_RAW __alldvrm 108 160
Note:
See TracChangeset
for help on using the changeset viewer.