Gas64 (no more use of gcc, only gas) WDS / LNX

User projects written in or related to FreeBASIC.
Post Reply
robert
Posts: 169
Joined: Aug 06, 2019 18:45

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by robert »

SARG wrote:Hi all,
Thank you for your feedback. The issue on variadic functions is almost fixed. Redim should work, it stays the cva_xx commands to be finished. No release for now.
robert wrote: I am interested in recompiling on Fedora to get rid of the ospeed warning. Please post the scripts or include them in your next update.
Put the 2 scripts with the source code files. Name the first one whatever you want (eg compil.sh) and the second one link.sh.
Then execute compil.sh. link.sh is called automatically. Scripts at the end of the post.

Notes :
- if you don't have ir_gas64.bas remove the related line in the first script and ir_gas64.o at the end of the second.
- no error checking, watch carefully the execution.
- The exe is named fbc_new rename it if necessary and copy where fbc is located.
Hi SARG:

Thank you for the scripts.

Compiled and linked on Fedora 31 with the latest FreeBASIC 1.08 source from Github. No problems. Copied fbc_new as fbc64_gas64 to the install directory, replacing your GAS64 compilation and am now testing examples. No more ospeed warnings. So far ... so good.

She's really faaaaaaaaaaast that GAS64.
Xusinboy Bekchanov
Posts: 782
Joined: Jul 26, 2018 18:28

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by Xusinboy Bekchanov »

SARG wrote:Hi all,
Xusinboy Bekchanov wrote:Windows version is normal. Today I checked again. Linux version 2 times faster compiled than the gcc version.
Not sure to understand , compilation with fbc64_gas64 (linux) is twice faster than with gcc ? The inverse of your previous post.
The previous test was based on one line example. Therefore, it so happened.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by D.J.Peters »

SARG thank you for the feedback

one more stupid question

where is or how do you get the address of a an UDT as a result of an operator ?
I mean does I need to allocate a new UDT copy the reult in it and return the pointer of the new UDT in eax,rax ?

something like this:

Code: Select all

type vec3 :  as single x,y,z : end type
operator +(l as vec3, r as vec3) as vec3
asm 
  ... this part is clear for me
 ' but where to copy the result to ?
end asm
end operator
SARG
Posts: 1755
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by SARG »

D.J.Peters wrote:one more stupid question
The sage said there is no stupid questions except the unasked. :-)
D.J.Peters wrote:where is or how do you get the address of a an UDT as a result of an operator ?
I mean does I need to allocate a new UDT copy the reult in it and return the pointer of the new UDT in eax,rax ?
An hidden parameter, in register rcx, contains a pointer to a variable of type vec3 defined in the calling procedure.
Your code should fill this variable using the pointer.
And just before the return rax is filled with this pointer (not always usefull it depends of following instructions).

EDIT : under Linux the register is obviously rdi.

The heavy commented asm code below is generated by fb64_gas64. By removing all the comments you get an example how to do.
Here the function is not 'naked'.

Code: Select all

Operator + ( ByRef lhs As Vec3, ByRef rhs As Vec3 ) As Vec3
  Return Type<Vec3>( lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z )
End operator

Code: Select all

# Info --> =============================================================================
# Info --> ===== Proc begin : _ZplR4VEC3S0_ / _ZplR4VEC3S0_ =====
# Info --> =============================================================================
   # Info --> registers released
   # Info --> hidden=13492176
   # Info --> [struct VEC3 ptr] _ZplR4VEC3S0_ ( 4VEC3* / [struct VEC3 ptr] Lt_0011.8$, [struct VEC3 ptr] LHS.9, [struct VEC3 ptr] RHS.10 ) proc shared public overloaded operator declared parsed procemitted operator.+ stdcall [struct VEC3] / Not accessed --> not used ??
   .text
   .globl _ZplR4VEC3S0_
