src/stdlib/SDL_stdlib.c
author Ethan Lee <flibitijibibo@flibitijibibo.com>
Wed, 17 Jan 2018 11:53:09 -0500
changeset 11852 c3fc99758ad2
parent 11811 5d94cb6b24d3
child 12072 1e46699fa470
permissions -rw-r--r--
SDL_log10
slouken@1330
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@11811
     3
  Copyright (C) 1997-2018 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@11684
   151
    return (float)SDL_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@11684
   244
SDL_fmod(double x, double y)
slouken@11684
   245
{
slouken@11684
   246
#if defined(HAVE_FMOD)
slouken@11684
   247
    return fmod(x, y);
slouken@11684
   248
#else
slouken@11684
   249
    return SDL_uclibc_fmod(x, y);
slouken@11684
   250
#endif
slouken@11684
   251
}
slouken@11684
   252
slouken@11684
   253
float
slouken@11684
   254
SDL_fmodf(float x, float y)
slouken@11684
   255
{
slouken@11684
   256
#if defined(HAVE_FMODF)
slouken@11684
   257
    return fmodf(x, y);
slouken@11684
   258
#else
slouken@11684
   259
    return (float)SDL_fmod((double)x, (double)y);
slouken@11684
   260
#endif
slouken@11684
   261
}
slouken@11684
   262
slouken@11684
   263
double
slouken@7351
   264
SDL_log(double x)
slouken@7351
   265
{
slouken@7351
   266
#if defined(HAVE_LOG)
slouken@7351
   267
    return log(x);
slouken@7351
   268
#else
slouken@7351
   269
    return SDL_uclibc_log(x);
slouken@11682
   270
#endif
slouken@11682
   271
}
slouken@11682
   272
slouken@11682
   273
float
slouken@11682
   274
SDL_logf(float x)
slouken@11682
   275
{
slouken@11682
   276
#if defined(HAVE_LOGF)
slouken@11682
   277
    return logf(x);
slouken@11682
   278
#else
slouken@11682
   279
    return (float)SDL_log((double)x);
slouken@11682
   280
#endif
slouken@7351
   281
}
slouken@7351
   282
slouken@7351
   283
double
flibitijibibo@11852
   284
SDL_log10(double x)
flibitijibibo@11852
   285
{
flibitijibibo@11852
   286
#if defined(HAVE_LOG10)
flibitijibibo@11852
   287
    return log10(x);
flibitijibibo@11852
   288
#else
flibitijibibo@11852
   289
    return SDL_uclibc_log10(x);
flibitijibibo@11852
   290
#endif
flibitijibibo@11852
   291
}
flibitijibibo@11852
   292
flibitijibibo@11852
   293
float
flibitijibibo@11852
   294
SDL_log10f(float x)
flibitijibibo@11852
   295
{
flibitijibibo@11852
   296
#if defined(HAVE_LOG10F)
flibitijibibo@11852
   297
    return log10f(x);
flibitijibibo@11852
   298
#else
flibitijibibo@11852
   299
    return (float)SDL_log10((double)x);
flibitijibibo@11852
   300
#endif
flibitijibibo@11852
   301
}
flibitijibibo@11852
   302
flibitijibibo@11852
   303
double
slouken@7351
   304
SDL_pow(double x, double y)
slouken@7351
   305
{
slouken@7351
   306
#if defined(HAVE_POW)
slouken@7351
   307
    return pow(x, y);
slouken@7351
   308
#else
slouken@7351
   309
    return SDL_uclibc_pow(x, y);
slouken@11682
   310
#endif
slouken@11682
   311
}
slouken@11682
   312
slouken@11682
   313
float
slouken@11682
   314
SDL_powf(float x, float y)
slouken@11682
   315
{
slouken@11682
   316
#if defined(HAVE_POWF)
slouken@11682
   317
    return powf(x, y);
slouken@11682
   318
#else
slouken@11682
   319
    return (float)SDL_pow((double)x, (double)y);
slouken@11682
   320
#endif
slouken@7351
   321
}
slouken@7351
   322
slouken@7351
   323
double
slouken@7351
   324
SDL_scalbn(double x, int n)
slouken@7351
   325
{
slouken@7351
   326
#if defined(HAVE_SCALBN)
slouken@7351
   327
    return scalbn(x, n);
dludwig@8478
   328
#elif defined(HAVE__SCALB)
dludwig@8478
   329
    return _scalb(x, n);
icculus@11404
   330
#elif defined(HAVE_LIBC) && defined(HAVE_FLOAT_H) && (FLT_RADIX == 2)
icculus@11404
   331
/* from scalbn(3): If FLT_RADIX equals 2 (which is
icculus@11404
   332
 * usual), then scalbn() is equivalent to ldexp(3). */
icculus@11404
   333
    return ldexp(x, n);
slouken@7351
   334
#else
slouken@7351
   335
    return SDL_uclibc_scalbn(x, n);
slouken@11682
   336
#endif
slouken@11682
   337
}
slouken@11682
   338
slouken@11682
   339
float
slouken@11682
   340
SDL_scalbnf(float x, int n)
slouken@11682
   341
{
slouken@11682
   342
#if defined(HAVE_SCALBNF)
slouken@11682
   343
    return scalbnf(x, n);
slouken@11682
   344
#else
slouken@11682
   345
    return (float)SDL_scalbn((double)x, n);
slouken@11682
   346
#endif
slouken@7351
   347
}
slouken@7351
   348
slouken@7351
   349
double
slouken@7351
   350
SDL_sin(double x)
slouken@7351
   351
{
slouken@7351
   352
#if defined(HAVE_SIN)
slouken@7351
   353
    return sin(x);
slouken@7351
   354
#else
slouken@7351
   355
    return SDL_uclibc_sin(x);
slouken@11682
   356
#endif
slouken@7351
   357
}
slouken@7351
   358
