src/stdlib/SDL_stdlib.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 24 Jan 2011 15:46:11 -0800
changeset 5086 c2539ff054c8
parent 4868 d6adaafcfb10
child 5262 b530ef003506
permissions -rw-r--r--
Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
slouken@1330
     1
/*
slouken@1330
     2
    SDL - Simple DirectMedia Layer
slouken@3697
     3
    Copyright (C) 1997-2010 Sam Lantinga
slouken@1330
     4
slouken@1330
     5
    This library is free software; you can redistribute it and/or
slouken@1330
     6
    modify it under the terms of the GNU Lesser General Public
slouken@1330
     7
    License as published by the Free Software Foundation; either
slouken@1330
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@1330
     9
slouken@1330
    10
    This library is distributed in the hope that it will be useful,
slouken@1330
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@1330
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1330
    13
    Lesser General Public License for more details.
slouken@1330
    14
slouken@1330
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1330
    16
    License along with this library; if not, write to the Free Software
slouken@1330
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@1330
    18
slouken@1330
    19
    Sam Lantinga
slouken@1330
    20
    slouken@libsdl.org
slouken@1330
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@1330
    23
slouken@1330
    24
/* This file contains portable stdlib functions for SDL */
slouken@1330
    25
slouken@1354
    26
#include "SDL_stdinc.h"
slouken@1330
    27
slouken@1330
    28
#ifndef HAVE_LIBC
slouken@1330
    29
/* These are some C runtime intrinsics that need to be defined */
slouken@1330
    30
slouken@3255
    31
#if defined(_MSC_VER)
slouken@1330
    32
slouken@1433
    33
#ifndef __FLTUSED__
slouken@1433
    34
#define __FLTUSED__
slouken@3255
    35
__declspec(selectany) int _fltused = 1;
slouken@1433
    36
#endif
slouken@3255
    37
slouken@5086
    38
#ifdef _M_IX86
slouken@1433
    39
slouken@4868
    40
void
slouken@4868
    41
__declspec(naked)
slouken@4868
    42
_chkstk()
slouken@4868
    43
{
slouken@4868
    44
}
slouken@4868
    45
slouken@1346
    46
/* Float to long */
slouken@3253
    47
void
slouken@3253
    48
__declspec(naked)
slouken@3253
    49
_ftol()
slouken@1345
    50
{
slouken@1895
    51
    /* *INDENT-OFF* */
slouken@1895
    52
    __asm {
slouken@1895
    53
        push        ebp
slouken@1895
    54
        mov         ebp,esp
slouken@1895
    55
        sub         esp,20h
slouken@1895
    56
        and         esp,0FFFFFFF0h
slouken@1895
    57
        fld         st(0)
slouken@1895
    58
        fst         dword ptr [esp+18h]
slouken@1895
    59
        fistp       qword ptr [esp+10h]
slouken@1895
    60
        fild        qword ptr [esp+10h]
slouken@1895
    61
        mov         edx,dword ptr [esp+18h]
slouken@1895
    62
        mov         eax,dword ptr [esp+10h]
slouken@1895
    63
        test        eax,eax
slouken@1895
    64
        je          integer_QnaN_or_zero
slouken@1346
    65
arg_is_not_integer_QnaN:
slouken@1895
    66
        fsubp       st(1),st
slouken@1895
    67
        test        edx,edx
slouken@1895
    68
        jns         positive
slouken@1895
    69
        fstp        dword ptr [esp]
slouken@1895
    70
        mov         ecx,dword ptr [esp]
slouken@1895
    71
        xor         ecx,80000000h
slouken@1895
    72
        add         ecx,7FFFFFFFh
slouken@1895
    73
        adc         eax,0
slouken@1895
    74
        mov         edx,dword ptr [esp+14h]
slouken@1895
    75
        adc         edx,0
slouken@1895
    76
        jmp         localexit
slouken@1346
    77
positive:
slouken@1895
    78
        fstp        dword ptr [esp]
slouken@1895
    79
        mov         ecx,dword ptr [esp]
slouken@1895
    80
        add         ecx,7FFFFFFFh
slouken@1895
    81
        sbb         eax,0
slouken@1895
    82
        mov         edx,dword ptr [esp+14h]
slouken@1895
    83
        sbb         edx,0
slouken@1895
    84
        jmp         localexit
slouken@1346
    85
integer_QnaN_or_zero:
slouken@1895
    86
        mov         edx,dword ptr [esp+14h]
slouken@1895
    87
        test        edx,7FFFFFFFh
slouken@1895
    88
        jne         arg_is_not_integer_QnaN
slouken@1895
    89
        fstp        dword ptr [esp+18h]
slouken@1895
    90
        fstp        dword ptr [esp+18h]
slouken@1346
    91
localexit:
slouken@1895
    92
        leave
slouken@1895
    93
        ret
slouken@1895
    94
    }
slouken@1895
    95
    /* *INDENT-ON* */
slouken@1345
    96
}
slouken@1895
    97