_ZplR4VEC3S0_:
   # Info --> stk4=112 reserved space for saving registers when proc calls (eventually 112 more for variadic linux only)
   push rbp
   mov  rbp,rsp
   sub rsp, 112
   # Info --> paramvar=Lt_0011.8 real typ=[struct VEC3 ptr] symbgetlen=12
   # Info --> var local parambyref accessed declared implicit Lt_0011 [struct VEC3]
   # Info --> lgt=12 real=12
   mov QWORD PTR 16[rbp], rcx
   # Info --> paramvar=LHS.9 real typ=[struct VEC3 ptr] symbgetlen=12
   # Info --> var local parambyref declared LHS [struct VEC3]
   # Info --> lgt=12 real=12
   mov QWORD PTR 24[rbp], rdx
   # Info --> paramvar=RHS.10 real typ=[struct VEC3 ptr] symbgetlen=12
   # Info --> var local parambyref declared RHS [struct VEC3]
   # Info --> lgt=12 real=12
   mov QWORD PTR 32[rbp], r8
   .Lt_000F:
   # Info --> registers released
   # Info --> deref LHS.9+24 [struct VEC3 ptr]
   # Info --> v1=var LHS ofs=24 [struct VEC3 ptr] symbdump=var local parambyref accessed declared LHS [struct VEC3]
   # Info --> vr=reg 0 [single ptr]
   # Info --> virtual register =0 real register=r11
   # Info --> marked as used register=r11
   mov r11, 24[rbp]
   # Info --> vr type=0 / 4
   # Info --> deref RHS.10+32 [struct VEC3 ptr]
   # Info --> v1=var RHS ofs=32 [struct VEC3 ptr] symbdump=var local parambyref accessed declared RHS [struct VEC3]
   # Info --> vr=reg 1 [single ptr]
   # Info --> virtual register =1 real register=r10
   # Info --> marked as used register=r10
   mov r10, 32[rbp]
   # Info --> vr type=1 / 4
   # Info --> bop vr0 [single ptr] [single] + vr1 [single ptr] [single]
   # Info --> v1=ptr [single] vidx=<reg 0 [single ptr]>
   # Info --> v2=ptr [single] vidx=<reg 1 [single ptr]>
   # Info --> vr=reg 2 [single]
   # Info --> Vr<>0 op =>add
   # Info --> virtual register =0 real register=r11
   # Info --> virtual register =1 real register=r10
   # Info --> Bop with float
   # Info --> Release done for register=r11
   movss xmm0, 0[r11]
   # Info --> Release done for register=r10
   movss xmm1, 0[r10]
   addss xmm0, xmm1
   # Info --> marked as used register=r8
   movq r8, xmm0
   # Info --> in _setVregDataType v=var Lt_0011 ofs=16 [struct VEC3 ptr] symbdump=var local parambyref accessed declared implicit Lt_0011 [struct VEC3]
   # Info --> dtype/subtype=[single ptr]
   # Info --> dtype/subtype=[struct VEC3 ptr]
   # Info --> CONVERTING vr3 [single ptr] := Lt_0011.8+16 [struct VEC3 ptr]
   # Info --> v1=reg 3 [single ptr] xx 3
   # Info --> v2=var Lt_0011 ofs=16 [struct VEC3 ptr] symbdump=var local parambyref accessed declared implicit Lt_0011 [struct VEC3] xx -1
   # Info --> pointer2 -> pointer1
   # Info --> deref Lt_0011.8+16 [struct VEC3 ptr]
   # Info --> v1=var Lt_0011 ofs=16 [struct VEC3 ptr] symbdump=var local parambyref accessed declared implicit Lt_0011 [struct VEC3]
   # Info --> vr=reg 4 [single ptr]
   # Info --> virtual register =4 real register=r11
   # Info --> marked as used register=r11
   mov r11, 16[rbp]
   # Info --> vr type=4 / 4
   # Info --> store vr4 [single ptr] [single] := vr2 [single]
   # Info --> v1=ptr [single] vidx=<reg 4 [single ptr]>
   # Info --> v2=reg 2 [single]
   # Info --> virtual register =4 real register=r11
   # Info --> virtual register =2 real register=r8
   # Info --> Release done for register=r8
   # Info --> Release done for register=r11
   mov [r11], r8d
   # Info --> deref LHS.9+24 [struct VEC3 ptr]
   # Info --> v1=var LHS ofs=24 [struct VEC3 ptr] symbdump=var local parambyref accessed declared LHS [struct VEC3]
   # Info --> vr=reg 5 [single ptr]
   # Info --> virtual register =5 real register=r11
   # Info --> marked as used register=r11
   mov r11, 24[rbp]
   # Info --> vr type=5 / 4
   # Info --> deref RHS.10+32 [struct VEC3 ptr]
   # Info --> v1=var RHS ofs=32 [struct VEC3 ptr] symbdump=var local parambyref accessed declared RHS [struct VEC3]
   # Info --> vr=reg 6 [single ptr]
   # Info --> virtual register =6 real register=r10
   # Info --> marked as used register=r10
   mov r10, 32[rbp]
   # Info --> vr type=6 / 4
   # Info --> bop vr5 [single ptr]+4 [single] + vr6 [single ptr]+4 [single]
   # Info --> v1=ptr ofs=4 [single] vidx=<reg 5 [single ptr]>
   # Info --> v2=ptr ofs=4 [single] vidx=<reg 6 [single ptr]>
   # Info --> vr=reg 7 [single]
   # Info --> Vr<>0 op =>add
   # Info --> virtual register =5 real register=r11
   # Info --> virtual register =6 real register=r10
   # Info --> Bop with float
   # Info --> Release done for register=r11
   movss xmm0, 4[r11]
   # Info --> Release done for register=r10
   movss xmm1, 4[r10]
   addss xmm0, xmm1
   # Info --> marked as used register=r8
   movq r8, xmm0
   # Info --> bop Lt_0011.8+16 [struct VEC3 ptr] + 4 [integer]
   # Info --> v1=var Lt_0011 ofs=16 [struct VEC3 ptr] symbdump=var local parambyref accessed declared implicit Lt_0011 [struct VEC3]
   # Info --> v2=imm 4 [integer]
   # Info --> vr=reg 8 [struct VEC3 ptr]
   # Info --> Vr<>0 op =>add
   # Info --> marked as used register=r11
   mov r11, QWORD PTR 16[rbp]
   add r11, 4
   # Info --> in _setVregDataType v=reg 8 [struct VEC3 ptr]
   # Info --> dtype/subtype=[single ptr]
   # Info --> dtype/subtype=[struct VEC3 ptr]
   # Info --> CONVERTING vr9 [single ptr] := vr8 [struct VEC3 ptr]
   # Info --> v1=reg 9 [single ptr] xx 9
   # Info --> v2=reg 8 [struct VEC3 ptr] xx 8
   # Info --> pointer2 -> pointer1
   # Info --> store vr8 [struct VEC3 ptr] [single] := vr7 [single]
   # Info --> v1=ptr [single] vidx=<reg 8 [struct VEC3 ptr]>
   # Info --> v2=reg 7 [single]
   # Info --> virtual register =8 real register=r11
   # Info --> virtual register =7 real register=r8
   # Info --> Release done for register=r8
   # Info --> Release done for register=r11
   mov [r11], r8d
   # Info --> deref LHS.9+24 [struct VEC3 ptr]
   # Info --> v1=var LHS ofs=24 [struct VEC3 ptr] symbdump=var local parambyref accessed declared LHS [struct VEC3]
   # Info --> vr=reg 10 [single ptr]
   # Info --> virtual register =10 real register=r11
   # Info --> marked as used register=r11
   mov r11, 24[rbp]
   # Info --> vr type=10 / 4
   # Info --> deref RHS.10+32 [struct VEC3 ptr]
   # Info --> v1=var RHS ofs=32 [struct VEC3 ptr] symbdump=var local parambyref accessed declared RHS [struct VEC3]
   # Info --> vr=reg 11 [single ptr]
   # Info --> virtual register =11 real register=r10
   # Info --> marked as used register=r10
   mov r10, 32[rbp]
   # Info --> vr type=11 / 4
   # Info --> bop vr10 [single ptr]+8 [single] + vr11 [single ptr]+8 [single]
   # Info --> v1=ptr ofs=8 [single] vidx=<reg 10 [single ptr]>
   # Info --> v2=ptr ofs=8 [single] vidx=<reg 11 [single ptr]>
   # Info --> vr=reg 12 [single]
   # Info --> Vr<>0 op =>add
   # Info --> virtual register =10 real register=r11
   # Info --> virtual register =11 real register=r10
   # Info --> Bop with float
   # Info --> Release done for register=r11
   movss xmm0, 8[r11]
   # Info --> Release done for register=r10
   movss xmm1, 8[r10]
   addss xmm0, xmm1
   # Info --> marked as used register=r8
   movq r8, xmm0
   # Info --> bop Lt_0011.8+16 [struct VEC3 ptr] + 8 [integer]
   # Info --> v1=var Lt_0011 ofs=16 [struct VEC3 ptr] symbdump=var local parambyref accessed declared implicit Lt_0011 [struct VEC3]
   # Info --> v2=imm 8 [integer]
   # Info --> vr=reg 13 [struct VEC3 ptr]
   # Info --> Vr<>0 op =>add
   # Info --> marked as used register=r11
   mov r11, QWORD PTR 16[rbp]
   add r11, 8
   # Info --> in _setVregDataType v=reg 13 [struct VEC3 ptr]
   # Info --> dtype/subtype=[single ptr]
   # Info --> dtype/subtype=[struct VEC3 ptr]
   # Info --> CONVERTING vr14 [single ptr] := vr13 [struct VEC3 ptr]
   # Info --> v1=reg 14 [single ptr] xx 14
   # Info --> v2=reg 13 [struct VEC3 ptr] xx 13
   # Info --> pointer2 -> pointer1
   # Info --> store vr13 [struct VEC3 ptr] [single] := vr12 [single]
   # Info --> v1=ptr [single] vidx=<reg 13 [struct VEC3 ptr]>
   # Info --> v2=reg 12 [single]
   # Info --> virtual register =13 real register=r11
   # Info --> virtual register =12 real register=r8
   # Info --> Release done for register=r8
   # Info --> Release done for register=r11
   mov [r11], r8d
   # Info --> emit branch = jmp to .Lt_0010 98 jmp
