Subversion Repositories autosfx

Rev

Blame | Last modification | View Log | RSS feed

  1. #include "stdafx.h"
  2. #pragma hdrstop
  3.  
  4. #if defined(__BORLANDC__) && (__BORLANDC__ < 0x0570)
  5. #pragma inline
  6. #endif
  7. /*
  8. ************************************************************************
  9.  Copyright (C) 2009, 2010  by Russell J. Peters, Roger Aelbrecht
  10.  
  11.    This file is part of TZipMaster Version 1.9.
  12.  
  13.     TZipMaster is free software: you can redistribute it and/or modify
  14.     it under the terms of the GNU Lesser General Public License as published by
  15.     the Free Software Foundation, either version 3 of the License, or
  16.     (at your option) any later version.
  17.  
  18.     TZipMaster is distributed in the hope that it will be useful,
  19.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.     GNU Lesser General Public License for more details.
  22.  
  23.     You should have received a copy of the GNU Lesser General Public License
  24.     along with TZipMaster.  If not, see <http://www.gnu.org/licenses/>.
  25.  
  26.     contact: problems@delphizip.org (include ZipMaster in the subject).
  27.     updates: http://www.delphizip.org
  28.     DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip
  29. ************************************************************************/
  30.  
  31. //---------------------------------------------------------------------------
  32.  
  33. // arg = arg / divisor , returns remainder
  34. unsigned  DivMod64(unsigned __int64& arg, unsigned divisor)
  35. {
  36.     asm
  37.     {
  38.         mov ecx, [ebp + 8]  // arg
  39.         mov eax, [ebp + 12] // divisor
  40.         or eax, eax
  41.         jnz @@ok
  42.                 // / 0   _ return 0, 0 _ not correct but safer
  43.         mov [ecx + 4] ,eax  // arg hi
  44.         mov [ecx + 0] ,eax  // arg lo
  45.         jmp @@done
  46.     @@ok:
  47.         xor edx, edx
  48.         mov eax, [ecx + 4]  // arg hi
  49.         or eax, eax         // zero?
  50.         jz @@nohi
  51.         div dword ptr [ebp + 12]
  52.     @@nohi:
  53.         mov [ecx + 4], eax  // quot hi
  54.         mov eax, [ecx]      // _dividend[0]
  55.         div dword ptr [ebp + 12]
  56.         mov [ecx], eax      // quot lo
  57.         mov eax, edx        // remainder
  58.     @@done:
  59.     }
  60. #pragma warn -rvl
  61. #pragma warn -par
  62. }
  63.