slouken@1895
    98
void
slouken@1895
    99
_ftol2_sse()
slouken@1330
   100
{
slouken@1895
   101
    _ftol();
slouken@1330
   102
}
slouken@1330
   103
slouken@1346
   104
/* 64-bit math operators for 32-bit systems */
slouken@1895
   105
void
slouken@1895
   106
__declspec(naked)
slouken@1895
   107
_allmul()
slouken@1330
   108
{
slouken@1895
   109
    /* *INDENT-OFF* */
slouken@1895
   110
    __asm {
slouken@1895
   111
        push        ebp
slouken@1895
   112
        mov         ebp,esp
slouken@1895
   113
        push        edi
slouken@1895
   114
        push        esi
slouken@1895
   115
        push        ebx
slouken@1895
   116
        sub         esp,0Ch
slouken@1895
   117
        mov         eax,dword ptr [ebp+10h]
slouken@1895
   118
        mov         edi,dword ptr [ebp+8]
slouken@1895
   119
        mov         ebx,eax
slouken@1895
   120
        mov         esi,eax
slouken@1895
   121
        sar         esi,1Fh
slouken@1895
   122
        mov         eax,dword ptr [ebp+8]
slouken@1895
   123
        mul         ebx
slouken@1895
   124
        imul        edi,esi
slouken@1895
   125
        mov         ecx,edx
slouken@1895
   126
        mov         dword ptr [ebp-18h],eax
slouken@1895
   127
        mov         edx,dword ptr [ebp+0Ch]
slouken@1895
   128
        add         ecx,edi
slouken@1895
   129
        imul        ebx,edx
slouken@1895
   130
        mov         eax,dword ptr [ebp-18h]
slouken@1895
   131
        lea         ebx,[ebx+ecx]
slouken@1895
   132
        mov         dword ptr [ebp-14h],ebx
slouken@1895
   133
        mov         edx,dword ptr [ebp-14h]
slouken@1895
   134
        add         esp,0Ch
slouken@1895
   135
        pop         ebx
slouken@1895
   136
        pop         esi
slouken@1895
   137
        pop         edi
slouken@1895
   138
        pop         ebp
slouken@1895
   139
        ret
slouken@1895
   140
    }
slouken@1895
   141
    /* *INDENT-ON* */
slouken@1330
   142
}
slouken@2735
   143
slouken@1895
   144
void
slouken@1895
   145
__declspec(naked)
slouken@1895
   146
