src/stdlib/SDL_stdlib.c
branchSDL-1.3
changeset 1663 11775724e3fe
parent 1662 782fd950bd46
child 1668 4da1ee79c9af
equal deleted inserted replaced
1662:782fd950bd46 1663:11775724e3fe
    40 #endif
    40 #endif
    41 
    41 
    42 /* Float to long */
    42 /* Float to long */
    43      void __declspec (naked) _ftol ()
    43      void __declspec (naked) _ftol ()
    44 {
    44 {
    45     __asm {
    45     /* *INDENT-OFF* */
    46         push ebp mov ebp, esp sub esp, 20 h and esp, 0F FFFFFF0h fld st (0)
    46     __asm {
    47         fst dword ptr[esp + 18 h]
    47         push        ebp
    48         fistp qword ptr[esp + 10 h]
    48         mov         ebp,esp
    49         fild qword ptr[esp + 10 h]
    49         sub         esp,20h
    50         mov edx, dword ptr[esp + 18 h]
    50         and         esp,0FFFFFFF0h
    51         mov eax, dword ptr[esp + 10 h]
    51         fld         st(0)
    52         test eax, eax
    52         fst         dword ptr [esp+18h]
    53             je integer_QnaN_or_zero
    53         fistp       qword ptr [esp+10h]
    54             arg_is_not_integer_QnaN:fsubp st (1), st
    54         fild        qword ptr [esp+10h]
    55             test edx, edx jns positive fstp dword ptr[esp]
    55         mov         edx,dword ptr [esp+18h]
    56         mov ecx, dword ptr[esp]
    56         mov         eax,dword ptr [esp+10h]
    57         xor ecx, 80000000 h
    57         test        eax,eax
    58             add ecx, 7F FFFFFFh adc eax, 0 mov edx, dword ptr[esp + 14 h]
    58         je          integer_QnaN_or_zero
    59         adc edx, 0 jmp localexit positive:fstp dword ptr[esp]
    59 arg_is_not_integer_QnaN:
    60         mov ecx, dword ptr[esp]
    60         fsubp       st(1),st
    61         add ecx, 7F FFFFFFh sbb eax, 0 mov edx, dword ptr[esp + 14 h]
    61         test        edx,edx
    62         sbb edx, 0
    62         jns         positive
    63             jmp localexit integer_QnaN_or_zero:mov edx, dword ptr[esp + 14 h]
    63         fstp        dword ptr [esp]
    64         test edx, 7F FFFFFFh
    64         mov         ecx,dword ptr [esp]
    65             jne arg_is_not_integer_QnaN fstp dword ptr[esp + 18 h]
    65         xor         ecx,80000000h
    66     fstp dword ptr[esp + 18 h] localexit:leave ret}
    66         add         ecx,7FFFFFFFh
    67 }
    67         adc         eax,0
       
    68         mov         edx,dword ptr [esp+14h]
       
    69         adc         edx,0
       
    70         jmp         localexit
       
    71 positive:
       
    72         fstp        dword ptr [esp]
       
    73         mov         ecx,dword ptr [esp]
       
    74         add         ecx,7FFFFFFFh
       
    75         sbb         eax,0
       
    76         mov         edx,dword ptr [esp+14h]
       
    77         sbb         edx,0
       
    78         jmp         localexit
       
    79 integer_QnaN_or_zero:
       
    80         mov         edx,dword ptr [esp+14h]
       
    81         test        edx,7FFFFFFFh
       
    82         jne         arg_is_not_integer_QnaN
       
    83         fstp        dword ptr [esp+18h]
       
    84         fstp        dword ptr [esp+18h]
       
    85 localexit:
       
    86         leave
       
    87         ret
       
    88     }
       
    89     /* *INDENT-ON* */
       
    90 }
       
    91 
    68 void
    92 void
    69 __declspec (naked)
    93 __declspec (naked)
    70 _ftol2_sse ()
    94 _ftol2_sse ()
    71 {
    95 {
    72     _ftol ();
    96     _ftol ();
    75 /* 64-bit math operators for 32-bit systems */
    99 /* 64-bit math operators for 32-bit systems */
    76 void
   100 void
    77 __declspec (naked)
   101 __declspec (naked)
    78 _allmul ()
   102 _allmul ()
    79 {
   103 {
    80     __asm {
   104     /* *INDENT-OFF* */
    81         push ebp
   105     __asm {
    82             mov ebp, esp
   106         push        ebp
    83             push edi
   107         mov         ebp,esp
    84             push esi push ebx sub esp, 0 Ch mov eax, dword ptr[ebp + 10 h]
   108         push        edi
    85         mov edi, dword ptr[ebp + 8]
   109         push        esi
    86         mov ebx, eax mov esi, eax sar esi, 1F h mov eax, dword ptr[ebp + 8]
   110         push        ebx
    87         mul ebx
   111         sub         esp,0Ch
    88             imul edi, esi
   112         mov         eax,dword ptr [ebp+10h]
    89             mov ecx, edx
   113         mov         edi,dword ptr [ebp+8]
    90             mov dword ptr[ebp - 18 h], eax mov edx, dword ptr[ebp + 0 Ch]
   114         mov         ebx,eax
    91         add ecx, edi imul ebx, edx mov eax, dword ptr[ebp - 18 h]
   115         mov         esi,eax
    92         lea ebx,[ebx + ecx]
   116         sar         esi,1Fh
    93         mov dword ptr[ebp - 14 h], ebx mov edx, dword ptr[ebp - 14 h]
   117         mov         eax,dword ptr [ebp+8]
    94     add esp, 0 Ch pop ebx pop esi pop edi pop ebp ret}
   118         mul         ebx
       
   119         imul        edi,esi
       
   120         mov         ecx,edx
       
   121         mov         dword ptr [ebp-18h],eax
       
   122         mov         edx,dword ptr [ebp+0Ch]
       
   123         add         ecx,edi
       
   124         imul        ebx,edx
       
   125         mov         eax,dword ptr [ebp-18h]
       
   126         lea         ebx,[ebx+ecx]
       
   127         mov         dword ptr [ebp-14h],ebx
       
   128         mov         edx,dword ptr [ebp-14h]
       
   129         add         esp,0Ch
       
   130         pop         ebx
       
   131         pop         esi
       
   132         pop         edi
       
   133         pop         ebp
       
   134         ret
       
   135     }
       
   136     /* *INDENT-ON* */
    95 }
   137 }
    96 void
   138 void
    97 __declspec (naked)
   139 __declspec (naked)
    98 _alldiv ()
   140 _alldiv ()
    99 {
   141 {
   100     __asm {
   142     /* *INDENT-OFF* */
   101         push edi push esi push ebx xor edi, edi mov eax, dword ptr[esp + 14 h]
   143     __asm {
   102         or eax, eax jge L1 inc edi mov edx, dword ptr[esp + 10 h]
   144         push        edi
   103         neg eax
   145         push        esi
   104             neg edx
   146         push        ebx
   105             sbb eax, 0
   147         xor         edi,edi
   106             mov dword ptr[esp + 14 h], eax
   148         mov         eax,dword ptr [esp+14h]
   107             mov dword ptr[esp + 10 h], edx L1:mov eax, dword ptr[esp + 1 Ch]
   149         or          eax,eax
   108         or eax, eax jge L2 inc edi mov edx, dword ptr[esp + 18 h]
   150         jge         L1
   109         neg eax
   151         inc         edi
   110             neg edx
   152         mov         edx,dword ptr [esp+10h]
   111             sbb eax, 0
   153         neg         eax
   112             mov dword ptr[esp + 1 Ch], eax
   154         neg         edx
   113             mov dword ptr[esp + 18 h], edx
   155         sbb         eax,0
   114             L2:or eax, eax jne L3 mov ecx, dword ptr[esp + 18 h]
   156         mov         dword ptr [esp+14h],eax
   115         mov eax, dword ptr[esp + 14 h]
   157         mov         dword ptr [esp+10h],edx
   116         xor edx, edx div ecx mov ebx, eax mov eax, dword ptr[esp + 10 h]
   158 L1:
   117         div ecx
   159         mov         eax,dword ptr [esp+1Ch]
   118             mov edx, ebx jmp L4 L3:mov ebx, eax mov ecx, dword ptr[esp + 18 h]
   160         or          eax,eax
   119         mov edx, dword ptr[esp + 14 h]
   161         jge         L2
   120         mov eax, dword ptr[esp + 10 h]
   162         inc         edi
   121 
   163         mov         edx,dword ptr [esp+18h]
   122 
   164         neg         eax
   123 
   165         neg         edx
   124 
   166         sbb         eax,0
   125 
   167         mov         dword ptr [esp+1Ch],eax
   126 
   168         mov         dword ptr [esp+18h],edx
   127          
   169 L2:
   128             L5:shr ebx, 1
   170         or          eax,eax
   129             rcr ecx, 1
   171         jne         L3
   130             shr edx, 1
   172         mov         ecx,dword ptr [esp+18h]
   131             rcr eax, 1
   173         mov         eax,dword ptr [esp+14h]
   132             or ebx, ebx jne L5 div ecx mov esi, eax mul dword ptr[esp + 1 Ch]
   174         xor         edx,edx
   133         mov ecx, eax mov eax, dword ptr[esp + 18 h]
   175         div         ecx
   134         mul esi add edx, ecx jb L6 cmp edx, dword ptr[esp + 14 h]
   176         mov         ebx,eax
   135         ja L6 jb L7 cmp eax, dword ptr[esp + 10 h]
   177         mov         eax,dword ptr [esp+10h]
   136     jbe L7
   178         div         ecx
   137             L6:dec esi
   179         mov         edx,ebx
   138             L7:xor edx, edx
   180         jmp         L4
   139             mov eax, esi
   181 L3:
   140             L4:dec edi
   182         mov         ebx,eax
   141             jne L8
   183         mov         ecx,dword ptr [esp+18h]
   142             neg edx neg eax sbb edx, 0 L8:pop ebx pop esi pop edi ret 10 h}
   184         mov         edx,dword ptr [esp+14h]
       
   185         mov         eax,dword ptr [esp+10h]
       
   186 L5:
       
   187         shr         ebx,1
       
   188         rcr         ecx,1
       
   189         shr         edx,1
       
   190         rcr         eax,1
       
   191         or          ebx,ebx
       
   192         jne         L5
       
   193         div         ecx
       
   194         mov         esi,eax
       
   195         mul         dword ptr [esp+1Ch]
       
   196         mov         ecx,eax
       
   197         mov         eax,dword ptr [esp+18h]
       
   198         mul         esi
       
   199         add         edx,ecx
       
   200         jb          L6
       
   201         cmp         edx,dword ptr [esp+14h]
       
   202         ja          L6
       
   203         jb          L7
       
   204         cmp         eax,dword ptr [esp+10h]
       
   205         jbe         L7
       
   206 L6:
       
   207         dec         esi
       
   208 L7:
       
   209         xor         edx,edx
       
   210         mov         eax,esi
       
   211 L4:
       
   212         dec         edi
       
   213         jne         L8
       
   214         neg         edx
       
   215         neg         eax
       
   216         sbb         edx,0
       
   217 L8:
       
   218         pop         ebx
       
   219         pop         esi
       
   220         pop         edi
       
   221         ret         10h
       
   222     }
       
   223     /* *INDENT-ON* */
   143 }
   224 }
   144 void
   225 void
   145 __declspec (naked)
   226 __declspec (naked)
   146 _aulldiv ()
   227 _aulldiv ()
   147 {
   228 {
   148     __asm {
   229     /* *INDENT-OFF* */
   149         push ebx push esi mov eax, dword ptr[esp + 18 h]
   230     __asm {
   150         or eax, eax jne L1 mov ecx, dword ptr[esp + 14 h]
   231         push        ebx
   151         mov eax, dword ptr[esp + 10 h]
   232         push        esi
   152         xor edx, edx div ecx mov ebx, eax mov eax, dword ptr[esp + 0 Ch]
   233         mov         eax,dword ptr [esp+18h]
   153         div ecx
   234         or          eax,eax
   154             mov edx, ebx jmp L2 L1:mov ecx, eax mov ebx, dword ptr[esp + 14 h]
   235         jne         L1
   155         mov edx, dword ptr[esp + 10 h]
   236         mov         ecx,dword ptr [esp+14h]
   156         mov eax, dword ptr[esp + 0 Ch]
   237         mov         eax,dword ptr [esp+10h]
   157 
   238         xor         edx,edx
   158 
   239         div         ecx
   159 
   240         mov         ebx,eax
   160 
   241         mov         eax,dword ptr [esp+0Ch]
   161 
   242         div         ecx
   162 
   243         mov         edx,ebx
   163          
   244         jmp         L2
   164             L3:shr ecx, 1
   245 L1:
   165             rcr ebx, 1
   246         mov         ecx,eax
   166             shr edx, 1
   247         mov         ebx,dword ptr [esp+14h]
   167             rcr eax, 1
   248         mov         edx,dword ptr [esp+10h]
   168             or ecx, ecx jne L3 div ebx mov esi, eax mul dword ptr[esp + 18 h]
   249         mov         eax,dword ptr [esp+0Ch]
   169         mov ecx, eax mov eax, dword ptr[esp + 14 h]
   250 L3:
   170         mul esi add edx, ecx jb L4 cmp edx, dword ptr[esp + 10 h]
   251         shr         ecx,1
   171         ja L4 jb L5 cmp eax, dword ptr[esp + 0 Ch]
   252         rcr         ebx,1
   172     jbe L5
   253         shr         edx,1
   173             L4:dec esi
   254         rcr         eax,1
   174             L5:xor edx, edx mov eax, esi L2:pop esi pop ebx ret 10 h}
   255         or          ecx,ecx
       
   256         jne         L3
       
   257         div         ebx
       
   258         mov         esi,eax
       
   259         mul         dword ptr [esp+18h]
       
   260         mov         ecx,eax
       
   261         mov         eax,dword ptr [esp+14h]
       
   262         mul         esi
       
   263         add         edx,ecx
       
   264         jb          L4
       
   265         cmp         edx,dword ptr [esp+10h]
       
   266         ja          L4
       
   267         jb          L5
       
   268         cmp         eax,dword ptr [esp+0Ch]
       
   269         jbe         L5
       
   270 L4:
       
   271         dec         esi
       
   272 L5:
       
   273         xor         edx,edx
       
   274         mov         eax,esi
       
   275 L2:
       
   276         pop         esi
       
   277         pop         ebx
       
   278         ret         10h
       
   279     }
       
   280     /* *INDENT-ON* */
   175 }
   281 }
   176 void
   282 void
   177 __declspec (naked)
   283 __declspec (naked)
   178 _allrem ()
   284 _allrem ()
   179 {
   285 {
   180     __asm {
   286     /* *INDENT-OFF* */
   181         push ebx push edi xor edi, edi mov eax, dword ptr[esp + 10 h]
   287     __asm {
   182         or eax, eax jge L1 inc edi mov edx, dword ptr[esp + 0 Ch]
   288         push        ebx
   183         neg eax
   289         push        edi
   184             neg edx
   290         xor         edi,edi
   185             sbb eax, 0
   291         mov         eax,dword ptr [esp+10h]
   186             mov dword ptr[esp + 10 h], eax
   292         or          eax,eax
   187             mov dword ptr[esp + 0 Ch], edx L1:mov eax, dword ptr[esp + 18 h]
   293         jge         L1
   188         or eax, eax jge L2 mov edx, dword ptr[esp + 14 h]
   294         inc         edi
   189         neg eax
   295         mov         edx,dword ptr [esp+0Ch]
   190             neg edx
   296         neg         eax
   191             sbb eax, 0
   297         neg         edx
   192             mov dword ptr[esp + 18 h], eax
   298         sbb         eax,0
   193             mov dword ptr[esp + 14 h], edx
   299         mov         dword ptr [esp+10h],eax
   194             L2:or eax, eax jne L3 mov ecx, dword ptr[esp + 14 h]
   300         mov         dword ptr [esp+0Ch],edx
   195         mov eax, dword ptr[esp + 10 h]
   301 L1:
   196         xor edx, edx div ecx mov eax, dword ptr[esp + 0 Ch]
   302         mov         eax,dword ptr [esp+18h]
   197         div ecx
   303         or          eax,eax
   198             mov eax, edx
   304         jge         L2
   199             xor edx, edx
   305         mov         edx,dword ptr [esp+14h]
   200             dec edi
   306         neg         eax
   201             jns L4 jmp L8 L3:mov ebx, eax mov ecx, dword ptr[esp + 14 h]
   307         neg         edx
   202         mov edx, dword ptr[esp + 10 h]
   308         sbb         eax,0
   203         mov eax, dword ptr[esp + 0 Ch]
   309         mov         dword ptr [esp+18h],eax
   204 
   310         mov         dword ptr [esp+14h],edx
   205 
   311 L2:
   206 
   312         or          eax,eax
   207 
   313         jne         L3
   208 
   314         mov         ecx,dword ptr [esp+14h]
   209 
   315         mov         eax,dword ptr [esp+10h]
   210          
   316         xor         edx,edx
   211             L5:shr ebx, 1
   317         div         ecx
   212             rcr ecx, 1
   318         mov         eax,dword ptr [esp+0Ch]
   213             shr edx, 1
   319         div         ecx
   214             rcr eax, 1
   320         mov         eax,edx
   215             or ebx, ebx jne L5 div ecx mov ecx, eax mul dword ptr[esp + 18 h]
   321         xor         edx,edx
   216         xchg eax, ecx mul dword ptr[esp + 14 h]
   322         dec         edi
   217         add edx, ecx jb L6 cmp edx, dword ptr[esp + 10 h]
   323         jns         L4
   218         ja L6 jb L7 cmp eax, dword ptr[esp + 0 Ch]
   324         jmp         L8
   219         jbe L7 L6:sub eax, dword ptr[esp + 14 h]
   325 L3:
   220         sbb edx, dword ptr[esp + 18 h]
   326         mov         ebx,eax
   221           L7:sub eax, dword ptr[esp + 0 Ch]
   327         mov         ecx,dword ptr [esp+14h]
   222         sbb edx, dword ptr[esp + 10 h]
   328         mov         edx,dword ptr [esp+10h]
   223     dec edi
   329         mov         eax,dword ptr [esp+0Ch]
   224             jns L8 L4:neg edx neg eax sbb edx, 0 L8:pop edi pop ebx ret 10 h}
   330 L5:
       
   331         shr         ebx,1
       
   332         rcr         ecx,1
       
   333         shr         edx,1
       
   334         rcr         eax,1
       
   335         or          ebx,ebx
       
   336         jne         L5
       
   337         div         ecx
       
   338         mov         ecx,eax
       
   339         mul         dword ptr [esp+18h]
       
   340         xchg        eax,ecx
       
   341         mul         dword ptr [esp+14h]
       
   342         add         edx,ecx
       
   343         jb          L6
       
   344         cmp         edx,dword ptr [esp+10h]
       
   345         ja          L6
       
   346         jb          L7
       
   347         cmp         eax,dword ptr [esp+0Ch]
       
   348         jbe         L7
       
   349 L6:
       
   350         sub         eax,dword ptr [esp+14h]
       
   351         sbb         edx,dword ptr [esp+18h]
       
   352 L7:
       
   353         sub         eax,dword ptr [esp+0Ch]
       
   354         sbb         edx,dword ptr [esp+10h]
       
   355         dec         edi
       
   356         jns         L8
       
   357 L4:
       
   358         neg         edx
       
   359         neg         eax
       
   360         sbb         edx,0
       
   361 L8:
       
   362         pop         edi
       
   363         pop         ebx
       
   364         ret         10h
       
   365     }
       
   366     /* *INDENT-ON* */
   225 }
   367 }
   226 void
   368 void
   227 __declspec (naked)
   369 __declspec (naked)
   228 _aullrem ()
   370 _aullrem ()
   229 {
   371 {
   230     __asm {
   372     /* *INDENT-OFF* */
   231         push ebx mov eax, dword ptr[esp + 14 h]
   373     __asm {
   232         or eax, eax jne L1 mov ecx, dword ptr[esp + 10 h]
   374         push        ebx
   233         mov eax, dword ptr[esp + 0 Ch]
   375         mov         eax,dword ptr [esp+14h]
   234         xor edx, edx div ecx mov eax, dword ptr[esp + 8]
   376         or          eax,eax
   235         div ecx
   377         jne         L1
   236             mov eax, edx
   378         mov         ecx,dword ptr [esp+10h]
   237             xor edx, edx jmp L2 L1:mov ecx, eax mov ebx, dword ptr[esp + 10 h]
   379         mov         eax,dword ptr [esp+0Ch]
   238         mov edx, dword ptr[esp + 0 Ch]
   380         xor         edx,edx
   239         mov eax, dword ptr[esp + 8]
   381         div         ecx
   240 
   382         mov         eax,dword ptr [esp+8]
   241 
   383         div         ecx
   242 
   384         mov         eax,edx
   243 
   385         xor         edx,edx
   244 
   386         jmp         L2
   245 
   387 L1:
   246          
   388         mov         ecx,eax
   247             L3:shr ecx, 1
   389         mov         ebx,dword ptr [esp+10h]
   248             rcr ebx, 1
   390         mov         edx,dword ptr [esp+0Ch]
   249             shr edx, 1
   391         mov         eax,dword ptr [esp+8]
   250             rcr eax, 1
   392 L3:
   251             or ecx, ecx jne L3 div ebx mov ecx, eax mul dword ptr[esp + 14 h]
   393         shr         ecx,1
   252         xchg eax, ecx mul dword ptr[esp + 10 h]
   394         rcr         ebx,1
   253         add edx, ecx jb L4 cmp edx, dword ptr[esp + 0 Ch]
   395         shr         edx,1
   254         ja L4 jb L5 cmp eax, dword ptr[esp + 8]
   396         rcr         eax,1
   255         jbe L5 L4:sub eax, dword ptr[esp + 10 h]
   397         or          ecx,ecx
   256         sbb edx, dword ptr[esp + 14 h]
   398         jne         L3
   257           L5:sub eax, dword ptr[esp + 8]
   399         div         ebx
   258         sbb edx, dword ptr[esp + 0 Ch]
   400         mov         ecx,eax
   259     neg edx neg eax sbb edx, 0 L2:pop ebx ret 10 h}
   401         mul         dword ptr [esp+14h]
       
   402         xchg        eax,ecx
       
   403         mul         dword ptr [esp+10h]
       
   404         add         edx,ecx
       
   405         jb          L4
       
   406         cmp         edx,dword ptr [esp+0Ch]
       
   407         ja          L4
       
   408         jb          L5
       
   409         cmp         eax,dword ptr [esp+8]
       
   410         jbe         L5
       
   411 L4:
       
   412         sub         eax,dword ptr [esp+10h]
       
   413         sbb         edx,dword ptr [esp+14h]
       
   414 L5:
       
   415         sub         eax,dword ptr [esp+8]
       
   416         sbb         edx,dword ptr [esp+0Ch]
       
   417         neg         edx
       
   418         neg         eax
       
   419         sbb         edx,0
       
   420 L2:
       
   421         pop         ebx
       
   422         ret         10h
       
   423     }
       
   424     /* *INDENT-ON* */
   260 }
   425 }
   261 void
   426 void
   262 __declspec (naked)
   427 __declspec (naked)
   263 _alldvrm ()
   428 _alldvrm ()
   264 {
   429 {
   265     __asm {
   430     /* *INDENT-OFF* */
   266         push edi
   431     __asm {
   267             push esi
   432         push        edi
   268             push ebp xor edi, edi xor ebp, ebp mov eax, dword ptr[esp + 14 h]
   433         push        esi
   269         or eax, eax jge L1 inc edi inc ebp mov edx, dword ptr[esp + 10 h]
   434         push        ebp
   270         neg eax
   435         xor         edi,edi
   271             neg edx
   436         xor         ebp,ebp
   272             sbb eax, 0
   437         mov         eax,dword ptr [esp+14h]
   273             mov dword ptr[esp + 14 h], eax
   438         or          eax,eax
   274             mov dword ptr[esp + 10 h], edx L1:mov eax, dword ptr[esp + 1 Ch]
   439         jge         L1
   275         or eax, eax jge L2 inc edi mov edx, dword ptr[esp + 18 h]
   440         inc         edi
   276         neg eax
   441         inc         ebp
   277             neg edx
   442         mov         edx,dword ptr [esp+10h]
   278             sbb eax, 0
   443         neg         eax
   279             mov dword ptr[esp + 1 Ch], eax
   444         neg         edx
   280             mov dword ptr[esp + 18 h], edx
   445         sbb         eax,0
   281             L2:or eax, eax jne L3 mov ecx, dword ptr[esp + 18 h]
   446         mov         dword ptr [esp+14h],eax
   282         mov eax, dword ptr[esp + 14 h]
   447         mov         dword ptr [esp+10h],edx
   283         xor edx, edx div ecx mov ebx, eax mov eax, dword ptr[esp + 10 h]
   448 L1:
   284         div ecx mov esi, eax mov eax, ebx mul dword ptr[esp + 18 h]
   449         mov         eax,dword ptr [esp+1Ch]
   285         mov ecx, eax mov eax, esi mul dword ptr[esp + 18 h]
   450         or          eax,eax
   286         add edx, ecx jmp L4 L3:mov ebx, eax mov ecx, dword ptr[esp + 18 h]
   451         jge         L2
   287         mov edx, dword ptr[esp + 14 h]
   452         inc         edi
   288         mov eax, dword ptr[esp + 10 h]
   453         mov         edx,dword ptr [esp+18h]
   289 
   454         neg         eax
   290 
   455         neg         edx
   291 
   456         sbb         eax,0
   292 
   457         mov         dword ptr [esp+1Ch],eax
   293 
   458         mov         dword ptr [esp+18h],edx
   294 
   459 L2:
   295          
   460         or          eax,eax
   296             L5:shr ebx, 1
   461         jne         L3
   297             rcr ecx, 1
   462         mov         ecx,dword ptr [esp+18h]
   298             shr edx, 1
   463         mov         eax,dword ptr [esp+14h]
   299             rcr eax, 1
   464         xor         edx,edx
   300             or ebx, ebx jne L5 div ecx mov esi, eax mul dword ptr[esp + 1 Ch]
   465         div         ecx
   301         mov ecx, eax mov eax, dword ptr[esp + 18 h]
   466         mov         ebx,eax
   302         mul esi add edx, ecx jb L6 cmp edx, dword ptr[esp + 14 h]
   467         mov         eax,dword ptr [esp+10h]
   303         ja L6 jb L7 cmp eax, dword ptr[esp + 10 h]
   468         div         ecx
   304         jbe L7 L6:dec esi sub eax, dword ptr[esp + 18 h]
   469         mov         esi,eax
   305         sbb edx, dword ptr[esp + 1 Ch]
   470         mov         eax,ebx
   306           L7:xor ebx, ebx L4:sub eax, dword ptr[esp + 10 h]
   471         mul         dword ptr [esp+18h]
   307         sbb edx, dword ptr[esp + 14 h]
   472         mov         ecx,eax
   308     dec ebp
   473         mov         eax,esi
   309             jns L9
   474         mul         dword ptr [esp+18h]
   310             neg edx
   475         add         edx,ecx
   311             neg eax
   476         jmp         L4
   312             sbb edx, 0
   477 L3:
   313             L9:mov ecx, edx
   478         mov         ebx,eax
   314             mov edx, ebx
   479         mov         ecx,dword ptr [esp+18h]
   315             mov ebx, ecx
   480         mov         edx,dword ptr [esp+14h]
   316             mov ecx, eax
   481         mov         eax,dword ptr [esp+10h]
   317             mov eax, esi
   482 L5:
   318             dec edi
   483         shr         ebx,1
   319             jne L8
   484         rcr         ecx,1
   320             neg edx neg eax sbb edx, 0 L8:pop ebp pop esi pop edi ret 10 h}
   485         shr         edx,1
       
   486         rcr         eax,1
       
   487         or          ebx,ebx
       
   488         jne         L5
       
   489         div         ecx
       
   490         mov         esi,eax
       
   491         mul         dword ptr [esp+1Ch]
       
   492         mov         ecx,eax
       
   493         mov         eax,dword ptr [esp+18h]
       
   494         mul         esi
       
   495         add         edx,ecx
       
   496         jb          L6
       
   497         cmp         edx,dword ptr [esp+14h]
       
   498         ja          L6
       
   499         jb          L7
       
   500         cmp         eax,dword ptr [esp+10h]
       
   501         jbe         L7
       
   502 L6:
       
   503         dec         esi
       
   504         sub         eax,dword ptr [esp+18h]
       
   505         sbb         edx,dword ptr [esp+1Ch]
       
   506 L7:
       
   507         xor         ebx,ebx
       
   508 L4:
       
   509         sub         eax,dword ptr [esp+10h]
       
   510         sbb         edx,dword ptr [esp+14h]
       
   511         dec         ebp
       
   512         jns         L9
       
   513         neg         edx
       
   514         neg         eax
       
   515         sbb         edx,0
       
   516 L9:
       
   517         mov         ecx,edx
       
   518         mov         edx,ebx
       
   519         mov         ebx,ecx
       
   520         mov         ecx,eax
       
   521         mov         eax,esi
       
   522         dec         edi
       
   523         jne         L8
       
   524         neg         edx
       
   525         neg         eax
       
   526         sbb         edx,0
       
   527 L8:
       
   528         pop         ebp
       
   529         pop         esi
       
   530         pop         edi
       
   531         ret         10h
       
   532     }
       
   533     /* *INDENT-ON* */
   321 }
   534 }
   322 void
   535 void
   323 __declspec (naked)
   536 __declspec (naked)
   324 _aulldvrm ()
   537 _aulldvrm ()
   325 {
   538 {
   326     __asm {
   539     /* *INDENT-OFF* */
   327         push esi mov eax, dword ptr[esp + 14 h]
   540     __asm {
   328         or eax, eax jne L1 mov ecx, dword ptr[esp + 10 h]
   541         push        esi
   329         mov eax, dword ptr[esp + 0 Ch]
   542         mov         eax,dword ptr [esp+14h]
   330         xor edx, edx div ecx mov ebx, eax mov eax, dword ptr[esp + 8]
   543         or          eax,eax
   331         div ecx mov esi, eax mov eax, ebx mul dword ptr[esp + 10 h]
   544         jne         L1
   332         mov ecx, eax mov eax, esi mul dword ptr[esp + 10 h]
   545         mov         ecx,dword ptr [esp+10h]
   333         add edx, ecx jmp L2 L1:mov ecx, eax mov ebx, dword ptr[esp + 10 h]
   546         mov         eax,dword ptr [esp+0Ch]
   334         mov edx, dword ptr[esp + 0 Ch]
   547         xor         edx,edx
   335         mov eax, dword ptr[esp + 8]
   548         div         ecx
   336 
   549         mov         ebx,eax
   337 
   550         mov         eax,dword ptr [esp+8]
   338 
   551         div         ecx
   339 
   552         mov         esi,eax
   340 
   553         mov         eax,ebx
   341 
   554         mul         dword ptr [esp+10h]
   342          
   555         mov         ecx,eax
   343             L3:shr ecx, 1
   556         mov         eax,esi
   344             rcr ebx, 1
   557         mul         dword ptr [esp+10h]
   345             shr edx, 1
   558         add         edx,ecx
   346             rcr eax, 1
   559         jmp         L2
   347             or ecx, ecx jne L3 div ebx mov esi, eax mul dword ptr[esp + 14 h]
   560 L1:
   348         mov ecx, eax mov eax, dword ptr[esp + 10 h]
   561         mov         ecx,eax
   349         mul esi add edx, ecx jb L4 cmp edx, dword ptr[esp + 0 Ch]
   562         mov         ebx,dword ptr [esp+10h]
   350         ja L4 jb L5 cmp eax, dword ptr[esp + 8]
   563         mov         edx,dword ptr [esp+0Ch]
   351         jbe L5 L4:dec esi sub eax, dword ptr[esp + 10 h]
   564         mov         eax,dword ptr [esp+8]
   352         sbb edx, dword ptr[esp + 14 h]
   565 L3:
   353           L5:xor ebx, ebx L2:sub eax, dword ptr[esp + 8]
   566         shr         ecx,1
   354         sbb edx, dword ptr[esp + 0 Ch]
   567         rcr         ebx,1
   355     neg edx
   568         shr         edx,1
   356             neg eax
   569         rcr         eax,1
   357             sbb edx, 0
   570         or          ecx,ecx
   358             mov ecx, edx
   571         jne         L3
   359             mov edx, ebx
   572         div         ebx
   360             mov ebx, ecx mov ecx, eax mov eax, esi pop esi ret 10 h}
   573         mov         esi,eax
       
   574         mul         dword ptr [esp+14h]
       
   575         mov         ecx,eax
       
   576         mov         eax,dword ptr [esp+10h]
       
   577         mul         esi
       
   578         add         edx,ecx
       
   579         jb          L4
       
   580         cmp         edx,dword ptr [esp+0Ch]
       
   581         ja          L4
       
   582         jb          L5
       
   583         cmp         eax,dword ptr [esp+8]
       
   584         jbe         L5
       
   585 L4:
       
   586         dec         esi
       
   587         sub         eax,dword ptr [esp+10h]
       
   588         sbb         edx,dword ptr [esp+14h]
       
   589 L5:
       
   590         xor         ebx,ebx
       
   591 L2:
       
   592         sub         eax,dword ptr [esp+8]
       
   593         sbb         edx,dword ptr [esp+0Ch]
       
   594         neg         edx
       
   595         neg         eax
       
   596         sbb         edx,0
       
   597         mov         ecx,edx
       
   598         mov         edx,ebx
       
   599         mov         ebx,ecx
       
   600         mov         ecx,eax
       
   601         mov         eax,esi
       
   602         pop         esi
       
   603         ret         10h
       
   604     }
       
   605     /* *INDENT-ON* */
   361 }
   606 }
   362 void
   607 void
   363 __declspec (naked)
   608 __declspec (naked)
   364 _allshl ()
   609 _allshl ()
   365 {
   610 {
   366     __asm {
   611     /* *INDENT-OFF* */
   367     cmp cl, 40 h
   612     __asm {
   368             jae RETZERO
   613         cmp         cl,40h
   369             cmp cl, 20 h
   614         jae         RETZERO
   370             jae MORE32
   615         cmp         cl,20h
   371             shld edx, eax, cl
   616         jae         MORE32
   372             shl eax, cl
   617         shld        edx,eax,cl
   373             ret
   618         shl         eax,cl
   374             MORE32:mov edx, eax
   619         ret
   375             xor eax, eax
   620 MORE32:
   376             and cl, 1F h
   621         mov         edx,eax
   377             shl edx, cl ret RETZERO:xor eax, eax xor edx, edx ret}
   622         xor         eax,eax
       
   623         and         cl,1Fh
       
   624         shl         edx,cl
       
   625         ret
       
   626 RETZERO:
       
   627         xor         eax,eax
       
   628         xor         edx,edx
       
   629         ret
       
   630     }
       
   631     /* *INDENT-ON* */
   378 }
   632 }
   379 void
   633 void
   380 __declspec (naked)
   634 __declspec (naked)
   381 _aullshr ()
   635 _aullshr ()
   382 {
   636 {
   383     __asm {
   637     /* *INDENT-OFF* */
   384     cmp cl, 40 h
   638     __asm {
   385             jae RETZERO
   639         cmp         cl,40h
   386             cmp cl, 20 h
   640         jae         RETZERO
   387             jae MORE32
   641         cmp         cl,20h
   388             shrd eax, edx, cl
   642         jae         MORE32
   389             shr edx, cl
   643         shrd        eax,edx,cl
   390             ret
   644         shr         edx,cl
   391             MORE32:mov eax, edx
   645         ret
   392             xor edx, edx
   646 MORE32:
   393             and cl, 1F h
   647         mov         eax,edx
   394             shr eax, cl ret RETZERO:xor eax, eax xor edx, edx ret}
   648         xor         edx,edx
   395 }
   649         and         cl,1Fh
   396 
   650         shr         eax,cl
   397 #endif                          /* MSC_VER */
   651         ret
   398 
   652 RETZERO:
   399 #endif                          /* !HAVE_LIBC */
   653         xor         eax,eax
       
   654         xor         edx,edx
       
   655         ret
       
   656     }
       
   657     /* *INDENT-ON* */
       
   658 }
       
   659 
       
   660 #endif /* MSC_VER */
       
   661 
       
   662 #endif /* !HAVE_LIBC */
       
   663 
   400 /* vi: set ts=4 sw=4 expandtab: */
   664 /* vi: set ts=4 sw=4 expandtab: */