#O9jmp .Lt_0010
   # Info --> registers released
   .Lt_0010:
   # Info --> loadres Lt_0011.8+16 [struct VEC3 ptr]
   # Info --> v1=var Lt_0011 ofs=16 [struct VEC3 ptr] symbdump=var local parambyref accessed declared implicit Lt_0011 [struct VEC3]
   # Info --> vr=reg 15 [struct VEC3 ptr]
   mov rax, 16[rbp]
   # Info --> stk=112
   # Info --> stk5=112

   mov rsp,rbp
   pop rbp
   ret
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by D.J.Peters »

Thank you SARG
looks like your code emitter doesn't have any optimazation stage right ?

your emitter emits 34 assembler commands for a vec3 addition

Code: Select all

# 37 assembler commands	 
   .text
   .globl _ZplR4VEC3S0_
_ZplR4VEC3S0_:
   push rbp
   mov  rbp,rsp
   sub rsp, 112
   mov QWORD PTR 16[rbp], rcx # @result
   mov QWORD PTR 24[rbp], rdx # @l
   mov QWORD PTR 32[rbp], r8  # @r
   mov r11, 24[rbp] # @l
   mov r10, 32[rbp] # @r
   movss xmm0, [r11] # l.x
   movss xmm1, [r10] # r.x
   addss xmm0, xmm1  # l.x + r.x
   movq r8, xmm0
   mov r11, 16[rbp]
   mov [r11], r8d   # *result->x = l.x + r.x
   mov r11, 24[rbp] # @l
   mov r10, 32[rbp] # @r
   movss xmm0, 4[r11] # l.y
   movss xmm1, 4[r10] # r.y
   addss xmm0, xmm1   # l.y + r.y
   movq r8, xmm0
   mov r11, QWORD PTR 16[rbp]
   add r11, 4
   mov [r11], r8d # *result->y = l.x + r.x
   mov r11, 24[rbp]
   mov r10, 32[rbp]
   movss xmm0, 8[r11]  # l.z
   movss xmm1, 8[r10]  # r.z
   addss xmm0, xmm1    # l.z + r.z
   movq r8, xmm0
   mov r11, QWORD PTR 16[rbp]
   add r11, 8
   mov [r11], r8d # *result->z = l.z + r.z