slouken@7351
   359
float 
slouken@7351
   360
SDL_sinf(float x)
slouken@7351
   361
{
slouken@10505
   362
#if defined(HAVE_SINF)
slouken@7351
   363
    return sinf(x);
slouken@7351
   364
#else
slouken@7351
   365
    return (float)SDL_sin((double)x);
slouken@11682
   366
#endif
slouken@7351
   367
}
slouken@7351
   368
slouken@7351
   369
double
slouken@7351
   370
SDL_sqrt(double x)
slouken@7351
   371
{
slouken@7351
   372
#if defined(HAVE_SQRT)
slouken@7351
   373
    return sqrt(x);
slouken@7351
   374
#else
slouken@7351
   375
    return SDL_uclibc_sqrt(x);
slouken@7351
   376
#endif
slouken@7351
   377
}
slouken@7351
   378
slouken@8840
   379
float
slouken@8840
   380
SDL_sqrtf(float x)
slouken@8840
   381
{
slouken@8840
   382
#if defined(HAVE_SQRTF)
slouken@8840
   383
    return sqrtf(x);
slouken@8840
   384
#else
slouken@8840
   385
    return (float)SDL_sqrt((double)x);
slouken@8840
   386
#endif
slouken@8840
   387
}
slouken@8840
   388
slouken@8840
   389
double
slouken@8840
   390
SDL_tan(double x)
slouken@8840
   391
{
slouken@8840
   392
#if defined(HAVE_TAN)
slouken@8840
   393
    return tan(x);
slouken@8840
   394
#else
slouken@8840
   395
    return SDL_uclibc_tan(x);
slouken@8840
   396
#endif
slouken@8840
   397
}
slouken@8840
   398
slouken@8840
   399
float
slouken@8840
   400
SDL_tanf(float x)
slouken@8840
   401
{
slouken@8840
   402
#if defined(HAVE_TANF)
slouken@8840
   403
    return tanf(x);
slouken@8840
   404
#else
slouken@8840
   405
    return (float)SDL_tan((double)x);
slouken@8840
   406
#endif
slouken@8840
   407
}
slouken@8840
   408
slouken@7351
   409
int SDL_abs(int x)
slouken@7351
   410
{
slouken@10505
   411
#if defined(HAVE_ABS)
slouken@7351
   412
    return abs(x);
slouken@7351
   413
#else
slouken@7351
   414
    return ((x) < 0 ? -(x) : (x));
slouken@7351
   415
#endif
slouken@7351
   416
}
slouken@7351
   417
slouken@10505
   418
#if defined(HAVE_CTYPE_H)
slouken@7351
   419
int SDL_isdigit(int x) { return isdigit(x); }
slouken@7351
   420
int SDL_isspace(int x) { return isspace(x); }
slouken@7351
   421
int SDL_toupper(int x) { return toupper(x); }
slouken@7351
   422
int SDL_tolower(int x) { return tolower(x); }
slouken@7351
   423
#else
slouken@7351
   424
int SDL_isdigit(int x) { return ((x) >= '0') && ((x) <= '9'); }
philipp@7357
   425
int SDL_isspace(int x) { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n') || ((x) == '\f') || ((x) == '\v'); }
slouken@7351
   426
int SDL_toupper(int x) { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
slouken@7351
   427
int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); }
slouken@7351
   428
#endif
icculus@7003
   429
icculus@7003
   430
slouken@1330
   431
#ifndef HAVE_LIBC
slouken@1330
   432
/* These are some C runtime intrinsics that need to be defined */
slouken@1330
   433
slouken@3255
   434
#if defined(_MSC_VER)
slouken@1330
   435
slouken@1433
   436
#ifndef __FLTUSED__
slouken@1433
   437
#define __FLTUSED__
slouken@3255
   438
__declspec(selectany) int _fltused = 1;
slouken@1433
   439
#endif
slouken@3255
   440
icculus@9716
   441
/* The optimizer on Visual Studio 2005 and later generates memcpy() calls */
slouken@10550
   442
#if (_MSC_VER >= 1400) && defined(_WIN64) && !defined(_DEBUG) && !(_MSC_VER >= 1900 && defined(_MT))
slouken@5455
   443
#include <intrin.h>
slouken@5455
   444
slouken@5455
   445
#pragma function(memcpy)
slouken@5455
   446
void * memcpy ( void * destination, const void * source, size_t num )
slouken@5455
   447
{
slouken@5455
   448
    const Uint8 *src = (const Uint8 *)source;
slouken@5455
   449
    Uint8 *dst = (Uint8 *)destination;
slouken@5455
   450
    size_t i;
slouken@5455
   451
    
slouken@5455
   452
    /* All WIN64 architectures have SSE, right? */
slouken@5455
   453
    if (!((uintptr_t) src & 15) && !((uintptr_t) dst & 15)) {
slouken@5455
   454
        __m128 values[4];
slouken@5455
   455
        for (i = num / 64; i--;) {
slouken@5455
   456
            _mm_prefetch(src, _MM_HINT_NTA);
slouken@5455
   457
            values[0] = *(__m128 *) (src + 0);
slouken@5455
   458
            values[1] = *(__m128 *) (src + 16);
slouken@5455
   459
            values[2] = *(__m128 *) (src + 32);
slouken@5455
   460
            values[3] = *(__m128 *) (src + 48);
slouken@5455
   461
            _mm_stream_ps((float *) (dst + 0), values[0]);
slouken@5455
   462
            _mm_stream_ps((float *) (dst + 16), values[1]);
slouken@5455
   463
            _mm_stream_ps((float *) (dst + 32), values[2]);
slouken@5455
   464
            _mm_stream_ps((float *) (dst + 48), values[3]);
slouken@5455
   465
            src += 64;
slouken@5455
   466
            dst += 64;
slouken@5455
   467
        }
slouken@5455
   468
        num &= 63;
slouken@5455
   469
    }
slouken@5455
   470
slouken@5455
   471
    while (num--) {
slouken@5455
   472
        *dst++ = *src++;
slouken@5455
   473
    }
slouken@5455
   474
    return destination;
slouken@5455
   475
}
slouken@5455
   476