_alldiv()
slouken@1330
   147
{
slouken@1895
   148
    /* *INDENT-OFF* */
slouken@1895
   149
    __asm {
slouken@1895
   150
        push        edi
slouken@1895
   151
        push        esi
slouken@1895
   152
        push        ebx
slouken@1895
   153
        xor         edi,edi
slouken@1895
   154
        mov         eax,dword ptr [esp+14h]
slouken@1895
   155
        or          eax,eax
slouken@1895
   156
        jge         L1
slouken@1895
   157
        inc         edi
slouken@1895
   158
        mov         edx,dword ptr [esp+10h]
slouken@1895
   159
        neg         eax
slouken@1895
   160
        neg         edx
slouken@1895
   161
        sbb         eax,0
slouken@1895
   162
        mov         dword ptr [esp+14h],eax
slouken@1895
   163
        mov         dword ptr [esp+10h],edx
slouken@1346
   164
L1:
slouken@1895
   165
        mov         eax,dword ptr [esp+1Ch]
slouken@1895
   166
        or          eax,eax
slouken@1895
   167
        jge         L2
slouken@1895
   168
        inc         edi
slouken@1895
   169
        mov         edx,dword ptr [esp+18h]
slouken@1895
   170
        neg         eax
slouken@1895
   171
        neg         edx
slouken@1895
   172
        sbb         eax,0
slouken@1895
   173
        mov         dword ptr [esp+1Ch],eax
slouken@1895
   174
        mov         dword ptr [esp+18h],edx
slouken@1346
   175
L2:
slouken@1895
   176
        or          eax,eax
slouken@1895
   177
        jne         L3
slouken@1895
   178
        mov         ecx,dword ptr [esp+18h]
slouken@1895
   179
        mov         eax,dword ptr [esp+14h]
slouken@1895
   180
        xor         edx,edx
slouken@1895
   181
        div         ecx
slouken@1895
   182
        mov         ebx,eax
slouken@1895
   183
        mov         eax,dword ptr [esp+10h]
slouken@1895
   184
        div         ecx
slouken@1895
   185
        mov         edx,ebx
slouken@1895
   186
        jmp         L4
slouken@1346
   187
L3:
slouken@1895
   188
        mov         ebx,eax
slouken@1895
   189
        mov         ecx,dword ptr [esp+18h]
slouken@1895
   190
        mov         edx,dword ptr [esp+14h]
slouken@1895
   191
        mov         eax,dword ptr [esp+10h]
slouken@1346
   192
L5:
slouken@1895
   193
        shr         ebx,1
slouken@1895
   194
        rcr         ecx,1
slouken@1895
   195
        shr         edx,1
slouken@1895
   196
        rcr         eax,1
slouken@1895
   197
        or          ebx,ebx
slouken@1895
   198
        jne         L5
slouken@1895
   199
        div         ecx
slouken@1895
   200
        mov         esi,eax
slouken@1895
   201
        mul         dword ptr [esp+1Ch]
slouken@1895
   202
        mov         ecx,eax
slouken@1895
   203
        mov         eax,dword ptr [esp+18h]
slouken@1895
   204
        mul         esi
slouken@1895
   205
        add         edx,ecx
slouken@1895
   206
        jb          L6
slouken@1895
   207
        cmp         edx,dword ptr [esp+14h]
slouken@1895
   208
        ja          L6
slouken@1895
   209
        jb          L7
slouken@1895
   210
        cmp         eax,dword ptr [esp+10h]
slouken@1895
   211
        jbe         L7
slouken@1346
   212
L6:
slouken@1895
   213
        dec         esi
slouken@1346
   214
L7:
slouken@1895
   215
        xor         edx,edx
slouken@1895
   216
        mov         eax,esi
slouken@1346
   217
L4:
slouken@1895
   218
        dec         edi
slouken@1895
   219
        jne         L8
slouken@1895
   220
        neg         edx
slouken@1895
   221
        neg         eax
slouken@1895
   222
        sbb         edx,0
slouken@1346
   223
L8:
slouken@1895
   224
        pop         ebx
slouken@1895
   225
        pop         esi
slouken@1895
   226
        pop         edi
slouken@1895
   227
        ret         10h
slouken@1895
   228
    }
slouken@1895
   229
    /* *INDENT-ON* */
slouken@1330
   230
}
slouken@2735
   231
slouken@1895
   232
void
slouken@1895
   233
__declspec(naked)
slouken@1895
   234
_aulldiv()
slouken@1330
   235
{
slouken@1895
   236
    /* *INDENT-OFF* */
slouken@1895
   237
    __asm {
slouken@1895
   238
        push        ebx
slouken@1895
   239
        push        esi
slouken@1895
   240
        mov         eax,dword ptr [esp+18h]
slouken@1895
   241
        or          eax,eax
slouken@1895
   242
        jne         L1
slouken@1895
   243
        mov         ecx,dword ptr [esp+14h]
slouken@1895
   244
        mov         eax,dword ptr [esp+10h]
slouken@1895
   245
        xor         edx,edx
slouken@1895
   246
        div         ecx
slouken@1895
   247
        mov         ebx,eax
slouken@1895
   248
        mov         eax,dword ptr [esp+0Ch]
slouken@1895
   249
        div         ecx
slouken@1895
   250
        mov         edx,ebx
slouken@1895
   251
        jmp         L2
slouken@1346
   252
L1:
slouken@1895
   253
        mov         ecx,eax
slouken@1895
   254
        mov         ebx,dword ptr [esp+14h]
slouken@1895
   255
        mov         edx,dword ptr [esp+10h]
slouken@1895
   256
        mov         eax,dword ptr [esp+0Ch]
slouken@1346
   257
L3:
slouken@1895
   258
        shr         ecx,1
slouken@1895
   259
        rcr         ebx,1
slouken@1895
   260
        shr         edx,1
slouken@1895
   261
        rcr         eax,1
slouken@1895
   262
        or          ecx,ecx
slouken@1895
   263
        jne         L3
slouken@1895
   264
        div         ebx
slouken@1895
   265
        mov         esi,eax
slouken@1895
   266
        mul         dword ptr [esp+18h]
slouken@1895
   267
        mov         ecx,eax
slouken@1895
   268
        mov         eax,dword ptr [esp+14h]
slouken@1895
   269
        mul         esi
slouken@1895
   270
        add         edx,ecx
slouken@1895
   271
        jb          L4
slouken@1895
   272
        cmp         edx,dword ptr [esp+10h]
slouken@1895
   273
        ja          L4
slouken@1895
   274
        jb          L5
slouken@1895
   275
        cmp         eax,dword ptr [esp+0Ch]
slouken@1895
   276
        jbe         L5
slouken@1346
   277
L4:
slouken@1895
   278
        dec         esi
slouken@1346
   279
L5:
slouken@1895
   280
        xor         edx,edx
slouken@1895
   281
        mov         eax,esi
slouken@1346
   282
L2:
slouken@1895
   283
        pop         esi
slouken@1895
   284
        pop         ebx
slouken@1895
   285
        ret         10h
slouken@1895
   286
    }
slouken@1895
   287
    /* *INDENT-ON* */
slouken@1330
   288
}
slouken@2735
   289
