invalid use of register 'frame'

General FreeBASIC programming questions.
Post Reply
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

invalid use of register 'frame'

Post by srvaldez »

there's an anomaly somewhere, the following code generates invalid use of register 'frame' error when using FB with gcc 7.3.0 or gcc 8.1.0 or gcc 8.2.1, it's ok with gcc 4.8.2
G:\WinFBE_Suite\FreeBASIC-1.06.0\fbc64 -w all -asm intel -gen gcc -Wc -O2 -v "%f"

Code: Select all

type clongdouble
	__(0 to 1) as ulongint
end type

function pild() as clongdouble
	dim as clongdouble result
	asm
		fldpi
		fstp	tbyte ptr [result]
	end asm
	function = result
end function

dim as clongdouble x, y, z

x=pild()
print hex(x.__(0)), hex(x.__(1))
however, when using -asm att on the equivalent code, it compiles and runs ok when using the afore mentioned versions of gcc
G:\WinFBE_Suite\FreeBASIC-1.06.0\fbc64 -w all -asm att -gen gcc -Wc -O2 -v "%f"

Code: Select all

type clongdouble
	__(0 to 1) as ulongint
end type

function pild() as clongdouble
   dim as clongdouble result
      asm
         "fldpi                 \n" _ 
         "fstpt   %[RESULT$1]            \n" _ 
         :[result]"=m"(result) _
         : _
         :
      end asm
   function = result
end function

dim as clongdouble x, y, z

x=pild()
print hex(x.__(0)), hex(x.__(1))
so I suspect that there's bug in fbc, when translating intel asm to gcc inline asm
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: invalid use of register 'frame'

Post by D.J.Peters »

result isn't a pointer address

I wrote a complete 10 byte double class for FreeBASIC including the print command
but can't find it anymore here on the forum :-(

Joshy

Code: Select all

type clongdouble
  as ulongint hi,lo
end type

function pild() as clongdouble
   dim as clongdouble result
   var p = @result.hi
   asm
      fldpi
      fstp   tbyte ptr [p]
   end asm
   function = result
end function
or

Code: Select all

type clongdouble
  as ubyte fields(9)
end type

function pild() as clongdouble
   dim as clongdouble result
   var p = @result.fields(0)
   asm
      fldpi
      fstp   tbyte ptr [p]
   end asm
   function = result
end function
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: invalid use of register 'frame'

Post by srvaldez »

hello D.J.Peters
your solution looks strange to me :-)
I think I will use at&t asm instead.

one pleasant thing I found out is that most of gcc's long double function can be wrapped very thinly, except for the input/output
for example, the trig and exp functions can be coded in a single asm jump when coding in WinFBx64
WinFBx86 is a different story

Code: Select all

sub sqrtld naked cdecl(byref result as clongdouble, byref c as clongdouble)
	asm
		"jmp sqrtl"
	end asm
end sub
you do need the naked sub to have access to the right registers
sancho3
Posts: 358
Joined: Sep 30, 2017 3:22

Re: invalid use of register 'frame'

Post by sancho3 »

D.J.Peters wrote:I wrote a complete 10 byte double class for FreeBASIC including the print command
but can't find it anymore here on the forum :-(
Is this it?
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: invalid use of register 'frame'

Post by D.J.Peters »

@sancho3 thank you for the link this is an older version
but better than nothing :-)

I don't know where the FreeBASIC post are gone.

Joshy
Post Reply