#endif /* _MSC_VER == 1600 && defined(_WIN64) && !defined(_DEBUG) */
slouken@5455
   477
slouken@5086
   478
#ifdef _M_IX86
slouken@1433
   479
slouken@1346
   480
/* Float to long */
slouken@3253
   481
void
slouken@3253
   482
__declspec(naked)
slouken@3253
   483
_ftol()
slouken@1345
   484
{
slouken@1895
   485
    /* *INDENT-OFF* */
slouken@1895
   486
    __asm {
slouken@1895
   487
        push        ebp
slouken@1895
   488
        mov         ebp,esp
slouken@1895
   489
        sub         esp,20h
slouken@1895
   490
        and         esp,0FFFFFFF0h
slouken@1895
   491
        fld         st(0)
slouken@1895
   492
        fst         dword ptr [esp+18h]
slouken@1895
   493
        fistp       qword ptr [esp+10h]
slouken@1895
   494
        fild        qword ptr [esp+10h]
slouken@1895
   495
        mov         edx,dword ptr [esp+18h]
slouken@1895
   496
        mov         eax,dword ptr [esp+10h]
slouken@1895
   497
        test        eax,eax
slouken@1895
   498
        je          integer_QnaN_or_zero
slouken@1346
   499
arg_is_not_integer_QnaN:
slouken@1895
   500
        fsubp       st(1),st
slouken@1895
   501
        test        edx,edx
slouken@1895
   502
        jns         positive
slouken@1895
   503
        fstp        dword ptr [esp]
slouken@1895
   504
        mov         ecx,dword ptr [esp]
slouken@1895
   505
        xor         ecx,80000000h
slouken@1895
   506
        add         ecx,7FFFFFFFh
slouken@1895
   507
        adc         eax,0
slouken@1895
   508
        mov         edx,dword ptr [esp+14h]
slouken@1895
   509
        adc         edx,0
slouken@1895
   510
        jmp         localexit
slouken@1346
   511
positive:
slouken@1895
   512
        fstp        dword ptr [esp]
slouken@1895
   513
        mov         ecx,dword ptr [esp]
slouken@1895
   514
        add         ecx,7FFFFFFFh
slouken@1895
   515
        sbb         eax,0
slouken@1895
   516
        mov         edx,dword ptr [esp+14h]
slouken@1895
   517
        sbb         edx,0
slouken@1895
   518
        jmp         localexit
slouken@1346
   519
integer_QnaN_or_zero:
slouken@1895
   520
        mov         edx,dword ptr [esp+14h]
slouken@1895
   521
        test        edx,7FFFFFFFh
slouken@1895
   522
        jne         arg_is_not_integer_QnaN
slouken@1895
   523
        fstp        dword ptr [esp+18h]
slouken@1895
   524
        fstp        dword ptr [esp+18h]
slouken@1346
   525
localexit:
slouken@1895
   526
        leave
slouken@1895
   527
        ret
slouken@1895
   528
    }
slouken@1895
   529
    /* *INDENT-ON* */
slouken@1345
   530
}
slouken@1895
   531
slouken@1895
   532
void
slouken@1895
   533
_ftol2_sse()
slouken@1330
   534
{
slouken@1895
   535
    _ftol();
slouken@1330
   536
}
slouken@1330
   537
slouken@10587
   538
/* 64-bit math operators for 32-bit systems */
slouken@10587
   539
void
slouken@10587
   540
__declspec(naked)
slouken@10587
   541
_allmul()
slouken@10587
   542
{
slouken@10587
   543
    /* *INDENT-OFF* */
slouken@10587
   544
    __asm {
slouken@10587
   545
        mov         eax, dword ptr[esp+8]
slouken@10587
   546
        mov         ecx, dword ptr[esp+10h]
slouken@10587
   547
        or          ecx, eax
slouken@10587
   548
        mov         ecx, dword ptr[esp+0Ch]
slouken@10587
   549
        jne         hard
slouken@10587
   550
        mov         eax, dword ptr[esp+4]
slouken@10587
   551
        mul         ecx
slouken@10587
   552
        ret         10h
slouken@10587
   553
hard:
slouken@10587
   554
        push        ebx
slouken@10587
   555
        mul         ecx
slouken@10587
   556
        mov         ebx, eax
slouken@10587
   557
        mov         eax, dword ptr[esp+8]
slouken@10587
   558
        mul         dword ptr[esp+14h]
slouken@10587
   559
        add         ebx, eax
slouken@10587
   560
        mov         eax, dword ptr[esp+8]
slouken@10587
   561
        mul         ecx
slouken@10587
   562
        add         edx, ebx
slouken@10587
   563
        pop         ebx
slouken@10587
   564
        ret         10h
slouken@10587
   565
    }
slouken@10587
   566
    /* *INDENT-ON* */
slouken@1330
   567
}
slouken@2735
   568
slouken@1895
   569
void
slouken@1895
   570
__declspec(naked)
slouken@1895
   571