#O9jmp .Lt_0010
   .Lt_0010:
   mov rax, 16[rbp] # return @result
   mov rsp,rbp
   pop rbp
   ret
but only 24 are needed

Code: Select all

# 24 assemnbler commands
   .text
   .globl _ZplR4VEC3S0_
_ZplR4VEC3S0_:
   push rbp
   mov  rbp,rsp
   sub rsp, 112
   mov QWORD PTR 16[rbp], rcx # @result
   mov QWORD PTR 24[rbp], rdx # @l
   mov QWORD PTR 32[rbp], r8  # @r
   mov rax, 16[rbp]  # @result
   mov r11, 24[rbp]  # @l
   mov r10, 32[rbp]  # @r
   movss xmm0, [r11] # l.x
   movss xmm1, [r10] # r.x
   addss xmm0, xmm1  # l.x + r.x
   movq r8, xmm0
   mov [eax], r8d     # *result->x = l.x + r.x
   movss xmm0, 4[r11] # l.y
   movss xmm1, 4[r10] # r.y
   addss xmm0, xmm1   # l.y + r.y
   movq r8, xmm0
   mov 4[eax], r8d    # *result->y = l.y + r.y
   movss xmm0, 8[r11] # l.z
   movss xmm1, 8[r10] # r.z
   addss xmm0, xmm1   # l.z + r.z
   movq r8, xmm0
   mov 8[eax], r8d    # *result->z = l.x + r.z
   mov rsp,rbp
   pop rbp
   re
