Can anyone convert this code to PureBasic so I can benchmark to see the difference.
Dim x As Double
Dim y As Double
Dim i As Long
Dim t As Single
x = 1
y = 1.000001
t = Timer
For i = 1 To 100000000
x = x * y
Next
t = Timer - t
Print " X= "; x
Print " Temps d'execution :", Round(t, 2) & " Sec"
Convert PB code to asm
Re: Convert PB code to asm
I'm not sure what you are asking.
Converting the code to PB would be something like this
but you are asking a question in the ASM forum.
Do you want the multiplication loop to be ASM ?
Converting the code to PB would be something like this
Code: Select all
x.d = 1
y.d = 1.000001
t.l = ElapsedMilliseconds()
For i.l = 1 To 100000000
x * y
Next
t = ElapsedMilliseconds() - t
Msg.s = "X= " + StrD(x) + #CRLF$
Msg + "Temps d'execution :" + StrD(t / 1000, 2) + " Sec"
MessageRequester("", Msg)
Do you want the multiplication loop to be ASM ?
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
-
- Enthusiast
- Posts: 346
- Joined: Thu Jul 02, 2009 5:42 am
Re: Convert PB code to asm
Wilbert, yes would like it to be asm
Re: Convert PB code to asm
You can also look at PB's asm output?
Code: Select all
fn$ = "c:\your-proj\yourfilename.pb"
Compiler = RunProgram(#PB_Compiler_Home + "compilers\pbcompiler", fn$ + " /commented", #NULL$, #PB_Program_Read | #PB_Program_Open)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: Convert PB code to asm
This is using x87.
It's also possible using the SSE2 instruction MULSD.
The results are slightly different because the FPU uses 80 bits internally while SSE2 uses 64 bits.
Code: Select all
x.d = 1
y.d = 1.000001
t.l = ElapsedMilliseconds()
!fld qword [v_y]
!fld qword [v_x]
!mov ecx, 100000000
!mulx_loop:
!fmul st0, st1
!dec ecx
!jnz mulx_loop
!fstp qword [v_x]
!fstp st0
t = ElapsedMilliseconds() - t
Msg.s = "X= " + StrD(x) + #CRLF$
Msg + "Temps d'execution :" + StrD(t / 1000, 2) + " Sec"
MessageRequester("", Msg)
Code: Select all
x.d = 1
y.d = 1.000001
t.l = ElapsedMilliseconds()
!movsd xmm0, [v_x]
!movsd xmm1, [v_y]
!mov ecx, 100000000
!mulx_loop:
!mulsd xmm0, xmm1
!dec ecx
!jnz mulx_loop
!movsd [v_x], xmm0
t = ElapsedMilliseconds() - t
Msg.s = "X= " + StrD(x) + #CRLF$
Msg + "Temps d'execution :" + StrD(t / 1000, 2) + " Sec"
MessageRequester("", Msg)
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Convert PB code to asm
It's possible to get purebasic's assembler output if you compile using command line compiler with the /commented option.
-
- Enthusiast
- Posts: 346
- Joined: Thu Jul 02, 2009 5:42 am
Re: Convert PB code to asm
Thank you Wilbert