_alldiv()
slouken@1330
   572
{
slouken@1895
   573
    /* *INDENT-OFF* */
slouken@1895
   574
    __asm {
slouken@1895
   575
        push        edi
slouken@1895
   576
        push        esi
slouken@1895
   577
        push        ebx
slouken@1895
   578
        xor         edi,edi
slouken@1895
   579
        mov         eax,dword ptr [esp+14h]
slouken@1895
   580
        or          eax,eax
slouken@1895
   581
        jge         L1
slouken@1895
   582
        inc         edi
slouken@1895
   583
        mov         edx,dword ptr [esp+10h]
slouken@1895
   584
        neg         eax
slouken@1895
   585
        neg         edx
slouken@1895
   586
        sbb         eax,0
slouken@1895
   587
        mov         dword ptr [esp+14h],eax
slouken@1895
   588
        mov         dword ptr [esp+10h],edx
slouken@1346
   589
L1:
slouken@1895
   590
        mov         eax,dword ptr [esp+1Ch]
slouken@1895
   591
        or          eax,eax
slouken@1895
   592
        jge         L2
slouken@1895
   593
        inc         edi
slouken@1895
   594
        mov         edx,dword ptr [esp+18h]
slouken@1895
   595
        neg         eax
slouken@1895
   596
        neg         edx
slouken@1895
   597
        sbb         eax,0
slouken@1895
   598
        mov         dword ptr [esp+1Ch],eax
slouken@1895
   599
        mov         dword ptr [esp+18h],edx
slouken@1346
   600
L2:
slouken@1895
   601
        or          eax,eax
slouken@1895
   602
        jne         L3
slouken@1895
   603
        mov         ecx,dword ptr [esp+18h]
slouken@1895
   604
        mov         eax,dword ptr [esp+14h]
slouken@1895
   605
        xor         edx,edx
slouken@1895
   606
        div         ecx
slouken@1895
   607
        mov         ebx,eax
slouken@1895
   608
        mov         eax,dword ptr [esp+10h]
slouken@1895
   609
        div         ecx
slouken@1895
   610
        mov         edx,ebx
slouken@1895
   611
        jmp         L4
slouken@1346
   612
L3:
slouken@1895
   613
        mov         ebx,eax
slouken@1895
   614
        mov         ecx,dword ptr [esp+18h]
slouken@1895
   615
        mov         edx,dword ptr [esp+14h]
slouken@1895
   616
        mov         eax,dword ptr [esp+10h]
slouken@1346
   617
L5:
slouken@1895
   618
        shr         ebx,1
slouken@1895
   619
        rcr         ecx,1
slouken@1895
   620
        shr         edx,1
slouken@1895
   621
        rcr         eax,1
slouken@1895
   622
        or          ebx,ebx
slouken@1895
   623
        jne         L5
slouken@1895
   624
        div         ecx
slouken@1895
   625
        mov         esi,eax
slouken@1895
   626
        mul         dword ptr [esp+1Ch]
slouken@1895
   627
        mov         ecx,eax
slouken@1895
   628
        mov         eax,dword ptr [esp+18h]
slouken@1895
   629
        mul         esi
slouken@1895
   630
        add         edx,ecx
slouken@1895
   631
        jb          L6
slouken@1895
   632
        cmp         edx,dword ptr [esp+14h]
slouken@1895
   633
        ja          L6
slouken@1895
   634
        jb          L7
slouken@1895
   635
        cmp         eax,dword ptr [esp+10h]
slouken@1895
   636
        jbe         L7
slouken@1346
   637
L6:
slouken@1895
   638
        dec         esi
slouken@1346
   639
L7:
slouken@1895
   640
        xor         edx,edx
slouken@1895
   641
        mov         eax,esi
slouken@1346
   642
L4:
slouken@1895
   643
        dec         edi
slouken@1895
   644
        jne         L8
slouken@1895
   645
        neg         edx
slouken@1895
   646
        neg         eax
slouken@1895
   647
        sbb         edx,0
slouken@1346
   648
L8:
slouken@1895
   649
        pop         ebx
slouken@1895
   650
        pop         esi
slouken@1895
   651
        pop         edi
slouken@1895
   652
        ret         10h
slouken@1895
   653
    }
slouken@1895
   654
    /* *INDENT-ON* */
slouken@1330
   655
}
slouken@2735
   656
slouken@1895
   657
void
slouken@1895
   658
__declspec(naked)
slouken@1895
   659