In case of ray tracing or per pixel operations often you need millions of such addition of vectors per frame
It makes a big different if a vector3 addition used 24 or 34 assember commands (~30 % slower)
Looks like my idea to translate my 3D math stuff to assembler are a good idea :-)

Thank you for your helpful description and support.

Joshy
Last edited by D.J.Peters on Mar 13, 2020 22:26, edited 4 times in total.
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by Lost Zergling »

Hello SARG,
I did some tests because the project seemed really interesting to me. As because of my way of programming I use the lists a lot (this allows me to save time on management applications), the idea of ​​doing without gcc is nice. If I may, I will have a few comments:
No significant speed difference using the lists, and the results seem identical, this means that, for me, it is potentially very substitutable for a large number of management oriented applications, however:
- The compilation seems to no longer work beyond a certain volume of code (w10, 64), and it's really a problem of size (too many function calls in the same scope?): Apparently it's a real size problem and nothing else (I copied pasted different blocks of code to make sure). From my point of view, it is blocking due to the maintenance of overloaded programs.
- I am not at all an assembly language expert, but there are alternatives in terms of license (FASM, BSD copyleft) or NASM (BSD): this could provide an effective alternative and therefore an additional interest compared to gcc.
- It seems to me desirable that you further specify the license for your work.
These three elements could, in my opinion, bring to this project a real and important interest.
I don't really use mathematical calculations, and even if DJ Peters' remark on this seems relevant, it may not be the main concern of a majority of users either.
It is only a lambda "user" point of view, but I see this project fundamentally very interesting. :-)
SARG
Posts: 1755
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by SARG »

Hi all,
Still working on variadic functions, a bit harder that I thought but the release is coming soon.
robert wrote:Compiled and linked on Fedora 31 with the latest FreeBASIC 1.08 source from Github. No problems. Copied fbc_new as fbc64_gas64 to the install directory, replacing your GAS64 compilation and am now testing examples. No more ospeed warnings. So far ... so good.
Very Good.
What do you call ospeed warning ?
Any problem when compiling ?
What Github official or mine ?
Do you use the modified modules provided with in the zip file ?
In the link script you can change 'fbc_new' by 'fbc64_gas64' to directly have the right name.
D.J.Peters wrote:looks like your code emitter doesn't have any optimization stage right ?
Due to the way the instructions are sent to the emitter it's hard to do a strong optimization. For now just 'micro' optimization a posteriori on the generated code.

Example of instruction flow and micro optimization
Here a local variable ARGS is initialized to zero
first instruction : addrof --> retrieve its address
second instruction : memclear --> put zero at the address

Code: Select all

