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