slouken@1895
   290
void
slouken@1895
   291
__declspec(naked)
slouken@1895
   292
_allrem()
slouken@1330
   293
{
slouken@1895
   294
    /* *INDENT-OFF* */
slouken@1895
   295
    __asm {
slouken@1895
   296
        push        ebx
slouken@1895
   297
        push        edi
slouken@1895
   298
        xor         edi,edi
slouken@1895
   299
        mov         eax,dword ptr [esp+10h]
slouken@1895
   300
        or          eax,eax
slouken@1895
   301
        jge         L1
slouken@1895
   302
        inc         edi
slouken@1895
   303
        mov         edx,dword ptr [esp+0Ch]
slouken@1895
   304
        neg         eax
slouken@1895
   305
        neg         edx
slouken@1895
   306
        sbb         eax,0
slouken@1895
   307
        mov         dword ptr [esp+10h],eax
slouken@1895
   308
        mov         dword ptr [esp+0Ch],edx
slouken@1346
   309
L1:
slouken@1895
   310
        mov         eax,dword ptr [esp+18h]
slouken@1895
   311
        or          eax,eax
slouken@1895
   312
        jge         L2
slouken@1895
   313
        mov         edx,dword ptr [esp+14h]
slouken@1895
   314
        neg         eax
slouken@1895
   315
        neg         edx
slouken@1895
   316
        sbb         eax,0
slouken@1895
   317
        mov         dword ptr [esp+18h],eax
slouken@1895
   318
        mov         dword ptr [esp+14h],edx
slouken@1346
   319
L2:
slouken@1895
   320
        or          eax,eax
slouken@1895
   321
        jne         L3
slouken@1895
   322
        mov         ecx,dword ptr [esp+14h]
slouken@1895
   323
        mov         eax,dword ptr [esp+10h]
slouken@1895
   324
        xor         edx,edx
slouken@1895
   325
        div         ecx
slouken@1895
   326
        mov         eax,dword ptr [esp+0Ch]
slouken@1895
   327
        div         ecx
slouken@1895
   328
        mov         eax,edx
slouken@1895
   329
        xor         edx,edx
slouken@1895
   330
        dec         edi
slouken@1895
   331
        jns         L4
slouken@1895
   332
        jmp         L8
slouken@1346
   333
L3:
slouken@1895
   334
        mov         ebx,eax
slouken@1895
   335
        mov         ecx,dword ptr [esp+14h]
slouken@1895
   336
        mov         edx,dword ptr [esp+10h]
slouken@1895
   337
        mov         eax,dword ptr [esp+0Ch]
slouken@1346
   338
L5:
slouken@1895
   339
        shr         ebx,1
slouken@1895
   340
        rcr         ecx,1
slouken@1895
   341
        shr         edx,1
slouken@1895
   342
        rcr         eax,1
slouken@1895
   343
        or          ebx,ebx
slouken@1895
   344
        jne         L5
slouken@1895
   345
        div         ecx
slouken@1895
   346
        mov         ecx,eax
slouken@1895
   347
        mul         dword ptr [esp+18h]
slouken@1895
   348
        xchg        eax,ecx
slouken@1895
   349
        mul         dword ptr [esp+14h]
slouken@1895
   350
        add         edx,ecx
slouken@1895
   351
        jb          L6
slouken@1895
   352
        cmp         edx,dword ptr [esp+10h]
slouken@1895
   353
        ja          L6
slouken@1895
   354
        jb          L7
slouken@1895
   355
        cmp         eax,dword ptr [esp+0Ch]
slouken@1895
   356
        jbe         L7
slouken@1346
   357
L6:
slouken@1895
   358
        sub         eax,dword ptr [esp+14h]
slouken@1895
   359
        sbb         edx,dword ptr [esp+18h]
slouken@1346
   360
L7:
slouken@1895
   361
        sub         eax,dword ptr [esp+0Ch]
slouken@1895
   362
        sbb         edx,dword ptr [esp+10h]
slouken@1895
   363
        dec         edi
slouken@1895
   364
        jns         L8
slouken@1346
   365
L4:
slouken@1895
   366
        neg         edx
slouken@1895
   367
        neg         eax
slouken@1895
   368
        sbb         edx,0
slouken@1346
   369
L8:
slouken@1895
   370
        pop         edi
slouken@1895
   371
        pop         ebx
slouken@1895
   372
        ret         10h
slouken@1895
   373
    }
slouken@1895
   374
    /* *INDENT-ON* */
slouken@1330
   375
}
slouken@2735
   376
