src/stdlib/SDL_stdlib.c
author Sam Lantinga <slouken@libsdl.org>
Sat, 04 Nov 2017 15:34:14 -0700
changeset 11682 b26412a89fbb
parent 11404 bd5b569b2a1b
child 11684 eccdf37f8996
permissions -rw-r--r--
Added float versions of SDL's math functions
slouken@1330
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@10737
     3
  Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
slouken@1330
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@1330
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@1330
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@1330
    20
*/
icculus@9306
    21
icculus@9306
    22
#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
icculus@9306
    23
#define SDL_DISABLE_ANALYZE_MACROS 1
icculus@9306
    24
#endif
icculus@9306
    25
icculus@8093
    26
#include "../SDL_internal.h"
slouken@1330
    27
slouken@1330
    28
/* This file contains portable stdlib functions for SDL */
slouken@1330
    29
slouken@1354
    30
#include "SDL_stdinc.h"
slouken@7351
    31
#include "../libm/math_libm.h"
slouken@1330
    32
slouken@7351
    33
slouken@7351
    34
double
slouken@7351
    35
SDL_atan(double x)
slouken@7351
    36
{
slouken@10505
    37
#if defined(HAVE_ATAN)
slouken@7351
    38
    return atan(x);
slouken@7351
    39
#else
slouken@7351
    40
    return SDL_uclibc_atan(x);
slouken@11682
    41
#endif
slouken@11682
    42
}
slouken@11682
    43
slouken@11682
    44
float
slouken@11682
    45
SDL_atanf(float x)
slouken@11682
    46
{
slouken@11682
    47
#if defined(HAVE_ATANF)
slouken@11682
    48
    return atanf(x);
slouken@11682
    49
#else
slouken@11682
    50
    return (float)SDL_atan((double)x);
slouken@11682
    51
#endif
slouken@7351
    52
}
slouken@7351
    53
slouken@7351
    54
double
slouken@7351
    55
SDL_atan2(double x, double y)
slouken@7351
    56
{
slouken@7351
    57
#if defined(HAVE_ATAN2)
slouken@7351
    58
    return atan2(x, y);
slouken@7351
    59
#else
slouken@7351
    60
    return SDL_uclibc_atan2(x, y);
slouken@11682
    61
#endif
slouken@11682
    62
}
slouken@11682
    63
slouken@11682
    64
float
slouken@11682
    65
SDL_atan2f(float x, float y)
slouken@11682
    66
{
slouken@11682
    67
#if defined(HAVE_ATAN2F)
slouken@11682
    68
    return atan2f(x, y);
slouken@11682
    69
#else
slouken@11682
    70
    return (float)SDL_atan2((double)x, (double)y);
slouken@11682
    71
#endif
slouken@7351
    72
}
slouken@7351
    73
slouken@7351
    74
double
icculus@8056
    75
SDL_acos(double val)
icculus@8056
    76
{
icculus@8056
    77
#if defined(HAVE_ACOS)
icculus@8056
    78
    return acos(val);
icculus@8056
    79
#else
icculus@8056
    80
    double result;
icculus@8056
    81
    if (val == -1.0) {
icculus@8056
    82
        result = M_PI;
icculus@8056
    83
    } else {
icculus@8056
    84
        result = SDL_atan(SDL_sqrt(1.0 - val * val) / val);
icculus@8056
    85
        if (result < 0.0)
icculus@8056
    86
        {
icculus@8056
    87
            result += M_PI;
icculus@8056
    88
        }
icculus@8056
    89
    }
icculus@8056
    90
    return result;
icculus@8056
    91
#endif
icculus@8056
    92
}
icculus@8056
    93
slouken@11682
    94
float
slouken@11682
    95
SDL_acosf(float val)
slouken@11682
    96
{
slouken@11682
    97
#if defined(HAVE_ACOSF)
slouken@11682
    98
    return acosf(val);
slouken@11682
    99
#else
slouken@11682
   100
    return (float)SDL_acos((double)val);
slouken@11682
   101
#endif
slouken@11682
   102
}
slouken@11682
   103
icculus@8056
   104
double
icculus@8056
   105
SDL_asin(double val)
icculus@8056
   106
{
icculus@8056
   107
#if defined(HAVE_ASIN)
icculus@8056
   108
    return asin(val);
icculus@8056
   109
#else
icculus@8056
   110
    double result;
icculus@8056
   111
    if (val == -1.0) {
icculus@8056
   112
        result = -(M_PI / 2.0);
icculus@8056
   113
    } else {
icculus@8056
   114
        result = (M_PI / 2.0) - SDL_acos(val);
icculus@8056
   115
    }
icculus@8056
   116
    return result;
icculus@8056
   117
#endif
icculus@8056
   118
}
icculus@8056
   119
slouken@11682
   120
float
slouken@11682
   121
SDL_asinf(float val)
slouken@11682
   122
{
slouken@11682
   123
#if defined(HAVE_ASINF)
slouken@11682
   124
    return asinf(val);
slouken@11682
   125
#else
slouken@11682
   126
    return (float)SDL_asin((double)val);
slouken@11682
   127
#endif
slouken@11682
   128
}
slouken@11682
   129
icculus@8056
   130
double
slouken@7351
   131
SDL_ceil(double x)
slouken@7351
   132
{
slouken@10505
   133
#if defined(HAVE_CEIL)
slouken@7351
   134
    return ceil(x);
slouken@7351
   135
#else
slouken@8033
   136
    double integer = SDL_floor(x);
slouken@8033
   137
    double fraction = x - integer;
slouken@8033
   138
    if (fraction > 0.0) {
slouken@8033
   139
        integer += 1.0;
slouken@8033
   140
    }
slouken@8033
   141
    return integer;
slouken@7351
   142
#endif /* HAVE_CEIL */
slouken@7351
   143
}
slouken@7351
   144
slouken@11682
   145
float
slouken@11682
   146
SDL_ceilf(float x)
slouken@11682
   147
{
slouken@11682
   148
#if defined(HAVE_CEILF)
slouken@11682
   149
    return ceilf(x);
slouken@11682
   150
#else
slouken@11682
   151
    return (float)ceil((float)x);
slouken@11682
   152
#endif
slouken@11682
   153
}
slouken@11682
   154
slouken@7351
   155
double
slouken@7351
   156