# Info --> addrof ARGS.3+-136 [any alias "va_list" ptr]
   # Info --> v1=var ARGS ofs=-136 [any alias "va_list" ptr] symbdump=var local accessed declared ARGS [any alias "va_list" ptr]
   # Info --> vr=reg 1 [any alias "va_list" ptr ptr]
 
#O4lea r11, -136[rbp]
   # Info --> memclear vr1 [any alias "va_list" ptr ptr]
   # Info --> v1=reg 1 [any alias "va_list" ptr ptr]
   # Info --> v2=imm 8 [integer]

   #O4mov QWORD PTR [r11], 0
   mov QWORD PTR -136[rbp], 0 #Optim 4


The optimization is done after the code generation by 'analyzing' the last line with kept data from the previous one.

Maybe better is possible by analysing totality the functions, I have to look at the asm code and think a lot how it can be done. But I don't want to go upstream in the compiler : just staying in the emitter.

However current executables should run at same speed (or faster) than those gotten with gcc (without optimization flags.....).
A way to do if speed is an issue : keep the asm code, look at it and just handly optimize the critical part with inline asm in the basic code.

Another of my goals is to be able to debug as with gas32. With gcc there are too much changes in code and variables therefore debugging could be hard. In this case speed doesn't matter.

Lost Zergling wrote:I did some tests because the project seemed really interesting to me.
Thank you for your real interest, repeated 3 times :-) Comments are welcome.
- The compilation seems to no longer work beyond a certain volume of code (w10, 64), and it's really a problem of size (too many function calls in the same scope?): Apparently it's a real size problem and nothing else (I copied pasted different blocks of code to make sure). From my point of view, it is blocking due to the maintenance of overloaded programs.
Not sure to understand. Could you send me examples, commented in french ;-) d eb ug @ alice adsl .fr (no space)
- I am not at all an assembly language expert, but there are alternatives in terms of license (FASM, BSD copyleft) or NASM (BSD): this could provide an effective alternative and therefore an additional interest compared to gcc.
Could you explain more the advantages ? For me here the assembler is 'only' a translator the important 'job' is done before.
- It seems to me desirable that you further specify the license for your work.
I'm not very aware about licensing. As it's just a new module in fbc and some light modifications somewhere else it should follow freebasic's one.
robert
Posts: 169
Joined: Aug 06, 2019 18:45

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by robert »

robert wrote:Compiled and linked on Fedora 31 with the latest FreeBASIC 1.08 source from Github. No problems. Copied fbc_new as fbc64_gas64 to the install directory, replacing your GAS64 compilation and am now testing examples. No more ospeed warnings. So far ... so good.
SARG wrote: Very Good.
What do you call ospeed warning ?
The warning is