slouken@1895
   377
void
slouken@1895
   378
__declspec(naked)
slouken@1895
   379
_aullrem()
slouken@1330
   380
{
slouken@1895
   381
    /* *INDENT-OFF* */
slouken@1895
   382
    __asm {
slouken@1895
   383
        push        ebx
slouken@1895
   384
        mov         eax,dword ptr [esp+14h]
slouken@1895
   385
        or          eax,eax
slouken@1895
   386
        jne         L1
slouken@1895
   387
        mov         ecx,dword ptr [esp+10h]
slouken@1895
   388
        mov         eax,dword ptr [esp+0Ch]
slouken@1895
   389
        xor         edx,edx
slouken@1895
   390
        div         ecx
slouken@1895
   391
        mov         eax,dword ptr [esp+8]
slouken@1895
   392
        div         ecx
slouken@1895
   393
        mov         eax,edx
slouken@1895
   394
        xor         edx,edx
slouken@1895
   395
        jmp         L2
slouken@1346
   396
L1:
slouken@1895
   397
        mov         ecx,eax
slouken@1895
   398
        mov         ebx,dword ptr [esp+10h]
slouken@1895
   399
        mov         edx,dword ptr [esp+0Ch]
slouken@1895
   400
        mov         eax,dword ptr [esp+8]
slouken@1346
   401
L3:
slouken@1895
   402
        shr         ecx,1
slouken@1895
   403
        rcr         ebx,1
slouken@1895
   404
        shr         edx,1
slouken@1895
   405
        rcr         eax,1
slouken@1895
   406
        or          ecx,ecx
slouken@1895
   407
        jne         L3
slouken@1895
   408
        div         ebx
slouken@1895
   409
        mov         ecx,eax
slouken@1895
   410
        mul         dword ptr [esp+14h]
slouken@1895
   411
        xchg        eax,ecx
slouken@1895
   412
        mul         dword ptr [esp+10h]
slouken@1895
   413
        add         edx,ecx
slouken@1895
   414
        jb          L4
slouken@1895
   415
        cmp         edx,dword ptr [esp+0Ch]
slouken@1895
   416
        ja          L4
slouken@1895
   417
        jb          L5
slouken@1895
   418
        cmp         eax,dword ptr [esp+8]
slouken@1895
   419
        jbe         L5
slouken@1346
   420
L4:
slouken@1895
   421
        sub         eax,dword ptr [esp+10h]
slouken@1895
   422
        sbb         edx,dword ptr [esp+14h]
slouken@1346
   423
L5:
slouken@1895
   424
        sub         eax,dword ptr [esp+8]
slouken@1895
   425
        sbb         edx,dword ptr [esp+0Ch]
slouken@1895
   426
        neg         edx
slouken@1895
   427
        neg         eax
slouken@1895
   428
        sbb         edx,0
slouken@1346
   429
L2:
slouken@1895
   430
        pop         ebx
slouken@1895
   431
        ret         10h
slouken@1895
   432
    }
slouken@1895
   433
    /* *INDENT-ON* */
slouken@1330
   434
}
slouken@2735
   435
slouken@1895
   436
void
slouken@1895
   437
