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