_aulldiv()
slouken@1330
   660
{
slouken@1895
   661
    /* *INDENT-OFF* */
slouken@1895
   662
    __asm {
slouken@1895
   663
        push        ebx
slouken@1895
   664
        push        esi
slouken@1895
   665
        mov         eax,dword ptr [esp+18h]
slouken@1895
   666
        or          eax,eax
slouken@1895
   667
        jne         L1
slouken@1895
   668
        mov         ecx,dword ptr [esp+14h]
slouken@1895
   669
        mov         eax,dword ptr [esp+10h]
slouken@1895
   670
        xor         edx,edx
slouken@1895
   671
        div         ecx
slouken@1895
   672
        mov         ebx,eax
slouken@1895
   673
        mov         eax,dword ptr [esp+0Ch]
slouken@1895
   674
        div         ecx
slouken@1895
   675
        mov         edx,ebx
slouken@1895
   676
        jmp         L2
slouken@1346
   677
L1:
slouken@1895
   678
        mov         ecx,eax
slouken@1895
   679
        mov         ebx,dword ptr [esp+14h]
slouken@1895
   680
        mov         edx,dword ptr [esp+10h]
slouken@1895
   681
        mov         eax,dword ptr [esp+0Ch]
slouken@1346
   682
L3:
slouken@1895
   683
        shr         ecx,1
slouken@1895
   684
        rcr         ebx,1
slouken@1895
   685
        shr         edx,1
slouken@1895
   686
        rcr         eax,1
slouken@1895
   687
        or          ecx,ecx
slouken@1895
   688
        jne         L3
slouken@1895
   689
        div         ebx
slouken@1895
   690
        mov         esi,eax
slouken@1895
   691
        mul         dword ptr [esp+18h]
slouken@1895
   692
        mov         ecx,eax
slouken@1895
   693
        mov         eax,dword ptr [esp+14h]
slouken@1895
   694
        mul         esi
slouken@1895
   695
        add         edx,ecx
slouken@1895
   696
        jb          L4
slouken@1895
   697
        cmp         edx,dword ptr [esp+10h]
slouken@1895
   698
        ja          L4
slouken@1895
   699
        jb          L5
slouken@1895
   700
        cmp         eax,dword ptr [esp+0Ch]
slouken@1895
   701
        jbe         L5
slouken@1346
   702
L4:
slouken@1895
   703
        dec         esi
slouken@1346
   704
L5:
slouken@1895
   705
        xor         edx,edx
slouken@1895
   706
        mov         eax,esi
slouken@1346
   707
L2:
slouken@1895
   708
        pop         esi
slouken@1895
   709
        pop         ebx
slouken@1895
   710
        ret         10h
slouken@1895
   711
    }
slouken@1895
   712
    /* *INDENT-ON* */
slouken@1330
   713
}
slouken@2735
   714
slouken@1895
   715
void
slouken@1895
   716
__declspec(naked)
slouken@1895
   717
_allrem()
slouken@1330
   718
{
slouken@1895
   719
    /* *INDENT-OFF* */
slouken@1895
   720
    __asm {
slouken@1895
   721
        push        ebx
slouken@1895
   722
        push        edi
slouken@1895
   723
        xor         edi,edi
slouken@1895
   724
        mov         eax,dword ptr [esp+10h]
slouken@1895
   725
        or          eax,eax
slouken@1895
   726
        jge         L1
slouken@1895
   727
        inc         edi
slouken@1895
   728
        mov         edx,dword ptr [esp+0Ch]
slouken@1895
   729
        neg         eax
slouken@1895
   730
        neg         edx
slouken@1895
   731
        sbb         eax,0
slouken@1895
   732
        mov         dword ptr [esp+10h],eax
slouken@1895
   733
        mov         dword ptr [esp+0Ch],edx
slouken@1346
   734
L1:
slouken@1895
   735
        mov         eax,dword ptr [esp+18h]
slouken@1895
   736
        or          eax,eax
slouken@1895
   737
        jge         L2
slouken@1895
   738
        mov         edx,dword ptr [esp+14h]
slouken@1895
   739
        neg         eax
slouken@1895
   740
        neg         edx
slouken@1895
   741
        sbb         eax,0
slouken@1895
   742
        mov         dword ptr [esp+18h],eax
slouken@1895
   743
        mov         dword ptr [esp+14h],edx
slouken@1346
   744
L2:
slouken@1895
   745
        or          eax,eax
slouken@1895
   746
        jne         L3
slouken@1895
   747
        mov         ecx,dword ptr [esp+14h]
slouken@1895
   748
        mov         eax,dword ptr [esp+10h]
slouken@1895
   749
        xor         edx,edx
slouken@1895
   750
        div         ecx
slouken@1895
   751
        mov         eax,dword ptr [esp+0Ch]
slouken@1895
   752
        div         ecx
slouken@1895
   753
        mov         eax,edx
slouken@1895
   754
        xor         edx,edx
slouken@1895
   755
        dec         edi
slouken@1895
   756
        jns         L4
slouken@1895
   757
        jmp         L8
slouken@1346
   758
L3:
slouken@1895
   759
        mov         ebx,eax
slouken@1895
   760
        mov         ecx,dword ptr [esp+14h]
slouken@1895
   761
        mov         edx,dword ptr [esp+10h]
slouken@1895
   762
        mov         eax,dword ptr [esp+0Ch]
slouken@1346
   763
L5:
slouken@1895
   764
        shr         ebx,1
slouken@1895
   765
        rcr         ecx,1
slouken@1895
   766
        shr         edx,1
slouken@1895
   767
        rcr         eax,1
slouken@1895
   768
        or          ebx,ebx
slouken@1895
   769
        jne         L5
slouken@1895
   770
        div         ecx
slouken@1895
   771
        mov         ecx,eax
slouken@1895
   772
        mul         dword ptr [esp+18h]
slouken@1895
   773
        xchg        eax,ecx
slouken@1895
   774
        mul         dword ptr [esp+14h]
slouken@1895
   775
        add         edx,ecx
slouken@1895
   776
        jb          L6
slouken@1895
   777
        cmp         edx,dword ptr [esp+10h]
slouken@1895
   778
        ja          L6
slouken@1895
   779
        jb          L7
slouken@1895
   780
        cmp         eax,dword ptr [esp+0Ch]
slouken@1895
   781
        jbe         L7
slouken@1346
   782
L6:
slouken@1895
   783
        sub         eax,dword ptr [esp+14h]
slouken@1895
   784
        sbb         edx,dword ptr [esp+18h]
slouken@1346
   785
L7:
slouken@1895
   786
        sub         eax,dword ptr [esp+0Ch]
slouken@1895
   787
        sbb         edx,dword ptr [esp+10h]
slouken@1895
   788
        dec         edi
slouken@1895
   789
        jns         L8
slouken@1346
   790
L4:
slouken@1895
   791
        neg         edx
slouken@1895
   792
        neg         eax
slouken@1895
   793
        sbb         edx,0
slouken@1346
   794
L8:
slouken@1895
   795
        pop         edi
slouken@1895
   796
        pop         ebx
slouken@1895
   797
        ret         10h
slouken@1895
   798
    }
slouken@1895
   799
    /* *INDENT-ON* */
slouken@1330
   800
}
slouken@2735
   801