SDL_copysign(double x, double y)
slouken@7351
   157
{
slouken@7351
   158
#if defined(HAVE_COPYSIGN)
slouken@7351
   159
    return copysign(x, y);
dludwig@8478
   160
#elif defined(HAVE__COPYSIGN)
dludwig@8478
   161
    return _copysign(x, y);
slouken@11341
   162
#elif defined(__WATCOMC__) && defined(__386__)
slouken@11341
   163
    /* this is nasty as hell, but it works.. */
slouken@11341
   164
    unsigned int *xi = (unsigned int *) &x,
slouken@11341
   165
                 *yi = (unsigned int *) &y;
slouken@11341
   166
    xi[1] = (yi[1] & 0x80000000) | (xi[1] & 0x7fffffff);
slouken@11341
   167
    return x;
slouken@7351
   168
#else
slouken@7351
   169
    return SDL_uclibc_copysign(x, y);
slouken@7351
   170
#endif /* HAVE_COPYSIGN */
slouken@7351
   171
}
slouken@7351
   172
slouken@11682
   173
float
slouken@11682
   174
SDL_copysignf(float x, float y)
slouken@11682
   175
{
slouken@11682
   176
#if defined(HAVE_COPYSIGNF)
slouken@11682
   177
    return copysignf(x, y);
slouken@11682
   178
#else
slouken@11682
   179
    return (float)SDL_copysign((double)x, (double)y);
slouken@11682
   180
#endif
slouken@11682
   181
}
slouken@11682
   182
slouken@7351
   183
double
slouken@7351
   184
SDL_cos(double x)
slouken@7351
   185
{
slouken@7351
   186
#if defined(HAVE_COS)
slouken@7351
   187
    return cos(x);
slouken@7351
   188
#else
slouken@7351
   189
    return SDL_uclibc_cos(x);
slouken@11682
   190
#endif
slouken@7351
   191
}
slouken@7351
   192
slouken@7351
   193
float
slouken@7351
   194
SDL_cosf(float x)
slouken@7351
   195
{
slouken@10505
   196
#if defined(HAVE_COSF)
slouken@7351
   197
    return cosf(x);
slouken@7351
   198
#else
slouken@7351
   199
    return (float)SDL_cos((double)x);
slouken@7351
   200
#endif
slouken@7351
   201
}
slouken@7351
   202
slouken@7351
   203
double
slouken@7351
   204
SDL_fabs(double x)
slouken@7351
   205
{
slouken@7351
   206
#if defined(HAVE_FABS)
slouken@7351
   207
    return fabs(x); 
slouken@7351
   208
#else
slouken@7351
   209
    return SDL_uclibc_fabs(x);
slouken@11682
   210
#endif
slouken@11682
   211
}
slouken@11682
   212
slouken@11682
   213
float
slouken@11682
   214
SDL_fabsf(float x)
slouken@11682
   215
{
slouken@11682
   216
#if defined(HAVE_FABSF)
slouken@11682
   217
    return fabsf(x); 
slouken@11682
   218
#else
slouken@11682
   219
    return (float)SDL_fabs((double)x);
slouken@11682
   220
#endif
slouken@7351
   221
}
slouken@7351
   222
slouken@7351
   223
double
slouken@7351
   224
SDL_floor(double x)
slouken@7351
   225
{
slouken@7351
   226
#if defined(HAVE_FLOOR)
slouken@7351
   227
    return floor(x);
slouken@7351
   228
#else
slouken@7351
   229
    return SDL_uclibc_floor(x);
slouken@11682
   230
#endif
slouken@11682
   231
}
slouken@11682
   232
slouken@11682
   233
float
slouken@11682
   234
SDL_floorf(float x)
slouken@11682
   235
{
slouken@11682
   236
#if defined(HAVE_FLOORF)
slouken@11682
   237
    return floorf(x);
slouken@11682
   238
#else
slouken@11682
   239
    return (float)SDL_floor((double)x);
slouken@11682
   240
#endif
slouken@7351
   241
}
slouken@7351
   242
slouken@7351
   243
double
slouken@7351
   244
SDL_log(double x)
slouken@7351
   245
{
slouken@7351
   246
#if defined(HAVE_LOG)
slouken@7351
   247
    return log(x);
slouken@7351
   248
#else
slouken@7351
   249
    return SDL_uclibc_log(x);
slouken@11682
   250
#endif
slouken@11682
   251
}
slouken@11682
   252
slouken@11682
   253
float
slouken@11682
   254
SDL_logf(float x)
slouken@11682
   255
{
slouken@11682
   256
#if defined(HAVE_LOGF)
slouken@11682
   257
    return logf(x);
slouken@11682
   258
#else
slouken@11682
   259
    return (float)SDL_log((double)x);
slouken@11682
   260
#endif
slouken@7351
   261
}
slouken@7351
   262
slouken@7351
   263
double
slouken@7351
   264
SDL_pow(double x, double y)
slouken@7351
   265
{
slouken@7351
   266
#if defined(HAVE_POW)
slouken@7351
   267
    return pow(x, y);
slouken@7351
   268
#else
slouken@7351
   269
    return SDL_uclibc_pow(x, y);
slouken@11682
   270
#endif
slouken@11682
   271
}
slouken@11682
   272
slouken@11682
   273
float
slouken@11682
   274
SDL_powf(float x, float y)
slouken@11682
   275
{
slouken@11682
   276
#if defined(HAVE_POWF)
slouken@11682
   277
    return powf(x, y);
slouken@11682
   278
#else
slouken@11682
   279
    return (float)SDL_pow((double)x, (double)y);
slouken@11682
   280
#endif
slouken@7351
   281
}
slouken@7351
   282
slouken@7351
   283
double
slouken@7351
   284
SDL_scalbn(double x, int n)
slouken@7351
   285
{
slouken@7351
   286
#if defined(HAVE_SCALBN)
slouken@7351
   287
    return scalbn(x, n);
dludwig@8478
   288
#elif defined(HAVE__SCALB)
dludwig@8478
   289
    return _scalb(x, n);
icculus@11404
   290
#elif defined(HAVE_LIBC) && defined(HAVE_FLOAT_H) && (FLT_RADIX == 2)
icculus@11404
   291
/* from scalbn(3): If FLT_RADIX equals 2 (which is
icculus@11404
   292
 * usual), then scalbn() is equivalent to ldexp(3). */
icculus@11404
   293
    return ldexp(x, n);
slouken@7351
   294
#else
slouken@7351
   295
    return SDL_uclibc_scalbn(x, n);
slouken@11682
   296
#endif
slouken@11682
   297
}
slouken@11682
   298
slouken@11682
   299
float
slouken@11682
   300
SDL_scalbnf(float x, int n)
slouken@11682
   301
{
slouken@11682
   302
#if defined(HAVE_SCALBNF)
slouken@11682
   303
    return scalbnf(x, n);
slouken@11682
   304
#else
slouken@11682
   305
    return (float)SDL_scalbn((double)x, n);
slouken@11682
   306
#endif
slouken@7351
   307
}
slouken@7351
   308
