flat assembler
Message board for the users of flat assembler.

Index > Windows > 32 bit code to 64 bit code

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog 20 Oct 2013, 16:27
this just does not make sense it still crashes and if i put that messagebox in front of the call statement it does not crash but shows and empty textbox.

I also found this console program but it crashes also

Code:
 sub rsp, 40 ; shadow space + stack alignment
    lea rcx, [infmt]
    lea rdx, [op1]
    call scanf
    lea rcx, [infmt]
    lea rdx, [op2]
    call scanf
    fld dword [op1]
    fld dword [op2]
    fmulp
    fstp qword [result]
    lea rcx, [outfmt]
    movsd xmm1, [result]
    mov rdx, [result]
    call printf
    add rsp, 40
    xor eax, eax  
    


maybe I put it together wrong?
here is the full console program I tried to test this on

Code:
format  PE64 console 4.0

entry   start

include 'C:\Users\Administrator\Programs\assembly\Fasm\INCLUDE\win64ax.inc'

section '.data' data readable writeable

       op1: dd 0
op2: dd 0
result: dq 0
infmt: db "%f", 0
outfmt: db "%.16lf", 0


section '.code' code readable executable

        start:
               sub rsp, 40 ; shadow space + stack alignment
    lea rcx, [infmt]
    lea rdx, [op1]
    call sscanf
    lea rcx, [infmt]
    lea rdx, [op2]
    call sscanf
    fld dword [op1]
    fld dword [op2]
    fmulp
    fstp qword [result]
    lea rcx, [outfmt]
    movsd xmm1, [result]
    mov rdx, [result]
    call printf
    add rsp, 40
    xor eax, eax

                invoke  ExitProcess, 0


section '.idata' import data readable

        library kernel32, 'kernel32.dll',\
                msvcrt, 'msvcrt.dll'

        import  kernel32,\
                ExitProcess, 'ExitProcess'

        import  msvcrt,\
                printf, 'printf',\
                sscanf,"sscanf",\
                scanf,"scanf"    
    


thanks for all the help
Post 20 Oct 2013, 16:27
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 20 Oct 2013, 17:32
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 19:41; edited 1 time in total
Post 20 Oct 2013, 17:32
View user's profile Send private message Reply with quote
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog 20 Oct 2013, 19:37
I think it will work but can you tell me the equivalent of the printf line so I can use it in a GUI program

is it wsprintfA or is it sscanf or what and how do I use it

I tried this

Code:

mov dword[bufferf1],21.0
mov dword[bufferf2],2.0
 movsd    xmm0,[bufferf1]
      divsd    xmm0,[bufferf2]
      movsd    [bufferf3],xmm0
      cinvoke  sprintf,str0,"%0.16lf",qword [bufferf3]
      ;cinvoke  printf,str0,sfmt
    ; cinvoke  wsprintfA,str0, "%s"
     ; xor      rcx,rcx
invoke SetDlgItemTextA,[hwnd],resultlengthxtextbox,addr str0 

    


and it gives me that range between .85 and 1.5 again

thanks


Last edited by patchariadog on 20 Oct 2013, 19:46; edited 1 time in total
Post 20 Oct 2013, 19:37
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 20 Oct 2013, 19:44
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 19:41; edited 3 times in total
Post 20 Oct 2013, 19:44
View user's profile Send private message Reply with quote
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog 20 Oct 2013, 19:53
okay so this is what I tried and it is still doing the .95 thing

Code:
 invoke GetDlgItemTextA, [hwnd], resultlengthxpixelstextbox, bufferbuffer1, 100
cinvoke sscanf, bufferbuffer1, "%f", op1

;read in MeasuredlengthXinpixelstextbox

invoke GetDlgItemTextA, [hwnd], measuredlengthxpixelstextbox, bufferbuffer2, 100
cinvoke sscanf, bufferbuffer2, "%f", op2
 movsd    xmm0,[op1]
      divsd    xmm0,[op2]
      movsd    [result],xmm0
      cinvoke  sprintf,str0,fmt0,qword [result]

invoke SetDlgItemTextA,[hwnd],resultlengthxtextbox,addr str0
    


data

Code:
bufferbuffer1 dq ? 
bufferbuffer2 dq ?

op1:    dq ?
op2:    dq ?
result: dq $0000000000000000
align 8
fmt0:   db '%0.5lf',$00
align 8
sfmt:   db '%s',$00
align 8
str0:   db 256 dup($00)     
    
Post 20 Oct 2013, 19:53
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 20 Oct 2013, 20:02
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 19:41; edited 1 time in total
Post 20 Oct 2013, 20:02
View user's profile Send private message Reply with quote
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog 20 Oct 2013, 20:12
I am even more confused now. could you please show how to fix it. sorry for bothering you
Post 20 Oct 2013, 20:12
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 20 Oct 2013, 20:17
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 19:40; edited 1 time in total
Post 20 Oct 2013, 20:17
View user's profile Send private message Reply with quote
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog 20 Oct 2013, 20:20
like I will type in 300 in the textbox and then 110.2 in the text box and it will also say the answer is between .95154 and 1.59848 instead of 2.72

for example the answer to the numbers above is .98 instead of 2.72
Post 20 Oct 2013, 20:20
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 20 Oct 2013, 20:29
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 19:40; edited 1 time in total
Post 20 Oct 2013, 20:29
View user's profile Send private message Reply with quote
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog 20 Oct 2013, 20:36
yeah! that works
thanks for helping me over these past few days with that
Post 20 Oct 2013, 20:36
View user's profile Send private message Reply with quote
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog 21 Oct 2013, 15:49
oh 1 more quick question. I was playing around with the calculations and I noticed that if you use xmm registers it only gives correct precision to 15 decimal places and if you use the fpu it only gives it to 7

for example 159/200*5.5
real answer = 4.3725
xmm answer = 4.37250000000000050000

I am okay with it showing a bunch of zeros because I could write a function to check and delete them.
although why does the computer put that extra 5 in their

thanks
Post 21 Oct 2013, 15:49
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 21 Oct 2013, 16:13
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 19:40; edited 1 time in total
Post 21 Oct 2013, 16:13
View user's profile Send private message Reply with quote
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog 22 Oct 2013, 02:35
Oh OK is it hard to change the data type to a larger data type? Do I just change the DQ to whatever is larger then a DQ or do I have to make major changes to the xmm code and the fpu code? Thanks
Post 22 Oct 2013, 02:35
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

< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.