slouken@1895
   802
void
slouken@1895
   803
__declspec(naked)
slouken@1895
   804
_aullrem()
slouken@1330
   805
{
slouken@1895
   806
    /* *INDENT-OFF* */
slouken@1895
   807
    __asm {
slouken@1895
   808
        push        ebx
slouken@1895
   809
        mov         eax,dword ptr [esp+14h]
slouken@1895
   810
        or          eax,eax
slouken@1895
   811
        jne         L1
slouken@1895
   812
        mov         ecx,dword ptr [esp+10h]
slouken@1895
   813
        mov         eax,dword ptr [esp+0Ch]
slouken@1895
   814
        xor         edx,edx
slouken@1895
   815
        div         ecx
slouken@1895
   816
        mov         eax,dword ptr [esp+8]
slouken@1895
   817
        div         ecx
slouken@1895
   818
        mov         eax,edx
slouken@1895
   819
        xor         edx,edx
slouken@1895
   820
        jmp         L2
slouken@1346
   821
L1:
slouken@1895
   822
        mov         ecx,eax
slouken@1895
   823
        mov         ebx,dword ptr [esp+10h]
slouken@1895
   824
        mov         edx,dword ptr [esp+0Ch]
slouken@1895
   825
        mov         eax,dword ptr [esp+8]
slouken@1346
   826
L3:
slouken@1895
   827
        shr         ecx,1
slouken@1895
   828
        rcr         ebx,1
slouken@1895
   829
        shr         edx,1
slouken@1895
   830
        rcr         eax,1
slouken@1895
   831
        or          ecx,ecx
slouken@1895
   832
        jne         L3
slouken@1895
   833
        div         ebx
slouken@1895
   834
        mov         ecx,eax
slouken@1895
   835
        mul         dword ptr [esp+14h]
slouken@1895
   836
        xchg        eax,ecx
slouken@1895
   837
        mul         dword ptr [esp+10h]
slouken@1895
   838
        add         edx,ecx
slouken@1895
   839
        jb          L4
slouken@1895
   840
        cmp         edx,dword ptr [esp+0Ch]
slouken@1895
   841
        ja          L4
slouken@1895
   842
        jb          L5
slouken@1895
   843
        cmp         eax,dword ptr [esp+8]
slouken@1895
   844
        jbe         L5
slouken@1346
   845
L4:
slouken@1895
   846
        sub         eax,dword ptr [esp+10h]
slouken@1895
   847
        sbb         edx,dword ptr [esp+14h]
slouken@1346
   848
L5:
slouken@1895
   849
        sub         eax,dword ptr [esp+8]
slouken@1895
   850
        sbb         edx,dword ptr [esp+0Ch]
slouken@1895
   851
        neg         edx
slouken@1895
   852
        neg         eax
slouken@1895
   853
        sbb         edx,0
slouken@1346
   854
L2:
slouken@1895
   855
        pop         ebx
slouken@1895
   856
        ret         10h
slouken@1895
   857
    }
slouken@1895
   858
    /* *INDENT-ON* */
slouken@1330
   859
}
slouken@2735
   860
slouken@1895
   861
void
slouken@1895
   862
__declspec(naked)
slouken@1895
   863