slouken@7351
   309
double
slouken@7351
   310
SDL_sin(double x)
slouken@7351
   311
{
slouken@7351
   312
#if defined(HAVE_SIN)
slouken@7351
   313
    return sin(x);
slouken@7351
   314
#else
slouken@7351
   315
    return SDL_uclibc_sin(x);
slouken@11682
   316
#endif
slouken@7351
   317
}
slouken@7351
   318
slouken@7351
   319
float 
slouken@7351
   320
SDL_sinf(float x)
slouken@7351
   321
{
slouken@10505
   322
#if defined(HAVE_SINF)
slouken@7351
   323
    return sinf(x);
slouken@7351
   324
#else
slouken@7351
   325
    return (float)SDL_sin((double)x);
slouken@11682
   326
#endif
slouken@7351
   327
}
slouken@7351
   328
slouken@7351
   329
double
slouken@7351
   330
SDL_sqrt(double x)
slouken@7351
   331
{
slouken@7351
   332
#if defined(HAVE_SQRT)
slouken@7351
   333
    return sqrt(x);
slouken@7351
   334
#else
slouken@7351
   335
    return SDL_uclibc_sqrt(x);
slouken@7351
   336
#endif
slouken@7351
   337
}
slouken@7351
   338
slouken@8840
   339
float
slouken@8840
   340
SDL_sqrtf(float x)
slouken@8840
   341
{
slouken@8840
   342
#if defined(HAVE_SQRTF)
slouken@8840
   343
    return sqrtf(x);
slouken@8840
   344
#else
slouken@8840
   345
    return (float)SDL_sqrt((double)x);
slouken@8840
   346
#endif
slouken@8840
   347
}
slouken@8840
   348
slouken@8840
   349
double
slouken@8840
   350
SDL_tan(double x)
slouken@8840
   351
{
slouken@8840
   352
#if defined(HAVE_TAN)
slouken@8840
   353
    return tan(x);
slouken@8840
   354
#else
slouken@8840
   355
    return SDL_uclibc_tan(x);
slouken@8840
   356
#endif
slouken@8840
   357
}
slouken@8840
   358
slouken@8840
   359
float
slouken@8840
   360
SDL_tanf(float x)
slouken@8840
   361
{
slouken@8840
   362
#if defined(HAVE_TANF)
slouken@8840
   363
    return tanf(x);
slouken@8840
   364
#else
slouken@8840
   365
    return (float)SDL_tan((double)x);
slouken@8840
   366
#endif
slouken@8840
   367
}
slouken@8840
   368
slouken@7351
   369
int SDL_abs(int x)
slouken@7351
   370
{
slouken@10505
   371
#if defined(HAVE_ABS)
slouken@7351
   372
    return abs(x);
slouken@7351
   373
#else
slouken@7351
   374
    return ((x) < 0 ? -(x) : (x));
slouken@7351
   375
#endif
slouken@7351
   376
}
slouken@7351
   377
slouken@10505
   378
#if defined(HAVE_CTYPE_H)
slouken@7351
   379
int SDL_isdigit(int x) { return isdigit(x); }
slouken@7351
   380
int SDL_isspace(int x) { return isspace(x); }
slouken@7351
   381
int SDL_toupper(int x) { return toupper(x); }
slouken@7351
   382
int SDL_tolower(int x) { return tolower(x); }
slouken@7351
   383
#else
slouken@7351
   384
int SDL_isdigit(int x) { return ((x) >= '0') && ((x) <= '9'); }
philipp@7357
   385
int SDL_isspace(int x) { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n') || ((x) == '\f') || ((x) == '\v'); }
slouken@7351
   386
int SDL_toupper(int x) { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
slouken@7351
   387
int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); }
slouken@7351
   388
#endif
icculus@7003
   389
icculus@7003
   390
slouken@1330
   391
#ifndef HAVE_LIBC
slouken@1330
   392
/* These are some C runtime intrinsics that need to be defined */
slouken@1330
   393
slouken@3255
   394
#if defined(_MSC_VER)
slouken@1330
   395
slouken@1433
   396
#ifndef __FLTUSED__
slouken@1433
   397
#define __FLTUSED__
slouken@3255
   398
__declspec(selectany) int _fltused = 1;
slouken@1433
   399
#endif
slouken@3255
   400
icculus@9716
   401
/* The optimizer on Visual Studio 2005 and later generates memcpy() calls */
slouken@10550
   402
#if (_MSC_VER >= 1400) && defined(_WIN64) && !defined(_DEBUG) && !(_MSC_VER >= 1900 && defined(_MT))
slouken@5455
   403
#include <intrin.h>
slouken@5455
   404
slouken@5455
   405
#pragma function(memcpy)
slouken@5455
   406
void * memcpy ( void * destination, const void * source, size_t num )
slouken@5455
   407
{
slouken@5455
   408
    const Uint8 *src = (const Uint8 *)source;
slouken@5455
   409
    Uint8 *dst = (Uint8 *)destination;
slouken@5455
   410
    size_t i;
slouken@5455
   411
    
slouken@5455
   412
    /* All WIN64 architectures have SSE, right? */
slouken@5455
   413
    if (!((uintptr_t) src & 15) && !((uintptr_t) dst & 15)) {
slouken@5455
   414
        __m128 values[4];
slouken@5455
   415
        for (i = num / 64; i--;) {
slouken@5455
   416
            _mm_prefetch(src, _MM_HINT_NTA);
slouken@5455
   417
            values[0] = *(__m128 *) (src + 0);
slouken@5455
   418
            values[1] = *(__m128 *) (src + 16);
slouken@5455
   419
            values[2] = *(__m128 *) (src + 32);
slouken@5455
   420
            values[3] = *(__m128 *) (src + 48);
slouken@5455
   421
            _mm_stream_ps((float *) (dst + 0), values[0]);
slouken@5455
   422
            _mm_stream_ps((float *) (dst + 16), values[1]);
slouken@5455
   423
            _mm_stream_ps((float *) (dst + 32), values[2]);
slouken@5455
   424
            _mm_stream_ps((float *) (dst + 48), values[3]);
slouken@5455
   425
            src += 64;
slouken@5455
   426
            dst += 64;
slouken@5455
   427
        }
slouken@5455
   428
        num &= 63;
slouken@5455
   429
    }
slouken@5455
   430
slouken@5455
   431
    while (num--) {
slouken@5455
   432
        *dst++ = *src++;
slouken@5455
   433
    }
slouken@5455
   434
    return destination;
slouken@5455
   435
}
slouken@5455
   436