__declspec(naked)
slouken@1895
   438
_alldvrm()
slouken@1330
   439
{
slouken@1895
   440
    /* *INDENT-OFF* */
slouken@1895
   441
    __asm {
slouken@1895
   442
        push        edi
slouken@1895
   443
        push        esi
slouken@1895
   444
        push        ebp
slouken@1895
   445
        xor         edi,edi
slouken@1895
   446
        xor         ebp,ebp
slouken@1895
   447
        mov         eax,dword ptr [esp+14h]
slouken@1895
   448
        or          eax,eax
slouken@1895
   449
        jge         L1
slouken@1895
   450
        inc         edi
slouken@1895
   451
        inc         ebp
slouken@1895
   452
        mov         edx,dword ptr [esp+10h]
slouken@1895
   453
        neg         eax
slouken@1895
   454
        neg         edx
slouken@1895
   455
        sbb         eax,0
slouken@1895
   456
        mov         dword ptr [esp+14h],eax
slouken@1895
   457
        mov         dword ptr [esp+10h],edx
slouken@1346
   458
L1:
slouken@1895
   459
        mov         eax,dword ptr [esp+1Ch]
slouken@1895
   460
        or          eax,eax
slouken@1895
   461
        jge         L2
slouken@1895
   462
        inc         edi
slouken@1895
   463
        mov         edx,dword ptr [esp+18h]
slouken@1895
   464
        neg         eax
slouken@1895
   465
        neg         edx
slouken@1895
   466
        sbb         eax,0
slouken@1895
   467
        mov         dword ptr [esp+1Ch],eax
slouken@1895
   468
        mov         dword ptr [esp+18h],edx
slouken@1346
   469
L2:
slouken@1895
   470
        or          eax,eax
slouken@1895
   471
        jne         L3
slouken@1895
   472
        mov         ecx,dword ptr [esp+18h]
slouken@1895
   473
        mov         eax,dword ptr [esp+14h]
slouken@1895
   474
        xor         edx,edx
slouken@1895
   475
        div         ecx
slouken@1895
   476
        mov         ebx,eax
slouken@1895
   477
        mov         eax,dword ptr [esp+10h]
slouken@1895
   478
        div         ecx
slouken@1895
   479
        mov         esi,eax
slouken@1895
   480
        mov         eax,ebx
slouken@1895
   481
        mul         dword ptr [esp+18h]
slouken@1895
   482
        mov         ecx,eax
slouken@1895
   483
        mov         eax,esi
slouken@1895
   484
        mul         dword ptr [esp+18h]
slouken@1895
   485
        add         edx,ecx
slouken@1895
   486
        jmp         L4
slouken@1346
   487
L3:
slouken@1895
   488
        mov         ebx,eax
slouken@1895
   489
        mov         ecx,dword ptr [esp+18h]
slouken@1895
   490
        mov         edx,dword ptr [esp+14h]
slouken@1895
   491
        mov         eax,dword ptr [esp+10h]
slouken@1346
   492
L5:
slouken@1895
   493
        shr         ebx,1
slouken@1895
   494
        rcr         ecx,1
slouken@1895
   495
        shr         edx,1
slouken@1895
   496
        rcr         eax,1
slouken@1895
   497
        or          ebx,ebx
slouken@1895
   498
        jne         L5
slouken@1895
   499
        div         ecx
slouken@1895
   500
        mov         esi,eax
slouken@1895
   501
        mul         dword ptr [esp+1Ch]
slouken@1895
   502
        mov         ecx,eax
slouken@1895
   503
        mov         eax,dword ptr [esp+18h]
slouken@1895
   504
        mul         esi
slouken@1895
   505
        add         edx,ecx
slouken@1895
   506
        jb          L6
slouken@1895
   507
        cmp         edx,dword ptr [esp+14h]
slouken@1895
   508
        ja          L6
slouken@1895
   509
        jb          L7
slouken@1895
   510
        cmp         eax,dword ptr [esp+10h]
slouken@1895
   511
        jbe         L7
slouken@1346
   512
L6:
slouken@1895
   513
        dec         esi
slouken@1895
   514
        sub         eax,dword ptr [esp+18h]
slouken@1895
   515
        sbb         edx,dword ptr [esp+1Ch]
slouken@1346
   516
L7:
slouken@1895
   517
        xor         ebx,ebx
slouken@1346
   518
L4:
slouken@1895
   519
        sub         eax,dword ptr [esp+10h]
slouken@1895
   520
        sbb         edx,dword ptr [esp+14h]
slouken@1895
   521
        dec         ebp
slouken@1895
   522
        jns         L9
slouken@1895
   523
        neg         edx
slouken@1895
   524
        neg         eax
slouken@1895
   525
        sbb         edx,0
slouken@1346
   526
L9:
slouken@1895
   527
        mov         ecx,edx
slouken@1895
   528
        mov         edx,ebx
slouken@1895
   529
        mov         ebx,ecx
slouken@1895
   530
        mov         ecx,eax
slouken@1895
   531
        mov         eax,esi
slouken@1895
   532
        dec         edi
slouken@1895
   533
        jne         L8
slouken@1895
   534
        neg         edx
slouken@1895
   535
        neg         eax
slouken@1895
   536
        sbb         edx,0
slouken@1346
   537
L8:
slouken@1895
   538
        pop         ebp
slouken@1895
   539
        pop         esi
slouken@1895
   540
        pop         edi
slouken@1895
   541
        ret         10h
slouken@1895
   542
    }
slouken@1895
   543
    /* *INDENT-ON* */
slouken@1330
   544
}
slouken@2735
   545
