News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

c++ translate

Started by ragdog, February 04, 2008, 07:54:01 PM

Previous topic - Next topic

ragdog

hi

can your help PLEASE :'(

   
The download status calculated in kp> mb> gb

I understand fpu not so good


OnProgressProc proc PROC lpThis:DWORD, ulProgress:DWORD,ulProgressMax:DWORD,ulStatusCode:DWORD,szStatusText:DWORD
LOCAL lpAvailableBytes :DWORD
LOCAL lpTotalBytes:DWORD

.data
OneK REAL10 1024.0

.code
;; kb
      finit
  fld OneK
  fild ulProgress    
  fdiv ST(0),ST(1)
  fistp lpAvailableBytes
  fild ulProgressMax
  fdiv ST(0),ST(1)
  fistp  lpTotalBytes
;; mb

;; gb
invoke wsprintf, addr szStringBuff, chr$("%lu of %lu"),lpAvailableBytes, lpTotalBytes
invoke SendMessage, hTitle, WM_SETTEXT, 0, offset szStringBuff
ret
OnProgressProc endp


greets
ragdog

ToutEnMasm

#31
Problem with the translation of c++ code fpu is that c++ optimize theĀ  calcul in ways not very clear.
You can follow these steps to reach the goal.
- Understand well what the fpu calculate (make an algebric formula).
-Don't follow the disassembled code,rewrite it.
- Take care with the size of each operand and his type (instructions are not the same)
- Use a trick: Create a QWORD and use the fst instruction to store (without poping the stack) the contentĀ  of st(n).Debug it and have a look on this QWORD.
At each step of the calcul,verify that you have what you want,surprises are granted.
-Leave the FPU with nothing in the stack

ragdog

thanks ToutEnMasm :U

for the good information and help!!!!

my problem is solved my algo convert fom (byte>kb>mb>gb>tb) in fpu

best regards
ragdog