fbc: Symbol `ospeed' has different size in shared object, consider re-linking

If you do a search on this forum for "ospeed" you will find many questions regarding this message. The most informative but still speculative was CoderJeff's response at

viewtopic.php?f=17&t=27313&p=258527&hil ... ed#p258527
SARG wrote: Any problem when compiling ?
No problems.
SARG wrote: What Github official or mine ?
https://github.com/freebasic/fbc

What is the URL of your Github repo?
SARG wrote: Do you use the modified modules provided with in the zip file ?
Yes I did, I moved them to the src/compiler directory with your compilation/linking scripts before running the scripts. Of course. the
rtlib and gfxlib2 stuff didnt get compiled but that will require modifying the makefile and I am not sure what exactly has to be done.
SARG wrote: In the link script you can change 'fbc_new' by 'fbc64_gas64' to directly have the right name.
It was quick and dirty, SARG, I just wanted to see if I could get it to work. I guess I should have a close look and see what is what regarding your mods to the fbc source and how to adjust the makefile to do a complete compile including rtlib and gfxlib2 as well as installation.
SARG
Posts: 1755
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by SARG »

Hi all,

After being stuck for a long time by stupid bugs and a misunderstanding of what parameters are to be put on stack, I can finally release a better version for Linux.

http://users.freebasic-portal.de/sarg/fbc64_gas64.zip


@robert Thank you for your answers.

About Lost Zergling's problem thanks to the files which he sent me I could understand what was happening. It's fixed by increasing the size of 2 arrays but I still have to add at least a control.
robert
Posts: 169
Joined: Aug 06, 2019 18:45

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by robert »

SARG wrote:Hi all,

After being stuck for a long time by stupid bugs and a misunderstanding of what parameters are to be put on stack, I can finally release a better version for Linux.

http://users.freebasic-portal.de/sarg/fbc64_gas64.zip


@robert Thank you for your answers.

About Lost Zergling's problem thanks to the files which he sent me I could understand what was happening. It's fixed by increasing the size of 2 arrays but I still have to add at least a control.
Hi SARG:

Thank you for the update

Copied your src files into the src/compiler folder of a fresh download of the latest FreeBASIC 1.08 source from Github. Using the stock makefile, fbc was compiled and linked on Fedora 31.

First make was O.K.

Second make with your newly compiled Fbc64_gas64 installed as fbc, the compiler throws these errors.

Code: Select all


FBC src/compiler/obj/linux-x86_64/symb-proc.o
src/compiler/obj/linux-x86_64/symb-proc.a64: Assembler messages:
src/compiler/obj/linux-x86_64/symb-proc.a64:6969: Error: attempt to store non-empty string in section `.bss'
src/compiler/obj/linux-x86_64/symb-proc.a64:6972: Error: attempt to store non-empty string in section `.bss'
src/compiler/obj/linux-x86_64/symb-proc.a64:6972: Error: attempt to store non-empty string in section `.bss'
src/compiler/obj/linux-x86_64/symb-proc.a64:6972: Error: attempt to store non-empty string in section `.bss'
src/compiler/obj/linux-x86_64/symb-proc.a64:6972: Error: attempt to store non-empty string in section `.bss'
make: *** [makefile:576: src/compiler/obj/linux-x86_64/symb-proc.o] Error 1

Xusinboy Bekchanov
Posts: 782
Joined: Jul 26, 2018 18:28

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by Xusinboy Bekchanov »

Hi,
When compiling with the new version, the following errors appear in Linux:

Code: Select all

 07:03:38: Compilation: "/media/nasbackup/FreeBASIC-1.07.0-linux-x86_64/bin/fbc64_gas64"  -b "VisualFBEditor.bas" -x "../VisualFBEditor64_gtk3" -exx -s gui -g -i "/media/GitHub/VisualFBEditor/./MyFbFramework" ...

