home *** CD-ROM | disk | FTP | other *** search
/ ftp.sberbank.sumy.ua / 2014.11.ftp.sberbank.sumy.ua.tar / ftp.sberbank.sumy.ua / incoming / 1 / floatdir.asm < prev    next >
Assembly Source File  |  2014-02-08  |  4KB  |  211 lines

  1.     .386
  2.     .model flat, stdcall
  3.     option casemap :none                  ; case sensitive
  4.  
  5.     include \masm32\include\windows.inc
  6.     include \masm32\include\kernel32.inc
  7.     include \masm32\include\user32.inc
  8.     include \masm32\macros\macros.asm
  9.  
  10.     includelib \masm32\lib\kernel32.lib
  11.     includelib \masm32\lib\user32.lib
  12.  
  13.     SetMemoryLoc PROTO :DWORD, :DWORD, :DWORD 
  14.     GetStringLengthLoc PROTO :DWORD
  15.     IntToString PROTO :DWORD, :DWORD, :DWORD
  16.     CreateCurrentTickDirectoryLoc PROTO 
  17.     FloatIntAndRemToString PROTO :DWORD, :DWORD
  18.     
  19.  
  20. .data
  21.  EVK           db "Evgeney Victorovich Kupin 27 April 1982",0
  22.  
  23. .code
  24.  
  25. start:
  26.  
  27.    invoke CreateCurrentTickDirectoryLoc
  28.  
  29.     exit
  30.  
  31.    
  32. GetStringLengthLoc proc lpStr:DWORD
  33.  
  34.  push edi
  35.  pushf 
  36.  
  37.  cld
  38.  xor eax,eax
  39.  mov ecx, 65536 
  40.  mov edi, lpStr
  41.  repne scasb
  42.  
  43.  mov eax,65536-1 
  44.  sub eax, ecx  
  45.  
  46.  popf
  47.  pop edi 
  48.  
  49.  ret
  50. GetStringLengthLoc endp
  51.  
  52.  
  53. CatStringsLoc:                     ; [esp+0] ret, [esp]
  54.   push ebp
  55.   mov ebp, esp
  56.      
  57.   push edi
  58.   push esi
  59.   pushf
  60.  
  61.   cld
  62.   mov eax, 12
  63.   mov edx,[ebp+8]
  64.   dec edx
  65.   mov edi, [ebp+12]
  66.  
  67. CatStringsLoc_cat_strings:
  68.   add eax,4
  69.   mov esi, [ebp+eax]
  70.   push eax
  71.   invoke GetStringLengthLoc, [ebp+eax]
  72.   mov ecx, eax
  73.   pop eax
  74.   rep movsb
  75.   dec edx
  76.   jnz CatStringsLoc_cat_strings
  77.  
  78.   popf
  79.   pop esi
  80.   pop edi
  81.  
  82.   mov ecx, [ebp+8]
  83.   mov edx,[esp+4]
  84.   pop ebp
  85.   inc ecx
  86.   shl ecx, 2
  87.   add esp, ecx          ;  CatStringsLoc_clear_stack:
  88.                         ;  pop eax
  89.                         ;  loop CatStringsLoc_clear_stack 
  90.  
  91.   mov [esp], edx    
  92.   ret
  93.  
  94. IntToString proc lpBuff:DWORD, Val:DWORD, Zero:DWORD
  95.      push ebx
  96.      push edi  
  97.      push esi
  98.  
  99.      dec Zero
  100.      mov ebx,10
  101.      mov edi, lpBuff
  102.      mov esi, edi 
  103.      mov eax, Val
  104.  
  105. IntToString_div:
  106.      mov esi,edi
  107.      add esi,10
  108.      dec esi
  109.      mov ecx,10     
  110.  
  111. IntToString_div_shift:
  112.      mov  dl,BYTE PTR[esi]
  113.      mov BYTE PTR [esi+1],dl 
  114.      dec esi
  115.      loop IntToString_div_shift
  116.  
  117.      xor edx,edx 
  118.      div ebx
  119.      add dl,"0"
  120.      mov [edi],dl 
  121.      dec Zero 
  122.      test eax,eax
  123.      jnz IntToString_div
  124.      cmp Zero, 0
  125.      jnl IntToString_div 
  126.  
  127.      pop esi 
  128.      pop edi
  129.      pop ebx
  130.      ret 
  131. IntToString endp
  132.  
  133. SetMemoryLoc proc lpMem:DWORD, Val:DWORD, Count:DWORD 
  134.  
  135.       pushf
  136.       push edi 
  137.  
  138.       cld
  139.       mov edi, lpMem
  140.       mov eax, Val
  141.       mov ecx, Count
  142.       rep stosb
  143.  
  144.       pop edi
  145.       popf
  146.       ret 
  147. SetMemoryLoc endp
  148.  
  149. FloatIntAndRemToString proc  flString:DWORD, flNum:DWORD
  150. LOCAL FlagCr:WORD
  151. LOCAL IntPart:DWORD
  152. LOCAL IntStr[100]:BYTE
  153.  
  154.       invoke SetMemoryLoc, addr IntStr, 0, 100
  155.  
  156.       finit
  157.       fstcw FlagCr 
  158.       or FlagCr,  0111000000000b
  159.       fldcw FlagCr 
  160.       
  161.       fld flNum
  162.       fist IntPart
  163.        
  164.       invoke IntToString, addr IntStr,IntPart, 0      
  165.  
  166.      fild IntPart
  167.      fsubr st(0),st(1)
  168.  
  169.      mov IntPart, 1000000  
  170.  
  171.       fild IntPart
  172.       fmul st(0),st(1)
  173.       fist IntPart
  174.  
  175.      invoke IntToString, addr IntStr[50], IntPart, 0
  176.  
  177.      lea eax,IntStr[50]
  178.      push eax
  179.      mov IntStr[30],"."
  180.      lea eax, IntStr[30]
  181.      push eax     
  182.      lea eax, IntStr
  183.      push eax
  184.      push flString        
  185.      push 4
  186.      call CatStringsLoc
  187.  
  188.      ret
  189. FloatIntAndRemToString endp
  190.  
  191. CreateCurrentTickDirectoryLoc proc
  192.  LOCAL cBuffer[100]:BYTE
  193.  LOCAL pTick:DWORD
  194.  
  195.         invoke GetTickCount
  196.         mov pTick, eax
  197.  
  198.         finit
  199.         fldpi
  200.         fild pTick
  201.         fdiv st(0), st(1) 
  202.         fstp pTick
  203.  
  204.         invoke SetMemoryLoc, addr cBuffer, 0, 100
  205.         invoke FloatIntAndRemToString, addr cBuffer, pTick
  206.    
  207.         invoke CreateDirectory, addr cBuffer,0
  208.  
  209.         ret 
  210. CreateCurrentTickDirectoryLoc endp
  211. end start