#endif /* _MSC_VER == 1600 && defined(_WIN64) && !defined(_DEBUG) */
slouken@5455
   437
slouken@5086
   438
#ifdef _M_IX86
slouken@1433
   439
slouken@1346
   440
/* Float to long */
slouken@3253
   441
void
slouken@3253
   442
__declspec(naked)
slouken@3253
   443
_ftol()
slouken@1345
   444
{
slouken@1895
   445
    /* *INDENT-OFF* */
slouken@1895
   446
    __asm {
slouken@1895
   447
        push        ebp
slouken@1895
   448
        mov         ebp,esp
slouken@1895
   449
        sub         esp,20h
slouken@1895
   450
        and         esp,0FFFFFFF0h
slouken@1895
   451
        fld         st(0)
slouken@1895
   452
        fst         dword ptr [esp+18h]
slouken@1895
   453
        fistp       qword ptr [esp+10h]
slouken@1895
   454
        fild        qword ptr [esp+10h]
slouken@1895
   455
        mov         edx,dword ptr [esp+18h]
slouken@1895
   456
        mov         eax,dword ptr [esp+10h]
slouken@1895
   457
        test        eax,eax
slouken@1895
   458
        je          integer_QnaN_or_zero
slouken@1346
   459
arg_is_not_integer_QnaN:
slouken@1895
   460
        fsubp       st(1),st
slouken@1895
   461
        test        edx,edx
slouken@1895
   462
        jns         positive
slouken@1895
   463
        fstp        dword ptr [esp]
slouken@1895
   464
        mov         ecx,dword ptr [esp]
slouken@1895
   465
        xor         ecx,80000000h
slouken@1895
   466
        add         ecx,7FFFFFFFh
slouken@1895
   467
        adc         eax,0
slouken@1895
   468
        mov         edx,dword ptr [esp+14h]
slouken@1895
   469
        adc         edx,0
slouken@1895
   470
        jmp         localexit
slouken@1346
   471
positive:
slouken@1895
   472
        fstp        dword ptr [esp]
slouken@1895
   473
        mov         ecx,dword ptr [esp]
slouken@1895
   474
        add         ecx,7FFFFFFFh
slouken@1895
   475
        sbb         eax,0
slouken@1895
   476
        mov         edx,dword ptr [esp+14h]
slouken@1895
   477
        sbb         edx,0
slouken@1895
   478
        jmp         localexit
slouken@1346
   479
integer_QnaN_or_zero:
slouken@1895
   480
        mov         edx,dword ptr [esp+14h]
slouken@1895
   481
        test        edx,7FFFFFFFh
slouken@1895
   482
        jne         arg_is_not_integer_QnaN
slouken@1895
   483
        fstp        dword ptr [esp+18h]
slouken@1895
   484
        fstp        dword ptr [esp+18h]
slouken@1346
   485
localexit:
slouken@1895
   486
        leave
slouken@1895
   487
        ret
slouken@1895
   488
    }
slouken@1895
   489
    /* *INDENT-ON* */
slouken@1345
   490
}
slouken@1895
   491
slouken@1895
   492
void
slouken@1895
   493
_ftol2_sse()
slouken@1330
   494
{
slouken@1895
   495
    _ftol();
slouken@1330
   496
}
slouken@1330
   497
slouken@10587
   498
/* 64-bit math operators for 32-bit systems */
slouken@10587
   499
void
slouken@10587
   500
__declspec(naked)
slouken@10587
   501
_allmul()
slouken@10587
   502
{
slouken@10587
   503
    /* *INDENT-OFF* */
slouken@10587
   504
    __asm {
slouken@10587
   505
        mov         eax, dword ptr[esp+8]
slouken@10587
   506
        mov         ecx, dword ptr[esp+10h]
slouken@10587
   507
        or          ecx, eax
slouken@10587
   508
        mov         ecx, dword ptr[esp+0Ch]
slouken@10587
   509
        jne         hard
slouken@10587
   510
        mov         eax, dword ptr[esp+4]
slouken@10587
   511
        mul         ecx
slouken@10587
   512
        ret         10h
slouken@10587
   513
hard:
slouken@10587
   514
        push        ebx
slouken@10587
   515
        mul         ecx
slouken@10587
   516
        mov         ebx, eax
slouken@10587
   517
        mov         eax, dword ptr[esp+8]
slouken@10587
   518
        mul         dword ptr[esp+14h]
slouken@10587
   519
        add         ebx, eax
slouken@10587
   520
        mov         eax, dword ptr[esp+8]
slouken@10587
   521
        mul         ecx
slouken@10587
   522
        add         edx, ebx
slouken@10587
   523
        pop         ebx
slouken@10587
   524
        ret         10h
slouken@10587
   525
    }
slouken@10587
   526
    /* *INDENT-ON* */
slouken@1330
   527
}
slouken@2735
   528
slouken@1895
   529
void
slouken@1895
   530
__declspec(naked)
slouken@1895
   531