VisualFBEditor.a64: Сообщения ассемблера:
VisualFBEditor.a64:120247: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=90 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:120249: Ошибка: неправильное выражение
VisualFBEditor.a64:120249: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:120251: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=90 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:120253: Ошибка: неправильное выражение
VisualFBEditor.a64:120253: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:120255: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=90 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:120258: Ошибка: неправильное выражение
VisualFBEditor.a64:120258: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:122806: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=585 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:122808: Ошибка: неправильное выражение
VisualFBEditor.a64:122808: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:122810: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=585 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:122812: Ошибка: неправильное выражение
VisualFBEditor.a64:122812: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:122814: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=585 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:122817: Ошибка: неправильное выражение
VisualFBEditor.a64:122817: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:122936: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=627 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:122938: Ошибка: неправильное выражение
VisualFBEditor.a64:122938: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:122940: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=627 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:122942: Ошибка: неправильное выражение
VisualFBEditor.a64:122942: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:122944: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=627 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:122947: Ошибка: неправильное выражение
VisualFBEditor.a64:122947: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123045: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=665 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123047: Ошибка: неправильное выражение
VisualFBEditor.a64:123047: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123049: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=665 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123051: Ошибка: неправильное выражение
VisualFBEditor.a64:123051: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123053: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=665 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123056: Ошибка: неправильное выражение
VisualFBEditor.a64:123056: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123174: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=707 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123176: Ошибка: неправильное выражение
VisualFBEditor.a64:123176: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123178: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=707 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123180: Ошибка: неправильное выражение
VisualFBEditor.a64:123180: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123182: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=707 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123185: Ошибка: неправильное выражение
VisualFBEditor.a64:123185: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123282: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=745 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123284: Ошибка: неправильное выражение
VisualFBEditor.a64:123284: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123286: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=745 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123288: Ошибка: неправильное выражение
VisualFBEditor.a64:123288: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123290: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=745 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123293: Ошибка: неправильное выражение
VisualFBEditor.a64:123293: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123411: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=787 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123413: Ошибка: неправильное выражение
VisualFBEditor.a64:123413: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123415: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=787 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123417: Ошибка: неправильное выражение
VisualFBEditor.a64:123417: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123419: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=787 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123422: Ошибка: неправильное выражение
VisualFBEditor.a64:123422: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123520: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=825 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123522: Ошибка: неправильное выражение
VisualFBEditor.a64:123522: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123524: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=825 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123526: Ошибка: неправильное выражение
VisualFBEditor.a64:123526: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123528: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=825 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123531: Ошибка: неправильное выражение
VisualFBEditor.a64:123531: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123650: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=867 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123652: Ошибка: неправильное выражение
VisualFBEditor.a64:123652: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123654: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=867 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123656: Ошибка: неправильное выражение
VisualFBEditor.a64:123656: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:123658: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=867 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:123661: Ошибка: неправильное выражение
VisualFBEditor.a64:123661: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:125499: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=311 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:125502: Ошибка: неправильное выражение
VisualFBEditor.a64:125502: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:126060: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=467 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:126063: Ошибка: неправильное выражение
VisualFBEditor.a64:126063: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:127848: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=761 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:127851: Ошибка: неправильное выражение
VisualFBEditor.a64:127851: Ошибка: missing right bracket
VisualFBEditor.a64:127851: Ошибка: мусор «X_Q]» после выражения
VisualFBEditor.a64:129387: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=291 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:129389: Ошибка: неправильное выражение
VisualFBEditor.a64:129389: Ошибка: missing right bracket
VisualFBEditor.a64:129389: Ошибка: мусор «X_Q]» после выражения
VisualFBEditor.a64:139336: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=259 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:139338: Ошибка: неправильное выражение
VisualFBEditor.a64:139338: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:184255: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=592 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:184257: Ошибка: неправильное выражение
VisualFBEditor.a64:184257: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:187109: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=948 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:187111: Ошибка: неправильное выражение
VisualFBEditor.a64:187111: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:189122: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=1180 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:189124: Ошибка: неправильное выражение
VisualFBEditor.a64:189124: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:189830: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=1252 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:189832: Ошибка: неправильное выражение
VisualFBEditor.a64:189832: Ошибка: мусор «X_Q» после выражения
VisualFBEditor.a64:284832: Ошибка: такая инструкция не существует: «found AN ERROR:virtual register=241 no real register corresponding,using KREG_XXX»
VisualFBEditor.a64:284834: Ошибка: неправильное выражение
VisualFBEditor.a64:284834: Ошибка: мусор «X_Q» после выражения

07:04:17: Do not build file.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by D.J.Peters »

SARG with some tiny macros the WINDOWS64_ABI and LINUX64_ABI looks the same now and need only 12 commads for the naked vector3 operators +/- !
The point are your generated code (I learned from) loads the arguments from registers to xmm0 and xmm1 and do the math operation
but the math operation works with the seconds argumet in mem[registers] also.

long:
mov xmm0,[regA+#]
mov xmm1,[regB+#]
add/sub xmm0,ymm1
mov [this+#],xmm0

short:
mov xmm0,[regA+#]
add/sub xmm0,[regB+#]
mov [this+#],xmm0

can't wait to get one of my ray tracers completly in assembler :-)

Again thank you for pointing me in the right direction !

Joshy
SARG
Posts: 1755
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by SARG »

Hi all,

Thank you for your reports and sorry for the inconvenience. I hope that I'll can fix quickly these new issues.

@robert
It should be easy to find the bug by compiling the concerned module.

@Xusinboy
In your case it should be harder. Send me all necessary for testing. debug @ aliceadsl .fr (no space)

@D.J.Peters
This sort of optimization is already in my roadmap. There are others like that....
Xusinboy Bekchanov
Posts: 782
Joined: Jul 26, 2018 18:28

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by Xusinboy Bekchanov »

SARG wrote: @Xusinboy
In your case it should be harder. Send me all necessary for testing. debug @ aliceadsl .fr (no space)
I sent you an email
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by Lost Zergling »

@Sarg : thank you again for this work and open comments around it.
Post Reply