_alldvrm()
slouken@1330
   864
{
slouken@1895
   865
    /* *INDENT-OFF* */
slouken@1895
   866
    __asm {
slouken@1895
   867
        push        edi
slouken@1895
   868
        push        esi
slouken@1895
   869
        push        ebp
slouken@1895
   870
        xor         edi,edi
slouken@1895
   871
        xor         ebp,ebp
slouken@1895
   872
        mov         eax,dword ptr [esp+14h]
slouken@1895
   873
        or          eax,eax
slouken@1895
   874
        jge         L1
slouken@1895
   875
        inc         edi
slouken@1895
   876
        inc         ebp
slouken@1895
   877
        mov         edx,dword ptr [esp+10h]
slouken@1895
   878
        neg         eax
slouken@1895
   879
        neg         edx
slouken@1895
   880
        sbb         eax,0
slouken@1895
   881
        mov         dword ptr [esp+14h],eax
slouken@1895
   882
        mov         dword ptr [esp+10h],edx
slouken@1346
   883
L1:
slouken@1895
   884
        mov         eax,dword ptr [esp+1Ch]
slouken@1895
   885
        or          eax,eax
slouken@1895
   886
        jge         L2
slouken@1895
   887
        inc         edi
slouken@1895
   888
        mov         edx,dword ptr [esp+18h]
slouken@1895
   889
        neg         eax
slouken@1895
   890
        neg         edx
slouken@1895
   891
        sbb         eax,0
slouken@1895
   892
        mov         dword ptr [esp+1Ch],eax
slouken@1895
   893
        mov         dword ptr [esp+18h],edx
slouken@1346
   894
L2:
slouken@1895
   895
        or          eax,eax
slouken@1895
   896
        jne         L3
slouken@1895
   897
        mov         ecx,dword ptr [esp+18h]
slouken@1895
   898
        mov         eax,dword ptr [esp+14h]
slouken@1895
   899
        xor         edx,edx
slouken@1895
   900
        div         ecx
slouken@1895
   901
        mov         ebx,eax
slouken@1895
   902
        mov         eax,dword ptr [esp+10h]
slouken@1895
   903
        div         ecx
slouken@1895
   904
        mov         esi,eax
slouken@1895
   905
        mov         eax,ebx
slouken@1895
   906
        mul         dword ptr [esp+18h]
slouken@1895
   907
        mov         ecx,eax
slouken@1895
   908
        mov         eax,esi
slouken@1895
   909
        mul         dword ptr [esp+18h]
slouken@1895
   910
        add         edx,ecx
slouken@1895
   911
        jmp         L4
slouken@1346
   912
L3:
slouken@1895
   913
        mov         ebx,eax
slouken@1895
   914
        mov         ecx,dword ptr [esp+18h]
slouken@1895
   915
        mov         edx,dword ptr [esp+14h]
slouken@1895
   916
        mov         eax,dword ptr [esp+10h]
slouken@1346
   917
L5:
slouken@1895
   918
        shr         ebx,1
slouken@1895
   919
        rcr         ecx,1
slouken@1895
   920
        shr         edx,1
slouken@1895
   921
        rcr         eax,1
slouken@1895
   922
        or          ebx,ebx
slouken@1895
   923
        jne         L5
slouken@1895
   924
        div         ecx
slouken@1895
   925
        mov         esi,eax
slouken@1895
   926
        mul         dword ptr [esp+1Ch]
slouken@1895
   927
        mov         ecx,eax
slouken@1895
   928
        mov         eax,dword ptr [esp+18h]
slouken@1895
   929
        mul         esi
slouken@1895
   930
        add         edx,ecx
slouken@1895
   931
        jb          L6
slouken@1895
   932
        cmp         edx,dword ptr [esp+14h]
slouken@1895
   933
        ja          L6
slouken@1895
   934
        jb          L7
slouken@1895
   935
        cmp         eax,dword ptr [esp+10h]
slouken@1895
   936
        jbe         L7
slouken@1346
   937
L6:
slouken@1895
   938
        dec         esi
slouken@1895
   939
        sub         eax,dword ptr [esp+18h]
slouken@1895
   940
        sbb         edx,dword ptr [esp+1Ch]
slouken@1346
   941
L7:
slouken@1895
   942
        xor         ebx,ebx
slouken@1346
   943
L4:
slouken@1895
   944
        sub         eax,dword ptr [esp+10h]
slouken@1895
   945
        sbb         edx,dword ptr [esp+14h]
slouken@1895
   946
        dec         ebp
slouken@1895
   947
        jns         L9
slouken@1895
   948
        neg         edx
slouken@1895
   949
        neg         eax
slouken@1895
   950
        sbb         edx,0
slouken@1346
   951
L9:
slouken@1895
   952
        mov         ecx,edx
slouken@1895
   953
        mov         edx,ebx
slouken@1895
   954
        mov         ebx,ecx
slouken@1895
   955
        mov         ecx,eax
slouken@1895
   956
        mov         eax,esi
slouken@1895
   957
        dec         edi
slouken@1895
   958
        jne         L8
slouken@1895
   959
        neg         edx
slouken@1895
   960
        neg         eax
slouken@1895
   961
        sbb         edx,0
slouken@1346
   962
L8:
slouken@1895
   963
        pop         ebp
slouken@1895
   964
        pop         esi
slouken@1895
   965
        pop         edi
slouken@1895
   966
        ret         10h
slouken@1895
   967
    }
slouken@1895
   968
    /* *INDENT-ON* */
slouken@1330
   969
}
slouken@2735
   970
slouken@1895
   971
void
slouken@1895
   972
__declspec(naked)
slouken@1895
   973
_aulldvrm()
slouken@1330
   974
{
slouken@1895
   975
    /* *INDENT-OFF* */
slouken@1895
   976
    __asm {
slouken@1895
   977
        push        esi
slouken@1895
   978
        mov         eax,dword ptr [esp+14h]
slouken@1895
   979
        or          eax,eax
slouken@1895
   980
        jne         L1
slouken@1895
   981
        mov         ecx,dword ptr [esp+10h]
slouken@1895
   982
        mov         eax,dword ptr [esp+0Ch]
slouken@1895
   983
        xor         edx,edx
slouken@1895
   984
        div         ecx
slouken@1895
   985
        mov         ebx,eax
slouken@1895
   986
        mov         eax,dword ptr [esp+8]
slouken@1895
   987
        div         ecx
slouken@1895
   988
        mov         esi,eax
slouken@1895
   989
        mov         eax,ebx
slouken@1895
   990
        mul         dword ptr [esp+10h]
slouken@1895
   991
        mov         ecx,eax
slouken@1895
   992
        mov         eax,esi
slouken@1895
   993
        mul         dword ptr [esp+10h]
slouken@1895
   994
        add         edx,ecx
slouken@1895
   995
        jmp         L2
slouken@1346
   996
L1:
slouken@1895
   997
        mov         ecx,eax
slouken@1895
   998
        mov         ebx,dword ptr [esp+10h]
slouken@1895
   999
        mov         edx,dword ptr [esp+0Ch]
slouken@1895
  1000
        mov         eax,dword ptr [esp+8]
slouken@1346
  1001
L3:
slouken@1895
  1002
        shr         ecx,1
slouken@1895
  1003
        rcr         ebx,1
slouken@1895
  1004
        shr         edx,1
slouken@1895
  1005
        rcr         eax,1
slouken@1895
  1006
        or          ecx,ecx
slouken@1895
  1007
        jne         L3
slouken@1895
  1008
        div         ebx
slouken@1895
  1009
        mov         esi,eax
slouken@1895
  1010
        mul         dword ptr [esp+14h]
slouken@1895
  1011
        mov         ecx,eax
slouken@1895
  1012
        mov         eax,dword ptr [esp+10h]
slouken@1895
  1013
        mul         esi
slouken@1895
  1014
        add         edx,ecx
slouken@1895
  1015
        jb          L4
slouken@1895
  1016
        cmp         edx,dword ptr [esp+0Ch]
slouken@1895
  1017
        ja          L4
slouken@1895
  1018
        jb          L5
slouken@1895
  1019
        cmp         eax,dword ptr [esp+8]
slouken@1895
  1020
        jbe         L5
slouken@1346
  1021
L4:
slouken@1895
  1022
        dec         esi
slouken@1895
  1023
        sub         eax,dword ptr [esp+10h]
slouken@1895
  1024
        sbb         edx,dword ptr [esp+14h]
slouken@1346
  1025
L5:
slouken@1895
  1026
        xor         ebx,ebx
slouken@1346
  1027
L2:
slouken@1895
  1028
        sub         eax,dword ptr [esp+8]
slouken@1895
  1029
        sbb         edx,dword ptr [esp+0Ch]
slouken@1895
  1030
        neg         edx
slouken@1895
  1031
        neg         eax
slouken@1895
  1032
        sbb         edx,0
slouken@1895
  1033
        mov         ecx,edx
slouken@1895
  1034
        mov         edx,ebx
slouken@1895
  1035
        mov         ebx,ecx
slouken@1895
  1036
        mov         ecx,eax
slouken@1895
  1037
        mov         eax,esi
slouken@1895
  1038
        pop         esi
slouken@1895
  1039
        ret         10h
slouken@1895
  1040
    }
slouken@1895
  1041
    /* *INDENT-ON* */
slouken@1330
  1042
}
slouken@2735
  1043