_alldiv()
slouken@1330
   532
{
slouken@1895
   533
    /* *INDENT-OFF* */
slouken@1895
   534
    __asm {
slouken@1895
   535
        push        edi
slouken@1895
   536
        push        esi
slouken@1895
   537
        push        ebx
slouken@1895
   538
        xor         edi,edi
slouken@1895
   539
        mov         eax,dword ptr [esp+14h]
slouken@1895
   540
        or          eax,eax
slouken@1895
   541
        jge         L1
slouken@1895
   542
        inc         edi
slouken@1895
   543
        mov         edx,dword ptr [esp+10h]
slouken@1895
   544
        neg         eax
slouken@1895
   545
        neg         edx
slouken@1895
   546
        sbb         eax,0
slouken@1895
   547
        mov         dword ptr [esp+14h],eax
slouken@1895
   548
        mov         dword ptr [esp+10h],edx
slouken@1346
   549
L1:
slouken@1895
   550
        mov         eax,dword ptr [esp+1Ch]
slouken@1895
   551
        or          eax,eax
slouken@1895
   552
        jge         L2
slouken@1895
   553
        inc         edi
slouken@1895
   554
        mov         edx,dword ptr [esp+18h]
slouken@1895
   555
        neg         eax
slouken@1895
   556
        neg         edx
slouken@1895
   557
        sbb         eax,0
slouken@1895
   558
        mov         dword ptr [esp+1Ch],eax
slouken@1895
   559
        mov         dword ptr [esp+18h],edx
slouken@1346
   560
L2:
slouken@1895
   561
        or          eax,eax
slouken@1895
   562
        jne         L3
slouken@1895
   563
        mov         ecx,dword ptr [esp+18h]
slouken@1895
   564
        mov         eax,dword ptr [esp+14h]
slouken@1895
   565
        xor         edx,edx
slouken@1895
   566
        div         ecx
slouken@1895
   567
        mov         ebx,eax
slouken@1895
   568
        mov         eax,dword ptr [esp+10h]
slouken@1895
   569
        div         ecx
slouken@1895
   570
        mov         edx,ebx
slouken@1895
   571
        jmp         L4
slouken@1346
   572
L3:
slouken@1895
   573
        mov         ebx,eax
slouken@1895
   574
        mov         ecx,dword ptr [esp+18h]
slouken@1895
   575
        mov         edx,dword ptr [esp+14h]
slouken@1895
   576
        mov         eax,dword ptr [esp+10h]
slouken@1346
   577
L5:
slouken@1895
   578
        shr         ebx,1
slouken@1895
   579
        rcr         ecx,1
slouken@1895
   580
        shr         edx,1
slouken@1895
   581
        rcr         eax,1
slouken@1895
   582
        or          ebx,ebx
slouken@1895
   583
        jne         L5
slouken@1895
   584
        div         ecx
slouken@1895
   585
        mov         esi,eax
slouken@1895
   586
        mul         dword ptr [esp+1Ch]
slouken@1895
   587
        mov         ecx,eax
slouken@1895
   588
        mov         eax,dword ptr [esp+18h]
slouken@1895
   589
        mul         esi
slouken@1895
   590
        add         edx,ecx
slouken@1895
   591
        jb          L6
slouken@1895
   592
        cmp         edx,dword ptr [esp+14h]
slouken@1895
   593
        ja          L6
slouken@1895
   594
        jb          L7
slouken@1895
   595
        cmp         eax,dword ptr [esp+10h]
slouken@1895
   596
        jbe         L7
slouken@1346
   597
L6:
slouken@1895
   598
        dec         esi
slouken@1346
   599
L7:
slouken@1895
   600
        xor         edx,edx
slouken@1895
   601
        mov         eax,esi
slouken@1346
   602
L4:
slouken@1895
   603
        dec         edi
slouken@1895
   604
        jne         L8
slouken@1895
   605
        neg         edx
slouken@1895
   606
        neg         eax
slouken@1895
   607
        sbb         edx,0
slouken@1346
   608
L8:
slouken@1895
   609
        pop         ebx
slouken@1895
   610
        pop         esi
slouken@1895
   611
        pop         edi
slouken@1895
   612
        ret         10h
slouken@1895
   613
    }
slouken@1895
   614
    /* *INDENT-ON* */
slouken@1330
   615
}
slouken@2735
   616
slouken@1895
   617
void
slouken@1895
   618
__declspec(naked)
slouken@1895
   619
_aulldiv()
slouken@1330
   620
{
slouken@1895
   621
    /* *INDENT-OFF* */
slouken@1895
   622
    __asm {
slouken@1895
   623
        push        ebx
slouken@1895
   624
        push        esi
slouken@1895
   625
        mov         eax,dword ptr [esp+18h]
slouken@1895
   626
        or          eax,eax
slouken@1895
   627
        jne         L1
slouken@1895
   628
        mov         ecx,dword ptr [esp+14h]
slouken@1895
   629
        mov         eax,dword ptr [esp+10h]
slouken@1895
   630
        xor         edx,edx
slouken@1895
   631
        div         ecx
slouken@1895
   632
        mov         ebx,eax
slouken@1895
   633
        mov         eax,dword ptr [esp+0Ch]
slouken@1895
   634
        div         ecx
slouken@1895
   635
        mov         edx,ebx
slouken@1895
   636
        jmp         L2
slouken@1346
   637
L1:
slouken@1895
   638
        mov         ecx,eax
slouken@1895
   639
        mov         ebx,dword ptr [esp+14h]
slouken@1895
   640
        mov         edx,dword ptr [esp+10h]
slouken@1895
   641
        mov         eax,dword ptr [esp+0Ch]
slouken@1346
   642
L3:
slouken@1895
   643
        shr         ecx,1
slouken@1895
   644
        rcr         ebx,1
slouken@1895
   645
        shr         edx,1
slouken@1895
   646
        rcr         eax,1
slouken@1895
   647
        or          ecx,ecx
slouken@1895
   648
        jne         L3
slouken@1895
   649
        div         ebx
slouken@1895
   650
        mov         esi,eax
slouken@1895
   651
        mul         dword ptr [esp+18h]
slouken@1895
   652
        mov         ecx,eax
slouken@1895
   653
        mov         eax,dword ptr [esp+14h]
slouken@1895
   654
        mul         esi
slouken@1895
   655
        add         edx,ecx
slouken@1895
   656
        jb          L4
slouken@1895
   657
        cmp         edx,dword ptr [esp+10h]
slouken@1895
   658
        ja          L4
slouken@1895
   659
        jb          L5
slouken@1895
   660
        cmp         eax,dword ptr [esp+0Ch]
slouken@1895
   661
        jbe         L5
slouken@1346
   662
L4:
slouken@1895
   663
        dec         esi
slouken@1346
   664
L5:
slouken@1895
   665
        xor         edx,edx
slouken@1895
   666
        mov         eax,esi
slouken@1346
   667
L2:
slouken@1895
   668
        pop         esi
slouken@1895
   669
        pop         ebx
slouken@1895
   670
        ret         10h
slouken@1895
   671
    }
slouken@1895
   672
    /* *INDENT-ON* */
slouken@1330
   673
}
slouken@2735
   674
slouken@1895
   675
void
slouken@1895
   676
__declspec(naked)
slouken@1895
   677
