flat assembler
Message board for the users of flat assembler.
  
       
      Index
      > Main > how do I use FPUGoto page Previous 1, 2  | 
  
| Author | 
  | 
              
| 
                  
                   MHajduk 05 Sep 2013, 19:25 
                  Use sscanf to convert the obtained strings from the text format to the desired number format then store values in v1 and v2, should work. 
                  
                 | 
              |||
                  
  | 
              
| 
                  
                   patchariadog 05 Sep 2013, 19:37 
                  I tried this code but it just crashes
 
                  
                Code: invoke GetDlgItemTextA,[hWin],textbox1,addr v1,100 invoke GetDlgItemTextA,[hWin],textbox2,addr v2,100 cinvoke sscanf,[v8],"%s",addr v1 cinvoke sscanf,[v9],"%s",addr v2 ;rest of the code that works finit fld dword [v8] fld dword [v9] fdivp fstp qword [v3] cinvoke sprintf, addr v4, "%.16lf", dword [v3], dword [v3 + 4] invoke SetDlgItemTextA,[hWin],maximumoutputpowertext,addr v4 I made v8 and v9 dd I also tried change the %s to %f because I was not sure what to use but it crashes also  | 
              |||
                  
  | 
              
| 
                  
                   MHajduk 05 Sep 2013, 19:49 
                  patchariadog wrote: I tried this code but it just crashes Code: v8 rb 101 v9 rb 101 (...) invoke GetDlgItemTextA, [hWin], textbox1, v8, 100 invoke GetDlgItemTextA, [hWin], textbox2, v9, 100 cinvoke sscanf, v8, "%f", v1 cinvoke sscanf, v9, "%f", v2 finit fld dword [v1] fld dword [v2] (...)  | 
              |||
                  
  | 
              
| 
                  
                   patchariadog 05 Sep 2013, 20:03 
                  I changed v8 and v9 to rb 200
 
                  
                then I put this code in and did textbox1 = 10.1 textbox2 = 5.5 answer should be = 1.83636363636 I get = 519010387852.254564 Code: invoke GetDlgItemTextA, [hWin], textbox1, v8, 100 invoke GetDlgItemTextA, [hWin], textbox2, v9, 100 cinvoke sscanf, v8, "%s", v1 cinvoke sscanf, v9, "%s", v2 finit fld dword [v1] fld dword [v2] fdivp fstp qword [v3] cinvoke sprintf, addr v4, "%.16lf", dword [v3], dword [v3 + 4] invoke SetDlgItemTextA,[hWin],maximumoutputpowertext,addr v4 thanks for all the help  | 
              |||
                  
  | 
              
| 
                  
                   patchariadog 05 Sep 2013, 20:10 
                  sorry I somehow missed changing the %s to %f now it works thanks so much.
 
                  
                also on this line of the compare code you gave me Code: cinvoke sprintf, addr v4, "%.16lf", dword [v3], dword [v3 + 4] what does the dword [v3 + 4] do thanks  | 
              |||
                  
  | 
              
| 
                  
                   MHajduk 05 Sep 2013, 20:10 
                  The formatting strings should be "%f" not "%s" - you want to convert input  strings to single precision floating point numbers. 
                  
                 | 
              |||
                  
  | 
              
| 
                  
                   MHajduk 05 Sep 2013, 20:13 
                  patchariadog wrote: what does the dword [v3 + 4] do  | 
              |||
                  
  | 
              
| 
                  
                   patchariadog 05 Sep 2013, 20:28 
                  okay thanks for all your help today. I have been searching for how to use the fpu in fasm on and off for about 6 months now so thank you. 
                  
                 | 
              |||
                  
  | 
              
| 
                  
                   MHajduk 05 Sep 2013, 20:38 
                  patchariadog wrote: okay thanks for all your help today. I have been searching for how to use the fpu in fasm on and off for about 6 months now so thank you.  | 
              |||
                  
  | 
              
| 
                  
                   AsmGuru62 06 Sep 2013, 01:45 
                  Code: fld [v1] fld [v2] fcom This is same as: Code: cmp [v2], [v1] To do the opposite (cmp [v1],[v2]) you must load values in opposite order: Code: fld [v2] fld [v1] Also, you do not have to load the 2nd argument -- can save 1 FPU opcode by direct operation with memory argument: Code: v1 dq 45.9776 v2 dq 7.0594 v3 dq 0 ... fld [v1] fmul [v2] fstp [v3]  | 
              |||
                  
  | 
              
| 
                  
                   MHajduk 06 Sep 2013, 07:28 
                  AsmGuru62 wrote: 
 But maybe you meant something like a macro shorthand here.  | 
              |||
                  
  | 
              
| 
                  
                   AsmGuru62 06 Sep 2013, 13:08 
                  Yes, I meant it like a pseudocode, because the swapping of the arguments will mean the difference in flags. 
                  
                 | 
              |||
                  
  | 
              
| Goto page  Previous  1, 2 < Last Thread | Next Thread >  | 
    
Forum Rules: 
  | 
    
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.