slouken@1895
  1044
void
slouken@1895
  1045
__declspec(naked)
slouken@1895
  1046
_allshl()
slouken@1330
  1047
{
slouken@1895
  1048
    /* *INDENT-OFF* */
slouken@1895
  1049
    __asm {
slouken@1895
  1050
        cmp         cl,40h
slouken@1895
  1051
        jae         RETZERO
slouken@1895
  1052
        cmp         cl,20h
slouken@1895
  1053
        jae         MORE32
slouken@1895
  1054
        shld        edx,eax,cl
slouken@1895
  1055
        shl         eax,cl
slouken@1895
  1056
        ret
slouken@1346
  1057
MORE32:
slouken@1895
  1058
        mov         edx,eax
slouken@1895
  1059
        xor         eax,eax
slouken@1895
  1060
        and         cl,1Fh
slouken@1895
  1061
        shl         edx,cl
slouken@1895
  1062
        ret
slouken@1346
  1063
RETZERO:
slouken@1895
  1064
        xor         eax,eax
slouken@1895
  1065
        xor         edx,edx
slouken@1895
  1066
        ret
slouken@1895
  1067
    }
slouken@1895
  1068
    /* *INDENT-ON* */
slouken@1330
  1069
}
slouken@2735
  1070
slouken@1895
  1071
void
slouken@1895
  1072
__declspec(naked)
slouken@2760
  1073
_allshr()
slouken@2760
  1074
{
slouken@2760
  1075
    /* *INDENT-OFF* */
slouken@2760
  1076
    __asm {
slouken@10587
  1077
        cmp         cl,3Fh
slouken@10587
  1078
        jae         RETSIGN
slouken@2760
  1079
        cmp         cl,20h
slouken@2760
  1080
        jae         MORE32
slouken@2760
  1081
        shrd        eax,edx,cl
slouken@2760
  1082
        sar         edx,cl
slouken@2760
  1083
        ret
slouken@2760
  1084
MORE32:
slouken@2760
  1085
        mov         eax,edx
slouken@10587
  1086
        sar         edx,1Fh
slouken@2760
  1087
        and         cl,1Fh
slouken@2760
  1088
        sar         eax,cl
slouken@2760
  1089
        ret
slouken@10587
  1090
RETSIGN:
slouken@10587
  1091
        sar         edx,1Fh
slouken@10587
  1092
        mov         eax,edx
slouken@2760
  1093
        ret
slouken@2760
  1094
    }
slouken@2760
  1095
    /* *INDENT-ON* */
slouken@2760
  1096
}
slouken@2760
  1097
slouken@2760
  1098
void
slouken@2760
  1099
__declspec(naked)
slouken@1895
  1100
_aullshr()
slouken@1330
  1101
{
slouken@1895
  1102
    /* *INDENT-OFF* */
slouken@1895
  1103
    __asm {
slouken@1895
  1104
        cmp         cl,40h
slouken@1895
  1105
        jae         RETZERO
slouken@1895
  1106
        cmp         cl,20h
slouken@1895
  1107
        jae         MORE32
slouken@1895
  1108
        shrd        eax,edx,cl
slouken@1895
  1109
        shr         edx,cl
slouken@1895
  1110
        ret
slouken@1346
  1111
MORE32:
slouken@1895
  1112
        mov         eax,edx
slouken@1895
  1113
        xor         edx,edx
slouken@1895
  1114
        and         cl,1Fh
slouken@1895
  1115
        shr         eax,cl
slouken@1895
  1116
        ret
slouken@1346
  1117
RETZERO:
slouken@1895
  1118
        xor         eax,eax
slouken@1895
  1119
        xor         edx,edx
slouken@1895
  1120
        ret
slouken@1895
  1121
    }
slouken@1895
  1122
    /* *INDENT-ON* */
slouken@1330
  1123
}
slouken@1330
  1124
slouken@5455
  1125
#endif /* _M_IX86 */
slouken@3255
  1126
slouken@1330
  1127
#endif /* MSC_VER */
slouken@1330
  1128
slouken@1331
  1129
#endif /* !HAVE_LIBC */
slouken@1895
  1130
slouken@1895
  1131
/* vi: set ts=4 sw=4 expandtab: */