_allrem()
slouken@1330
   678
{
slouken@1895
   679
    /* *INDENT-OFF* */
slouken@1895
   680
    __asm {
slouken@1895
   681
        push        ebx
slouken@1895
   682
        push        edi
slouken@1895
   683
        xor         edi,edi
slouken@1895
   684
        mov         eax,dword ptr [esp+10h]
slouken@1895
   685
        or          eax,eax
slouken@1895
   686
        jge         L1
slouken@1895
   687
        inc         edi
slouken@1895
   688
        mov         edx,dword ptr [esp+0Ch]
slouken@1895
   689
        neg         eax
slouken@1895
   690
        neg         edx
slouken@1895
   691
        sbb         eax,0
slouken@1895
   692
        mov         dword ptr [esp+10h],eax
slouken@1895
   693
        mov         dword ptr [esp+0Ch],edx
slouken@1346
   694
L1:
slouken@1895
   695
        mov         eax,dword ptr [esp+18h]
slouken@1895
   696
        or          eax,eax
slouken@1895
   697
        jge         L2
slouken@1895
   698
        mov         edx,dword ptr [esp+14h]
slouken@1895
   699
        neg         eax
slouken@1895
   700
        neg         edx
slouken@1895
   701
        sbb         eax,0
slouken@1895
   702
        mov         dword ptr [esp+18h],eax
slouken@1895
   703
        mov         dword ptr [esp+14h],edx
slouken@1346
   704
L2:
slouken@1895
   705
        or          eax,eax
slouken@1895
   706
        jne         L3
slouken@1895
   707
        mov         ecx,dword ptr [esp+14h]
slouken@1895
   708
        mov         eax,dword ptr [esp+10h]
slouken@1895
   709
        xor         edx,edx
slouken@1895
   710
        div         ecx
slouken@1895
   711
        mov         eax,dword ptr [esp+0Ch]
slouken@1895
   712
        div         ecx
slouken@1895
   713
        mov         eax,edx
slouken@1895
   714
        xor         edx,edx
slouken@1895
   715
        dec         edi
slouken@1895
   716
        jns         L4
slouken@1895
   717
        jmp         L8
slouken@1346
   718
L3:
slouken@1895
   719
        mov         ebx,eax
slouken@1895
   720
        mov         ecx,dword ptr [esp+14h]
slouken@1895
   721
        mov         edx,dword ptr [esp+10h]
slouken@1895
   722
        mov         eax,dword ptr [esp+0Ch]
slouken@1346
   723
L5:
slouken@1895
   724
        shr         ebx,1
slouken@1895
   725
        rcr         ecx,1
slouken@1895
   726
        shr         edx,1
slouken@1895
   727
        rcr         eax,1
slouken@1895
   728
        or          ebx,ebx
slouken@1895
   729
        jne         L5
slouken@1895
   730
        div         ecx
slouken@1895
   731
        mov         ecx,eax
slouken@1895
   732
        mul         dword ptr [esp+18h]
slouken@1895
   733
        xchg        eax,ecx
slouken@1895
   734
        mul         dword ptr [esp+14h]
slouken@1895
   735
        add         edx,ecx
slouken@1895
   736
        jb          L6
slouken@1895
   737
        cmp         edx,dword ptr [esp+10h]
slouken@1895
   738
        ja          L6
slouken@1895
   739
        jb          L7
slouken@1895
   740
        cmp         eax,dword ptr [esp+0Ch]
slouken@1895
   741
        jbe         L7
slouken@1346
   742
L6:
slouken@1895
   743
        sub         eax,dword ptr [esp+14h]
slouken@1895
   744
        sbb         edx,dword ptr [esp+18h]
slouken@1346
   745
L7:
slouken@1895
   746
        sub         eax,dword ptr [esp+0Ch]
slouken@1895
   747
        sbb         edx,dword ptr [esp+10h]
slouken@1895
   748
        dec         edi
slouken@1895
   749
        jns         L8
slouken@1346
   750
L4:
slouken@1895
   751
        neg         edx
slouken@1895
   752
        neg         eax
slouken@1895
   753
        sbb         edx,0
slouken@1346
   754
L8:
slouken@1895
   755
        pop         edi
slouken@1895
   756
        pop         ebx
slouken@1895
   757
        ret         10h
slouken@1895
   758
    }
slouken@1895
   759
    /* *INDENT-ON* */
slouken@1330
   760
}
slouken@2735
   761
slouken@1895
   762
void
slouken@1895
   763
__declspec(naked)
slouken@1895
   764
_aullrem()
slouken@1330
   765
{
slouken@1895
   766
    /* *INDENT-OFF* */
slouken@1895
   767
    __asm {
slouken@1895
   768
        push        ebx
slouken@1895
   769
        mov         eax,dword ptr [esp+14h]
slouken@1895
   770
        or          eax,eax
slouken@1895
   771
        jne         L1
slouken@1895
   772
        mov         ecx,dword ptr [esp+10h]
slouken@1895
   773
        mov         eax,dword ptr [esp+0Ch]
slouken@1895
   774
        xor         edx,edx
slouken@1895
   775
        div         ecx
slouken@1895
   776
        mov         eax,dword ptr [esp+8]
slouken@1895
   777
        div         ecx
slouken@1895
   778
        mov         eax,edx
slouken@1895
   779
        xor         edx,edx
slouken@1895
   780
        jmp         L2
slouken@1346
   781
L1:
slouken@1895
   782
        mov         ecx,eax
slouken@1895
   783
        mov         ebx,dword ptr [esp+10h]
slouken@1895
   784
        mov         edx,dword ptr [esp+0Ch]
slouken@1895
   785
        mov         eax,dword ptr [esp+8]
slouken@1346
   786
L3:
slouken@1895
   787
        shr         ecx,1
slouken@1895
   788
        rcr         ebx,1
slouken@1895
   789
        shr         edx,1
slouken@1895
   790
        rcr         eax,1
slouken@1895
   791
        or          ecx,ecx
slouken@1895
   792
        jne         L3
slouken@1895
   793
        div         ebx
slouken@1895
   794
        mov         ecx,eax
slouken@1895
   795
        mul         dword ptr [esp+14h]
slouken@1895
   796
        xchg        eax,ecx
slouken@1895
   797
        mul         dword ptr [esp+10h]
slouken@1895
   798
        add         edx,ecx
slouken@1895
   799
        jb          L4
slouken@1895
   800
        cmp         edx,dword ptr [esp+0Ch]
slouken@1895
   801
        ja          L4
slouken@1895
   802
        jb          L5
slouken@1895
   803
        cmp         eax,dword ptr [esp+8]
slouken@1895
   804
        jbe         L5
slouken@1346
   805
L4:
slouken@1895
   806
        sub         eax,dword ptr [esp+10h]
slouken@1895
   807
        sbb         edx,dword ptr [esp+14h]
slouken@1346
   808
L5:
slouken@1895
   809
        sub         eax,dword ptr [esp+8]
slouken@1895
   810
        sbb         edx,dword ptr [esp+0Ch]
slouken@1895
   811
        neg         edx
slouken@1895
   812
        neg         eax
slouken@1895
   813
        sbb         edx,0
slouken@1346
   814
L2:
slouken@1895
   815
        pop         ebx
slouken@1895
   816
        ret         10h
slouken@1895
   817
    }
slouken@1895
   818
    /* *INDENT-ON* */
slouken@1330
   819
}
slouken@2735
   820
slouken@1895
   821
void
slouken@1895
   822
__declspec(naked)
slouken@1895
   823
