flat assembler
Message board for the users of flat assembler.

Index > Main > Where to start?

Goto page Previous  1, 2, 3, 4, 5, 6, 7
Author
Thread Post new topic Reply to topic
Inagawa



Joined: 24 Mar 2012
Posts: 153
Inagawa
I know, but I am outputting it with wsprintf, which should be able to interpret the format, no? Could you give me one line of code showing how you would output the floating point variable?
Post 05 May 2012, 12:42
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
Inagawa wrote:
I know, but I am outputting it with wsprintf, which should be able to interpret the format, no?
wsprintf cannot print FP numbers. Read the spec for the wsprintf format string, there is no FP format selection.
Inagawa wrote:
Could you give me one line of code showing how you would output the floating point variable?
If you link to MSVCRT and import printf then you can use the C formatting library to read and print the FP number.
Post 05 May 2012, 12:48
View user's profile Send private message Visit poster's website Reply with quote
Inagawa



Joined: 24 Mar 2012
Posts: 153
Inagawa
I see, I forgot I haven't actually asked about outputting 64bit floats, only 64bit. I'll try to figure it out. Thanks for the clue
Post 05 May 2012, 12:51
View user's profile Send private message Reply with quote
Inagawa



Joined: 24 Mar 2012
Posts: 153
Inagawa
I've got to ask, what do you mean by "the C formatting library"? I never used C, so if I had to guess, it means a library of a certain implementation of functions like printf, etc.

With that in mind, I have no damn clue as to what's the problem!

cinvoke printf, <'%g '>, DWORD[__TimeMicro] prints out 5.40652e-315. But the number already has to be in the right format, since I FSTP-ed it as a float. Is there some formatting function I need to call first?
Post 05 May 2012, 13:16
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
Inagawa wrote:
cinvoke printf, <'%g '>, DWORD[__TimeMicro] prints out 5.40652e-315. But the number already has to be in the right format, since I FSTP-ed it as a float. Is there some formatting function I need to call first?
How did you load the number into the FPU the first place? Show us your code please.

edit to add: Read the spec for the %g format. It expects a qword input. I can tell because it outputted a value that cannot be represented by a single precision float.
Post 05 May 2012, 13:20
View user's profile Send private message Visit poster's website Reply with quote
Inagawa



Joined: 24 Mar 2012
Posts: 153
Inagawa
I already did, it's in the previous posts

Code:
__Average                 dd 0
  __Frequency               dq 0 
  __TimeMicro               dq 0 
  __TimeBuffer              dq 0

  ;
  ; I have an FPU code like this
  ;
  finit
  fild         [__Average]
  fild         [__Frequency]
  mov          DWORD[__TimeMicro], 1000
  fild         DWORD[__TimeMicro]
  fdivp
  fdivp
  fstp         DWORD[__TimeMicro]
    


If I do fstp [__TimeMicro], then it outputs 3.81553e-315


Last edited by Inagawa on 05 May 2012, 13:29; edited 1 time in total
Post 05 May 2012, 13:24
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
So you divided by zero?

I suggest you start with something simpler:
Code:
testdp dq 12.34567890
cinvoke someprintfunction, ..., dword[testdp+0], dword[testdp+4], ...    
Post 05 May 2012, 13:28
View user's profile Send private message Visit poster's website Reply with quote
Inagawa



Joined: 24 Mar 2012
Posts: 153
Inagawa
Both __Average and __Frequency do have values. The code is too long to show it here. I simply "showcased" the data as being zero initialized. The ST0 at the end of my FPU code does contain a valid value of 11.4. I simply need to store and output it
Post 05 May 2012, 13:31
View user's profile Send private message Reply with quote
Inagawa



Joined: 24 Mar 2012
Posts: 153
Inagawa
And oddly enough, when I use this code:

Code:
cinvoke      printf, <'%f %f'>, DWORD[__TimeMicro], DWORD[__TimeMicro+4]    


I get an output, which is "11.597398 0.000000". So the float is there, I just have no idea what I'm doing wrong here..

And before you say "Why don't you just do cinvoke printf, <'%f'>, DWORD[__TimeMicro]?" It's because if I do, then I get 0.000000..
Post 05 May 2012, 13:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
Inagawa wrote:
I just have no idea what I'm doing wrong here..
Yeah, nor do we. Without seeing your code we really have no idea what you have done.
Post 05 May 2012, 14:04
View user's profile Send private message Visit poster's website Reply with quote
Inagawa



Joined: 24 Mar 2012
Posts: 153
Inagawa
You can see the whole code in the section Macroinstructions -> PerformanceCounter. Please download it and look at what's wrong there
Post 05 May 2012, 14:28
View user's profile Send private message Reply with quote
dancho



Joined: 06 Mar 2011
Posts: 74
dancho
.data
__TimeMicro dq 11.4
fmt db '%g',0

.code
cinvoke printf,fmt,dword[__TimeMicro],dword[__TimeMicro+4]

/* stdout */

11.4

c reference for printf family :
http://en.cppreference.com/w/c/io/fprintf
Post 05 May 2012, 20:01
View user's profile Send private message Reply with quote
Inagawa



Joined: 24 Mar 2012
Posts: 153
Inagawa
I swear on my life that I have tried this EXACT code and it just didn't work. It suddenly works flawlessly now. This makes me doubt my sanity.. Thanks a lot

This is the worst kind of victory though, I don't have the slightest clue how it got fixed...
Post 05 May 2012, 20:59
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5, 6, 7

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.