Gas64 (no more use of gcc, only gas) WDS / LNX
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
@hhr
There is not any problem on my side.
Is it a compile time error ? in this case what error ?
Or a runtime problem ?
That issue could be already fixed after your report viewtopic.php?p=292633#p292633
Unfortunately daily builds are off since june 6th however I can put a link to my own version.
Try by declaring impulsex/impulsey double instead single.
There is not any problem on my side.
Is it a compile time error ? in this case what error ?
Or a runtime problem ?
That issue could be already fixed after your report viewtopic.php?p=292633#p292633
Unfortunately daily builds are off since june 6th however I can put a link to my own version.
Try by declaring impulsex/impulsey double instead single.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
@SARG
Declaring impulsex/impulsey double instead single solved the problem. Now I will wait for the next daily build. Thank you for the answer and for gas64.
PS: I tested with FB-1.09.0 and forgot to test with the latest available daily build. There is no error, please excuse my mistake.
Declaring impulsex/impulsey double instead single solved the problem. Now I will wait for the next daily build. Thank you for the answer and for gas64.
PS: I tested with FB-1.09.0 and forgot to test with the latest available daily build. There is no error, please excuse my mistake.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
We can download a new daily build and I tested Everlift with it. https://users.freebasic-portal.de/stw/builds/.
For gas64 I changed Double to Single in Line 79.
Is this a bug in gas64? We should help to make gas64 better and better, but I do not want to be hasty.
For gas64 I changed Double to Single in Line 79.
Is this a bug in gas64? We should help to make gas64 better and better, but I do not want to be hasty.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
You are correct hhr.
The angle has to be single
using double compiles OK but doesn't run.
I'll try and isolate the problem.
Thanks.
The angle has to be single
using double compiles OK but doesn't run.
I'll try and isolate the problem.
Thanks.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
The bug in -gen gas64 seems to be around the sin function.
If the crt sin is used then it is OK.
(using build fbc_win64_mingw_0794_2022-06-20)
If the crt sin is used then it is OK.
Code: Select all
#cmdline "-gen gas64"
#define usecrt '<<------------------- comment out the whole line
declare function sin_ cdecl lib "msvcrt" alias "sin"(as double) as double
Type V2
As Single x,y
End Type
Function drawline(x As Long,y As Long,angle As double,length As double,flag As Long=0) As v2
angle=angle*.0174532925199433
Dim As Single x2=x+length*Cos(angle)
#ifdef usecrt
Dim As Single y2=y-length*Sin_(angle)
#else
Dim As Single y2=y-length*Sin(angle)
#endif
Return Type(x2,y2)
End Function
screen 19,32
dim as single a
dim as double l=200
for a=0 to 360 step 1
dim as v2 p=drawline(400,300,a,l)
line(400,300)-(p.x,p.y),rgb(200,0,0)
if abs(sqr((400-p.x)^2+(300-p.y)^2)-l)>.1 then print a,abs(sqr((400-p.x)^2+(300-p.y)^2)-l)
next a
print "OK"
sleep
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
Sorry guys, no problem on my side with both codes.
What should I get/see ?
edit : no problem with my own version but there is an issue with the daily build version.
edit bis : there is a problem of compatibily with libs.
Compiling with lastest fbc.exe (daily build) and the libs from 1.09 --> no problem
I'll try to find with what version the problem begins.
What should I get/see ?
edit : no problem with my own version but there is an issue with the daily build version.
edit bis : there is a problem of compatibily with libs.
Compiling with lastest fbc.exe (daily build) and the libs from 1.09 --> no problem
I'll try to find with what version the problem begins.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
it took more than 2 hours for finding an explanation. Thanks asm debugger.
Daily builds don't use the same libs as provided by fbc 1.09 :
- daily build, cos/sin functions are called in the OS (Windows)
- regular 1.09, it's the lib from gcc AFAIK
Now the real problem, when calling cos and sin these functions, of OS, write into the area of reserved stack for drawline and unfortunately crush x2 value stored in this area.
First instructions of the functions :
It seems weird ..... Any opinion/help is welcome.
@dodicat
Using sin from crt avoid the call to the other 'problematic' function so the value is not crushed.
Daily builds don't use the same libs as provided by fbc 1.09 :
- daily build, cos/sin functions are called in the OS (Windows)
- regular 1.09, it's the lib from gcc AFAIK
Now the real problem, when calling cos and sin these functions, of OS, write into the area of reserved stack for drawline and unfortunately crush x2 value stored in this area.
First instructions of the functions :
Code: Select all
push rbx
sub rsp,70
mov rax,7FFFFFFFFFFFFFFF
movaps xmmword ptr ss:[rsp+60],xmm6
movsd qword ptr ss:[rsp+88],xmm0 <------ rsp is decremented by 70 but adding 88 it's beyond its reserved stack.
@dodicat
Using sin from crt avoid the call to the other 'problematic' function so the value is not crushed.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
It's spilling the parameter into the home area/shadow store.
https://docs.microsoft.com/en-us/cpp/bu ... w=msvc-170
There's a diagram herehttps://docs.microsoft.com/en-us/cpp/bu ... w=msvc-170
The caller is responsible for allocating space for the callee's parameters. The caller must always allocate sufficient space to store four register parameters, even if the callee doesn't take that many parameters
https://docs.microsoft.com/en-us/cpp/bu ... w=msvc-170
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
Why just the bare 7FFFFFFFFFFFFFFF
(mov rax,7FFFFFFFFFFFFFFF )
Shouldn't there be 0x prefixed?
mov rax, 0x7FFFFFFFFFFFFFFF
Or is this the correct result of your own debug program.
(mov rax,7FFFFFFFFFFFFFFF )
Shouldn't there be 0x prefixed?
mov rax, 0x7FFFFFFFFFFFFFFF
Or is this the correct result of your own debug program.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
@adeyblue
I know all that (I printed these pages some years ago) otherwise how gas64 could work. However you put me on the track, thanks.
In gas64 Cos, Sin and few other functions are called in a different way and no space is reserved for parameters on the stack (bad forgetting) if there is no other calls. Then 'obviously' the area used by sin/cos functions to save xmm0 is wrong.
By chance until now that did not cause any problem.
I'll fixed that quickly.
@dodicat
That's just a copy of what is displayed by the debugger (x64dbg, very powerful).
I know all that (I printed these pages some years ago) otherwise how gas64 could work. However you put me on the track, thanks.
In gas64 Cos, Sin and few other functions are called in a different way and no space is reserved for parameters on the stack (bad forgetting) if there is no other calls. Then 'obviously' the area used by sin/cos functions to save xmm0 is wrong.
By chance until now that did not cause any problem.
I'll fixed that quickly.
@dodicat
That's just a copy of what is displayed by the debugger (x64dbg, very powerful).
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
Thanks for fixing that SARG, and hhr for finding the bug in the first place.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
@dodicat
Easy fix (3 lines added including a test....) yesterday night, will be pushed this afternoon. After it'll depend of Jeff.
@dodicat, hhr, adeyblue
Thanks for your help.
Easy fix (3 lines added including a test....) yesterday night, will be pushed this afternoon. After it'll depend of Jeff.
@dodicat, hhr, adeyblue
Thanks for your help.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Ever lift.
@dodicat from my raytracer stuff NanoMeter2RGB() with gamma corecture.
The calculation of gamma factor isn't from me (but can't remember the source) it comes from the visible spectrum of 380-780 nm !
EDIT: found the javascript source code at: https://www.johndcook.com/wavelength_to_RGB.html is inside the HTML code.
one more: https://codepen.io/pen?&editors=011 look in the right pane at: nmToRGB:
Joshy
The calculation of gamma factor isn't from me (but can't remember the source) it comes from the visible spectrum of 380-780 nm !
EDIT: found the javascript source code at: https://www.johndcook.com/wavelength_to_RGB.html is inside the HTML code.
one more: https://codepen.io/pen?&editors=011 look in the right pane at: nmToRGB:
Joshy
Code: Select all
function NanoMeter2RGB(byval nm as single) as ulong
dim as single r,g,b,factor
if nm<380.0f then
nm=380.0f
elseif nm>780.0f then
nm=780.0f
endif
if nm < 440.0f then ' 380-440
r =-(nm - 440.0f) / 60.0f : b = 1.0f
elseif nm >= 440.0f andalso nm < 490.0f then
g = (nm - 440.0f) / 50.0f : b = 1.0f
elseif nm >= 490.0f andalso nm < 510.0f then
b = -(nm - 510.0f) / 20.0f : g = 1.0f
elseif nm >= 510.0f andalso nm < 580.0f then
r = (nm - 510.0f) / 70.0f : g = 1.0f
elseif nm >= 580.0f andalso nm < 645.0f then
g = -(nm - 645.0f) / 65.0f : r = 1.0f
elseif nm >= 645.0f then ' 645-780
r = 1.0f
endif
if nm < 420.0f then
factor = 0.3f + 0.7f*(nm - 380.0f) / 40.0f
elseif nm >= 420.0f andalso nm < 701.0f then
factor = 1.0f
elseif nm >= 701.0f then
factor = 0.3f + 0.7f*(780.0f - nm) / 80.0f
endif
const GAMMA as single = 0.8f
r = iif(r > 0.0f,255.0f*((r*factor)^GAMMA),0.0f)
g = iif(g > 0.0f,255.0f*((g*factor)^GAMMA),0.0f)
b = iif(b > 0.0f,255.0f*((b*factor)^GAMMA),0.0f)
return RGB(r,g,b)
end function
screenres 400,64,32
for x as single=0 to 400
' 380-780 nanometer
var colour=NanoMeter2RGB(380.0f+x)
line (x,0)-step(0,63),colour
next
sleep
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
Thanks D.j.Peters.
Bluatigro posted a rainbow colour function a while back.
Here I compare yours and his.
Although the colours in both blend nicely, the ulong values are not linear, so I created a false linearity with a spline for red, green and blue in my ever lift.
This should work with -gen gas64 after SARG's mose recent update.(The map function to test)
Bluatigro posted a rainbow colour function a while back.
Here I compare yours and his.
Although the colours in both blend nicely, the ulong values are not linear, so I created a false linearity with a spline for red, green and blue in my ever lift.
Code: Select all
'#cmdline "-gen gas64"
function NanoMeter2RGB(byval nm as single) as ulong
dim as single r,g,b,factor
if nm<380.0f then
nm=380.0f
elseif nm>780.0f then
nm=780.0f
endif
if nm < 440.0f then ' 380-440
r =-(nm - 440.0f) / 60.0f : b = 1.0f
elseif nm >= 440.0f andalso nm < 490.0f then
g = (nm - 440.0f) / 50.0f : b = 1.0f
elseif nm >= 490.0f andalso nm < 510.0f then
b = -(nm - 510.0f) / 20.0f : g = 1.0f
elseif nm >= 510.0f andalso nm < 580.0f then
r = (nm - 510.0f) / 70.0f : g = 1.0f
elseif nm >= 580.0f andalso nm < 645.0f then
g = -(nm - 645.0f) / 65.0f : r = 1.0f
elseif nm >= 645.0f then ' 645-780
r = 1.0f
endif
if nm < 420.0f then
factor = 0.3f + 0.7f*(nm - 380.0f) / 40.0f
elseif nm >= 420.0f andalso nm < 701.0f then
factor = 1.0f
elseif nm >= 701.0f then
factor = 0.3f + 0.7f*(780.0f - nm) / 80.0f
endif
const GAMMA as single = 0.8f
r = iif(r > 0.0f,255.0f*((r*factor)^GAMMA),0.0f)
g = iif(g > 0.0f,255.0f*((g*factor)^GAMMA),0.0f)
b = iif(b > 0.0f,255.0f*((b*factor)^GAMMA),0.0f)
return RGB(r,g,b)
end function
function rainbow( x as single ) as ulong 'idea from bluatigro
static as double pi=4*atn(1)
#define rad(n) (pi/180)*(n)
dim as ulong r , g , b
r = sin( rad( x ) ) * 127 + 128
g = sin( rad( x - 120 ) ) * 127 + 128
b = sin( rad( x + 120 ) ) * 127 + 128
return rgb( r and 255 , g and 255 , b and 255 )
end function
function map(a as double,b as double,x as double,c as double,d as double) as double
return ((d)-(c))*((x)-(a))/((b)-(a))+(c)
end function
screen 20,32
dim as ulong min=4294967294,max=0
dim as ulong colour
dim as double xpos,ypos
for k as long=1 to 2
for x as single=0 to 400 step .25
if k=1 then colour=NanoMeter2RGB(380.0+x) else colour=rainbow(380-x)
xpos=map(0,400,x,0,1024)
if k=1 then ypos=map(4278190335.0,4294967040.0,colour,50,500) else _
ypos=map(4278302408.0,4294920760.0,colour,50,500)
line(xpos,768)-(xpos,ypos),colour
if min>colour then min=colour
if max<colour then max=colour
next
if k=1 then print "D.J.Peters" else print "Bluatigro"
print "colours "; min;" to ";max
print "Press a key"
min=4294967294:max=0
sleep
cls
next
sleep