_alldvrm()
slouken@1330
   824
{
slouken@1895
   825
    /* *INDENT-OFF* */
slouken@1895
   826
    __asm {
slouken@1895
   827
        push        edi
slouken@1895
   828
        push        esi
slouken@1895
   829
        push        ebp
slouken@1895
   830
        xor         edi,edi
slouken@1895
   831
        xor         ebp,ebp
slouken@1895
   832
        mov         eax,dword ptr [esp+14h]
slouken@1895
   833
        or          eax,eax
slouken@1895
   834
        jge         L1
slouken@1895
   835
        inc         edi
slouken@1895
   836
        inc         ebp
slouken@1895
   837
        mov         edx,dword ptr [esp+10h]
slouken@1895
   838
        neg         eax
slouken@1895
   839
        neg         edx
slouken@1895
   840
        sbb         eax,0
slouken@1895
   841
        mov         dword ptr [esp+14h],eax
slouken@1895
   842
        mov         dword ptr [esp+10h],edx
slouken@1346
   843
L1:
slouken@1895
   844
        mov         eax,dword ptr [esp+1Ch]
slouken@1895
   845
        or          eax,eax
slouken@1895
   846
        jge         L2
slouken@1895
   847
        inc         edi
slouken@1895
   848
        mov         edx,dword ptr [esp+18h]
slouken@1895
   849
        neg         eax
slouken@1895
   850
        neg         edx
slouken@1895
   851
        sbb         eax,0
slouken@1895
   852
        mov         dword ptr [esp+1Ch],eax
slouken@1895
   853
        mov         dword ptr [esp+18h],edx
slouken@1346
   854
L2:
slouken@1895
   855
        or          eax,eax
slouken@1895
   856
        jne         L3
slouken@1895
   857
        mov         ecx,dword ptr [esp+18h]
slouken@1895
   858
        mov         eax,dword ptr [esp+14h]
slouken@1895
   859
        xor         edx,edx
slouken@1895
   860
        div         ecx
slouken@1895
   861
        mov         ebx,eax
slouken@1895
   862
        mov         eax,dword ptr [esp+10h]
slouken@1895
   863
        div         ecx
slouken@1895
   864
        mov         esi,eax
slouken@1895
   865
        mov         eax,ebx
slouken@1895
   866
        mul         dword ptr [esp+18h]
slouken@1895
   867
        mov         ecx,eax
slouken@1895
   868
        mov         eax,esi
slouken@1895
   869
        mul         dword ptr [esp+18h]
slouken@1895
   870
        add         edx,ecx
slouken@1895
   871
        jmp         L4
slouken@1346
   872
L3:
slouken@1895
   873
        mov         ebx,eax
slouken@1895
   874
        mov         ecx,dword ptr [esp+18h]
slouken@1895
   875
        mov         edx,dword ptr [esp+14h]
slouken@1895
   876
        mov         eax,dword ptr [esp+10h]
slouken@1346
   877
L5:
slouken@1895
   878
        shr         ebx,1
slouken@1895
   879
        rcr         ecx,1
slouken@1895
   880
        shr         edx,1
slouken@1895
   881
        rcr         eax,1
slouken@1895
   882
        or          ebx,ebx
slouken@1895
   883
        jne         L5
slouken@1895
   884
        div         ecx
slouken@1895
   885
        mov         esi,eax
slouken@1895
   886
        mul         dword ptr [esp+1Ch]
slouken@1895
   887
        mov         ecx,eax
slouken@1895
   888
        mov         eax,dword ptr [esp+18h]
slouken@1895
   889
        mul         esi
slouken@1895
   890
        add         edx,ecx
slouken@1895
   891
        jb          L6
slouken@1895
   892
        cmp         edx,dword ptr [esp+14h]
slouken@1895
   893
        ja          L6
slouken@1895
   894
        jb          L7
slouken@1895
   895
        cmp         eax,dword ptr [esp+10h]
slouken@1895
   896
        jbe         L7
slouken@1346
   897
L6:
slouken@1895
   898
        dec         esi
slouken@1895
   899
        sub         eax,dword ptr [esp+18h]
slouken@1895
   900
        sbb         edx,dword ptr [esp+1Ch]
slouken@1346
   901
L7:
slouken@1895
   902
        xor         ebx,ebx
slouken@1346
   903
L4:
slouken@1895
   904
        sub         eax,dword ptr [esp+10h]
slouken@1895
   905
        sbb         edx,dword ptr [esp+14h]
slouken@1895
   906
        dec         ebp
slouken@1895
   907
        jns         L9
slouken@1895
   908
        neg         edx
slouken@1895
   909
        neg         eax
slouken@1895
   910
        sbb         edx,0
slouken@1346
   911
L9:
slouken@1895
   912
        mov         ecx,edx
slouken@1895
   913
        mov         edx,ebx
slouken@1895
   914
        mov         ebx,ecx
slouken@1895
   915
        mov         ecx,eax
slouken@1895
   916
        mov         eax,esi
slouken@1895
   917
        dec         edi
slouken@1895
   918
        jne         L8
slouken@1895
   919
        neg         edx
slouken@1895
   920
        neg         eax
slouken@1895
   921
        sbb         edx,0
slouken@1346
   922
L8:
slouken@1895
   923
        pop         ebp
slouken@1895
   924
        pop         esi
slouken@1895
   925
        pop         edi
slouken@1895
   926
        ret         10h
slouken@1895
   927
    }
slouken@1895
   928
    /* *INDENT-ON* */
slouken@1330
   929
}
slouken@2735
   930
slouken@1895
   931
void
slouken@1895
   932
__declspec(naked)
slouken@1895
   933