slouken@1895
   546
void
slouken@1895
   547
__declspec(naked)
slouken@1895
   548
_aulldvrm()
slouken@1330
   549
{
slouken@1895
   550
    /* *INDENT-OFF* */
slouken@1895
   551
    __asm {
slouken@1895
   552
        push        esi
slouken@1895
   553
        mov         eax,dword ptr [esp+14h]
slouken@1895
   554
        or          eax,eax
slouken@1895
   555
        jne         L1
slouken@1895
   556
        mov         ecx,dword ptr [esp+10h]
slouken@1895
   557
        mov         eax,dword ptr [esp+0Ch]
slouken@1895
   558
        xor         edx,edx
slouken@1895
   559
        div         ecx
slouken@1895
   560
        mov         ebx,eax
slouken@1895
   561
        mov         eax,dword ptr [esp+8]
slouken@1895
   562
        div         ecx
slouken@1895
   563
        mov         esi,eax
slouken@1895
   564
        mov         eax,ebx
slouken@1895
   565
        mul         dword ptr [esp+10h]
slouken@1895
   566
        mov         ecx,eax
slouken@1895
   567
        mov         eax,esi
slouken@1895
   568
        mul         dword ptr [esp+10h]
slouken@1895
   569
        add         edx,ecx
slouken@1895
   570
        jmp         L2
slouken@1346
   571
L1:
slouken@1895
   572
        mov         ecx,eax
slouken@1895
   573
        mov         ebx,dword ptr [esp+10h]
slouken@1895
   574
        mov         edx,dword ptr [esp+0Ch]
slouken@1895
   575
        mov         eax,dword ptr [esp+8]
slouken@1346
   576
L3:
slouken@1895
   577
        shr         ecx,1
slouken@1895
   578
        rcr         ebx,1
slouken@1895
   579
        shr         edx,1
slouken@1895
   580
        rcr         eax,1
slouken@1895
   581
        or          ecx,ecx
slouken@1895
   582
        jne         L3
slouken@1895
   583
        div         ebx
slouken@1895
   584
        mov         esi,eax
slouken@1895
   585
        mul         dword ptr [esp+14h]
slouken@1895
   586
        mov         ecx,eax
slouken@1895
   587
        mov         eax,dword ptr [esp+10h]
slouken@1895
   588
        mul         esi
slouken@1895
   589
        add         edx,ecx
slouken@1895
   590
        jb          L4
slouken@1895
   591
        cmp         edx,dword ptr [esp+0Ch]
slouken@1895
   592
        ja          L4
slouken@1895
   593
        jb          L5
slouken@1895
   594
        cmp         eax,dword ptr [esp+8]
slouken@1895
   595
        jbe         L5
slouken@1346
   596
L4:
slouken@1895
   597
        dec         esi
slouken@1895
   598
        sub         eax,dword ptr [esp+10h]
slouken@1895
   599
        sbb         edx,dword ptr [esp+14h]
slouken@1346
   600
L5:
slouken@1895
   601
        xor         ebx,ebx
slouken@1346
   602
L2:
slouken@1895
   603
        sub         eax,dword ptr [esp+8]
slouken@1895
   604
        sbb         edx,dword ptr [esp+0Ch]
slouken@1895
   605
        neg         edx
slouken@1895
   606
        neg         eax
slouken@1895
   607
        sbb         edx,0
slouken@1895
   608
        mov         ecx,edx
slouken@1895
   609
        mov         edx,ebx
slouken@1895
   610
        mov         ebx,ecx
slouken@1895
   611
        mov         ecx,eax
slouken@1895
   612
        mov         eax,esi
slouken@1895
   613
        pop         esi
slouken@1895
   614
        ret         10h
slouken@1895
   615
    }
slouken@1895
   616
    /* *INDENT-ON* */
slouken@1330
   617
}
slouken@2735
   618