_aulldvrm()
slouken@1330
   934
{
slouken@1895
   935
    /* *INDENT-OFF* */
slouken@1895
   936
    __asm {
slouken@1895
   937
        push        esi
slouken@1895
   938
        mov         eax,dword ptr [esp+14h]
slouken@1895
   939
        or          eax,eax
slouken@1895
   940
        jne         L1
slouken@1895
   941
        mov         ecx,dword ptr [esp+10h]
slouken@1895
   942
        mov         eax,dword ptr [esp+0Ch]
slouken@1895
   943
        xor         edx,edx
slouken@1895
   944
        div         ecx
slouken@1895
   945
        mov         ebx,eax
slouken@1895
   946
        mov         eax,dword ptr [esp+8]
slouken@1895
   947
        div         ecx
slouken@1895
   948
        mov         esi,eax
slouken@1895
   949
        mov         eax,ebx
slouken@1895
   950
        mul         dword ptr [esp+10h]
slouken@1895
   951
        mov         ecx,eax
slouken@1895
   952
        mov         eax,esi
slouken@1895
   953
        mul         dword ptr [esp+10h]
slouken@1895
   954
        add         edx,ecx
slouken@1895
   955
        jmp         L2
slouken@1346
   956
L1:
slouken@1895
   957
        mov         ecx,eax
slouken@1895
   958
        mov         ebx,dword ptr [esp+10h]
slouken@1895
   959
        mov         edx,dword ptr [esp+0Ch]
slouken@1895
   960
        mov         eax,dword ptr [esp+8]
slouken@1346
   961
L3:
slouken@1895
   962
        shr         ecx,1
slouken@1895
   963
        rcr         ebx,1
slouken@1895
   964
        shr         edx,1
slouken@1895
   965
        rcr         eax,1
slouken@1895
   966
        or          ecx,ecx
slouken@1895
   967
        jne         L3
slouken@1895
   968
        div         ebx
slouken@1895
   969
        mov         esi,eax
slouken@1895
   970
        mul         dword ptr [esp+14h]
slouken@1895
   971
        mov         ecx,eax
slouken@1895
   972
        mov         eax,dword ptr [esp+10h]
slouken@1895
   973
        mul         esi
slouken@1895
   974
        add         edx,ecx
slouken@1895
   975
        jb          L4
slouken@1895
   976
        cmp         edx,dword ptr [esp+0Ch]
slouken@1895
   977
        ja          L4
slouken@1895
   978
        jb          L5
slouken@1895
   979
        cmp         eax,dword ptr [esp+8]
slouken@1895
   980
        jbe         L5
slouken@1346
   981
L4:
slouken@1895
   982
        dec         esi
slouken@1895
   983
        sub         eax,dword ptr [esp+10h]
slouken@1895
   984
        sbb         edx,dword ptr [esp+14h]
slouken@1346
   985
L5:
slouken@1895
   986
        xor         ebx,ebx
slouken@1346
   987
L2:
slouken@1895
   988
        sub         eax,dword ptr [esp+8]
slouken@1895
   989
        sbb         edx,dword ptr [esp+0Ch]
slouken@1895
   990
        neg         edx
slouken@1895
   991
        neg         eax
slouken@1895
   992
        sbb         edx,0
slouken@1895
   993
        mov         ecx,edx
slouken@1895
   994
        mov         edx,ebx
slouken@1895
   995
        mov         ebx,ecx
slouken@1895
   996
        mov         ecx,eax
slouken@1895
   997
        mov         eax,esi
slouken@1895
   998
        pop         esi
slouken@1895
   999
        ret         10h
slouken@1895
  1000
    }
slouken@1895
  1001
    /* *INDENT-ON* */
slouken@1330
  1002
}
slouken@2735
  1003
slouken@1895
  1004
void
slouken@1895
  1005
__declspec(naked)
slouken@1895
  1006
_allshl()
slouken@1330
  1007
{
slouken@1895
  1008
    /* *INDENT-OFF* */
slouken@1895
  1009
    __asm {
slouken@1895
  1010
        cmp         cl,40h
slouken@1895
  1011
        jae         RETZERO
slouken@1895
  1012
        cmp         cl,20h
slouken@1895
  1013
        jae         MORE32
slouken@1895
  1014
        shld        edx,eax,cl
slouken@1895
  1015
        shl         eax,cl
slouken@1895
  1016
        ret
slouken@1346
  1017
MORE32:
slouken@1895
  1018
        mov         edx,eax
slouken@1895
  1019
        xor         eax,eax
slouken@1895
  1020
        and         cl,1Fh
slouken@1895
  1021
        shl         edx,cl
slouken@1895
  1022
        ret
slouken@1346
  1023
RETZERO:
slouken@1895
  1024
        xor         eax,eax
slouken@1895
  1025
        xor         edx,edx
slouken@1895
  1026
        ret
slouken@1895
  1027
    }
slouken@1895
  1028
    /* *INDENT-ON* */
slouken@1330
  1029
}
slouken@2735
  1030
slouken@1895
  1031
void
slouken@1895
  1032
__declspec(naked)
slouken@2760
  1033
_allshr()
slouken@2760
  1034
{
slouken@2760
  1035
    /* *INDENT-OFF* */
slouken@2760
  1036
    __asm {
slouken@10587
  1037
        cmp         cl,3Fh
slouken@10587
  1038
        jae         RETSIGN
slouken@2760
  1039
        cmp         cl,20h
slouken@2760
  1040
        jae         MORE32
slouken@2760
  1041
        shrd        eax,edx,cl
slouken@2760
  1042
        sar         edx,cl
slouken@2760
  1043
        ret
slouken@2760
  1044
MORE32:
slouken@2760
  1045
        mov         eax,edx
slouken@10587
  1046
        sar         edx,1Fh
slouken@2760
  1047
        and         cl,1Fh
slouken@2760
  1048
        sar         eax,cl
slouken@2760
  1049
        ret
slouken@10587
  1050
RETSIGN:
slouken@10587
  1051
        sar         edx,1Fh
slouken@10587
  1052
        mov         eax,edx
slouken@2760
  1053
        ret
slouken@2760
  1054
    }
slouken@2760
  1055
    /* *INDENT-ON* */
slouken@2760
  1056
}
slouken@2760
  1057
slouken@2760
  1058
void
slouken@2760
  1059
__declspec(naked)
slouken@1895
  1060
_aullshr()
slouken@1330
  1061
{
slouken@1895
  1062
    /* *INDENT-OFF* */
slouken@1895
  1063
    __asm {
slouken@1895
  1064
        cmp         cl,40h
slouken@1895
  1065
        jae         RETZERO
slouken@1895
  1066
        cmp         cl,20h
slouken@1895
  1067
        jae         MORE32
slouken@1895
  1068
        shrd        eax,edx,cl
slouken@1895
  1069
        shr         edx,cl
slouken@1895
  1070
        ret
slouken@1346
  1071
MORE32:
slouken@1895
  1072
        mov         eax,edx
slouken@1895
  1073
        xor         edx,edx
slouken@1895
  1074
        and         cl,1Fh
slouken@1895
  1075
        shr         eax,cl
slouken@1895
  1076
        ret
slouken@1346
  1077
RETZERO:
slouken@1895
  1078
        xor         eax,eax
slouken@1895
  1079
        xor         edx,edx
slouken@1895
  1080
        ret
slouken@1895
  1081
    }
slouken@1895
  1082
    /* *INDENT-ON* */
slouken@1330
  1083
}
slouken@1330
  1084
slouken@5455
  1085
#endif /* _M_IX86 */
slouken@3255
  1086
slouken@1330
  1087
#endif /* MSC_VER */
slouken@1330
  1088
slouken@1331
  1089
#endif /* !HAVE_LIBC */
slouken@1895
  1090
slouken@1895
  1091
/* vi: set ts=4 sw=4 expandtab: */