slouken@1895
   619
void
slouken@1895
   620
__declspec(naked)
slouken@1895
   621
_allshl()
slouken@1330
   622
{
slouken@1895
   623
    /* *INDENT-OFF* */
slouken@1895
   624
    __asm {
slouken@1895
   625
        cmp         cl,40h
slouken@1895
   626
        jae         RETZERO
slouken@1895
   627
        cmp         cl,20h
slouken@1895
   628
        jae         MORE32
slouken@1895
   629
        shld        edx,eax,cl
slouken@1895
   630
        shl         eax,cl
slouken@1895
   631
        ret
slouken@1346
   632
MORE32:
slouken@1895
   633
        mov         edx,eax
slouken@1895
   634
        xor         eax,eax
slouken@1895
   635
        and         cl,1Fh
slouken@1895
   636
        shl         edx,cl
slouken@1895
   637
        ret
slouken@1346
   638
RETZERO:
slouken@1895
   639
        xor         eax,eax
slouken@1895
   640
        xor         edx,edx
slouken@1895
   641
        ret
slouken@1895
   642
    }
slouken@1895
   643
    /* *INDENT-ON* */
slouken@1330
   644
}
slouken@2735
   645
slouken@1895
   646
void
slouken@1895
   647
__declspec(naked)
slouken@2760
   648
_allshr()
slouken@2760
   649
{
slouken@2760
   650
    /* *INDENT-OFF* */
slouken@2760
   651
    __asm {
slouken@2760
   652
        cmp         cl,40h
slouken@2760
   653
        jae         RETZERO
slouken@2760
   654
        cmp         cl,20h
slouken@2760
   655
        jae         MORE32
slouken@2760
   656
        shrd        eax,edx,cl
slouken@2760
   657
        sar         edx,cl
slouken@2760
   658
        ret
slouken@2760
   659
MORE32:
slouken@2760
   660
        mov         eax,edx
slouken@2760
   661
        xor         edx,edx
slouken@2760
   662
        and         cl,1Fh
slouken@2760
   663
        sar         eax,cl
slouken@2760
   664
        ret
slouken@2760
   665
RETZERO:
slouken@2760
   666
        xor         eax,eax
slouken@2760
   667
        xor         edx,edx
slouken@2760
   668
        ret
slouken@2760
   669
    }
slouken@2760
   670
    /* *INDENT-ON* */
slouken@2760
   671
}
slouken@2760
   672
slouken@2760
   673
void
slouken@2760
   674
__declspec(naked)
slouken@1895
   675
_aullshr()
slouken@1330
   676
{
slouken@1895
   677
    /* *INDENT-OFF* */
slouken@1895
   678
    __asm {
slouken@1895
   679
        cmp         cl,40h
slouken@1895
   680
        jae         RETZERO
slouken@1895
   681
        cmp         cl,20h
slouken@1895
   682
        jae         MORE32
slouken@1895
   683
        shrd        eax,edx,cl
slouken@1895
   684
        shr         edx,cl
slouken@1895
   685
        ret
slouken@1346
   686
MORE32:
slouken@1895
   687
        mov         eax,edx
slouken@1895
   688
        xor         edx,edx
slouken@1895
   689
        and         cl,1Fh
slouken@1895
   690
        shr         eax,cl
slouken@1895
   691
        ret
slouken@1346
   692
RETZERO:
slouken@1895
   693
        xor         eax,eax
slouken@1895
   694
        xor         edx,edx
slouken@1895
   695
        ret
slouken@1895
   696
    }
slouken@1895
   697
    /* *INDENT-ON* */
slouken@1330
   698
}
slouken@1330
   699
slouken@3255
   700
#endif /* _WIN64 */
slouken@3255
   701
slouken@1330
   702
#endif /* MSC_VER */
slouken@1330
   703
slouken@1331
   704
#endif /* !HAVE_LIBC */
slouken@1895
   705
slouken@1895
   706
/* vi: set ts=4 sw=4 expandtab: */