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

User projects written in or related to FreeBASIC.
SARG
Posts: 1123
Joined: May 27, 2005 7:15
Location: FRANCE

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

Postby SARG » Jul 07, 2020 23:34

Hi all,

After few days on holidays I'm back for coding :-)
So a new version : http://users.freebasic-portal.de/sarg/f ... 64_WDS.zip

- Some fixes for LNX (procedure callings). However as all the tests are not sucessfully passed exe not provided.
- Fix for calculations when lang QB is selected

- And especially for srvaldez, adding of fast gosub/return like with gas32. 2 new files modified (symb.bi and ast-gosub.bas)

WARNING direct execution of subroutines without using gosub can induces undefined behaviours.
For respecting stack alignment (16byte multiple) a 'push' is added just after the called label and a 'pop' just before the return.
if gosub is not used there is no call so the push misaligns the stack. If procedure calls or float uses are done it could arise crashes.
srvaldez
Posts: 2482
Joined: Sep 25, 2005 21:54

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

Postby srvaldez » Jul 07, 2020 23:48

thank you SARG :-)
Xusinboy Bekchanov
Posts: 246
Joined: Jul 26, 2018 18:28

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

Postby Xusinboy Bekchanov » Jul 08, 2020 12:38

SARG wrote:@Xusinboy
Sorry I don't know how to get the current problems. Could you explain exactly what I should do.

Here I said the same:
Xusinboy Bekchanov wrote:On press New button find an error inside the procedure Sub Control.ProcessMessage(ByRef message As Message)

At compile time, in the new version shows this:

Code: Select all

17:33:45: Compilation: ""F:\Install\Install2\FreeBASIC-1.07.1-win64\fbc64_gas64.exe"  -b "VisualFBEditor.bas" -x "../VisualFBEditor64.exe" "VisualFBEditor.rc"  -i "F:\Install\Install2\VisualFBEditor/./MyFbFramework" 2> "F:\Install\Install2\VisualFBEditor/Temp/Compile.log""

VisualFBEditor.a64: Assembler messages:
VisualFBEditor.a64:305941: Error: no such instruction: `found AN ERROR:Converting float to int 01'

17:34:06: Do not build file.
SARG
Posts: 1123
Joined: May 27, 2005 7:15
Location: FRANCE

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

Postby SARG » Jul 09, 2020 21:40

Xusinboy Bekchanov wrote:On press New button find an error inside the procedure Sub Control.ProcessMessage(ByRef message As Message)
Ok, understood.
Xusinboy Bekchanov wrote:VisualFBEditor.a64:305941: Error: no such instruction: `found AN ERROR:Converting float to int 01'
I didn't get this compilation error. I used your 1.24 version.

But when running the exe crashed. I found and fixed this issue but the exe is always crashing now in a Windows's part, information given by gdb....
However when I tried to debug (with x64dbg) no issue, all is running fine. Even when I cklicked on the button NEW...
So I'm a bit annoyed. :-(

Try this new version and if you get the compilation error post/send 20 lines before the error of the a64.file.
http://users.freebasic-portal.de/sarg/f ... 64_exe.zip
Xusinboy Bekchanov
Posts: 246
Joined: Jul 26, 2018 18:28

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

Postby Xusinboy Bekchanov » Jul 10, 2020 4:54

SARG wrote:
Xusinboy Bekchanov wrote:On press New button find an error inside the procedure Sub Control.ProcessMessage(ByRef message As Message)
Ok, understood.
Xusinboy Bekchanov wrote:VisualFBEditor.a64:305941: Error: no such instruction: `found AN ERROR:Converting float to int 01'
I didn't get this compilation error. I used your 1.24 version.

This will happen in the new version: https://github.com/XusinboyBekchanov/VisualFBEditor + https://github.com/XusinboyBekchanov/MyFbFramework
SARG wrote:Try this new version and if you get the compilation error post / send 20 lines before the error of the a64.file.

Ok:

Code: Select all

   lea rcx, -14336[rbp] #Optim 5
   lea rdx, Lt_A900[rip+0]
   call STARTSWITH #NO_ALL
   mov r11b, al
   cmp r11b, 0
   je .Lt_C405
#O5lea r11, -14336[rbp]
   #O5mov rcx, r11
   lea rcx, -14336[rbp] #Optim 5
   mov edx, 10
   mov r8, -1
   call fb_WstrMid #NO_ALL
#O2mov r11, rax
   #O2mov -20584[rbp], r11
   mov -20584[rbp], rax #Optim 2
   mov rcx, -20584[rbp]
   call fb_WstrVal #NO_ALL
#O3movq rax, xmm0
   #O3mov r11, rax
   movq r11, xmm0 #Optim 3

   FOUND AN ERROR : Converting float to int 01
SARG
Posts: 1123
Joined: May 27, 2005 7:15
Location: FRANCE

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

Postby SARG » Jul 12, 2020 10:26

Hi all,

Xusinboy Bekchanov wrote:This will happen in the new version: https://github.com/XusinboyBekchanov/VisualFBEditor + https://github.com/XusinboyBekchanov/MyFbFramework

VisualFBEditor.a64:305941: Error: no such instruction: `found AN ERROR:Converting float to int 01'
Fixed.
However why put/convert a double as an enum ? Somewhere in this code

Code: Select all

   If FileExists(ToolsINI) Then
      Open ToolsINI For Input Encoding "utf8" As #Fn
      Do Until EOF(Fn)
         Line Input #Fn, Buff
         If StartsWith(Buff, "Path=") Then
            tt = New ToolType
            tt->Path = Mid(Buff, 6)
            Tools.Add tt
         ElseIf tt <> 0 Then
            If StartsWith(Buff, "Name=") Then
               tt->Name = Mid(Buff, 6)
            ElseIf StartsWith(Buff, "Parameters=") Then
               tt->Parameters = Mid(Buff, 12)
            ElseIf StartsWith(Buff, "WorkingFolder=") Then
               tt->WorkingFolder = Mid(Buff, 15)
            ElseIf StartsWith(Buff, "Accelerator=") Then
               tt->Accelerator = Mid(Buff, 13)
               #ifdef __USE_GTK__
               #else
                  Ico.Handle = ExtractIconW(Instance, tt->Path, NULL)
                  Bitm.Handle = Ico.ToBitmap
               #endif
               mi = miXizmat->Add(tt->Name & !"\t" & tt->Accelerator, Bitm, "Tools", @mClickTool)
               mi->Tag = tt
            ElseIf StartsWith(Buff, "LoadType=") Then
               tt->LoadType = Cast(LoadTypes, Val(Mid(Buff, 10)))
            ElseIf StartsWith(Buff, "WaitComplete=") Then
               tt->WaitComplete = CDbl(Mid(Buff, 14))
            End If
         End If
      Loop
      Close #Fn
   End if


The other issue seems also to be fixed. Try with the new version. And thanks again for reporting any issue.

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

Notice :
- I needed to change sym.bi so there are two versions one for 1.07 and one for 1.08.
- also a new file changed sym-label.bas (due to gosub changes)

@coderjeff
Hope you read that. Did you receive my email ? I really need some help.

Now I return on the LNX version.
Xusinboy Bekchanov
Posts: 246
Joined: Jul 26, 2018 18:28

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

Postby Xusinboy Bekchanov » Jul 12, 2020 11:01

Thank you, it compiles now, but gives the following error when opening the file and moving the caret to a new location:

Code: Select all

 1164
 1165

Program received signal SIGSEGV, Segmentation fault.
0x000000000047dc8f in MY::SYS::FORMS::EDITCONTROL::SHOWCARETPOS(bool) ()
(gdb) bt
#0  0x000000000047dc8f in MY::SYS::FORMS::EDITCONTROL::SHOWCARETPOS(bool) ()
#1  0x000000000047fde3 in MY::SYS::FORMS::EDITCONTROL::SCROLLTOCARET() ()
#2  0x00000000004798b2 in MY::SYS::FORMS::EDITCONTROL::CHANGED(wchar_t&) ()
#3  0x0000000000479f6c in MY::SYS::FORMS::EDITCONTROL::CHANGETEXT(wchar_t&, INTEGER, wchar_t&, INTEGER, INTEGER) ()
#4  0x000000000048c528 in MY::SYS::FORMS::EDITCONTROL::PROCESSMESSAGE(MESSAGE&) ()
#5  0x0000000000427a63 in MY::SYS::FORMS::CONTROL::DEFWNDPROC(HWND__*, unsigned int, unsigned long long, long long) ()
#6  0x00007ff8af2a681d in USER32!CascadeChildWindows () from C:\Windows\System32\user32.dll
#7  0x0000000000050880 in ?? ()
#8  0x00007ff800000102 in ?? ()
#9  0x0000000000000066 in ?? ()
#10 0x0000000000210001 in ?? ()
#11 0x0000000000000000 in ?? ()
(gdb)

Code: Select all

   Sub EditControl.ShowCaretPos(Scroll As Boolean = False)
?1155:      nCaretPosY = GetCaretPosY(FSelEndLine)
?1156:      FCurLineCharIdx = FSelEndChar
?1157:      nCaretPosX = TextWidth(GetTabbedText(Left(Lines(FSelEndLine), FCurLineCharIdx)))
?1158:      If CInt(DropDownShowed) AndAlso CInt(CInt(FSelEndChar < DropDownChar) OrElse CInt(FSelEndChar > GetNextCharIndex(*Cast(EditControlLine Ptr, FLines.Items[FSelEndLine])->Text, DropDownChar))) Then
?1159:         CloseDropDown()
?1160:      End If
?1161:      If CInt(ToolTipShowed) AndAlso CInt(CInt(FSelEndChar < ToolTipChar) OrElse CInt(Mid(*Cast(EditControlLine Ptr, FLines.Items[FSelEndLine])->Text, FSelEndChar + 1, 1) = ":") OrElse CInt(GetWordAt(FSelEndLine, ToolTipChar) <> HintWord)) Then
?1162:         CloseToolTip()
?1163:      End If
?1164:      If OldLine <> FSelEndLine OrElse OldChar <> FSelEndChar Then
?1165:         If OnSelChange Then OnSelChange(This, FSelEndLine, FSelEndChar)

I think that this happens when referring to OnSelChange(This, FSelEndLine, FSelEndChar)
SARG
Posts: 1123
Joined: May 27, 2005 7:15
Location: FRANCE

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

Postby SARG » Jul 20, 2020 23:15

Hi all,

I ended to rid of issues when testing the LNX version :-) Thanks to jeff who helped me about variadic argument lists.
Only the first level compilation but the test suite is succesfully passed. I let robert made the 3 compilations and testing. Thanks in advance.

Under WDS the three compilations are good and also the test suite.

The use of asm words for shared variables and procedures names is allowed again. It seems there is no issue...
ex : 'dim shared as integer rax' or 'sub rdx() '

http://users.freebasic-portal.de/sarg/fbc64_gas64.zip (Source code, exes for LNX/WDS 1.07/1.08)

Notice : use symb_108.bi (after renaming in symb.bi) for compiling version 1.08.
I hope I didn't made any mistake as there are a lot of versions/files....

@xusinboy I return to the issue when executing your code compiled with gas64.
robert
Posts: 116
Joined: Aug 06, 2019 18:45

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

Postby robert » Jul 21, 2020 3:12

SARG wrote:Hi all,

I ended to rid of issues when testing the LNX version :-) Thanks to jeff who helped me about variadic argument lists.
Only the first level compilation but the test suite is succesfully passed. I let robert made the 3 compilations and testing. Thanks in advance.



Hi SARG:

Error on Linux Fedora 32, Github FreeBASIC 1.0.8 source makefile compile third run

Code: Select all


FBC src/compiler/obj/linux-x86_64/ast-gosub.o
FBC src/compiler/obj/linux-x86_64/ast-helper.o
src/compiler/ast-helper.bas(925) warning 1(2): Passing scalar as pointer, at parameter 2 of ASTTYPEINISCOPEBEGIN()
src/compiler/ast-helper.bas(925) error 24: Invalid data types, at parameter 2 of ASTTYPEINISCOPEBEGIN() in 'astTypeIniScopeBegin( tree, dimtbfield, TRUE )'
src/compiler/ast-helper.bas(925) error 133: Too many errors, exiting
make: *** [makefile:576: src/compiler/obj/linux-x86_64/ast-helper.o] Error 1

srvaldez
Posts: 2482
Joined: Sep 25, 2005 21:54

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

Postby srvaldez » Jul 21, 2020 12:43

hello SARG :-)
on Windows it works like a charm, no problems so far, thank you :-)
Lost Zergling
Posts: 326
Joined: Dec 02, 2011 22:51
Location: France

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

Postby Lost Zergling » Jul 21, 2020 12:45

I'm sorry, I didn't retrieve your email. Still testing occasionnally. Lattest release offers better visibility.
20180206.a64:187150: Error: no such instruction: `found AN ERROR:No room for spilling register report dev,current limit 150'
I wonder if the limit couldn't be automatically adapted ? (or something approaching)
SARG
Posts: 1123
Joined: May 27, 2005 7:15
Location: FRANCE

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

Postby SARG » Jul 23, 2020 15:34

Lost Zergling wrote:20180206.a64:187150: Error: no such instruction: `found AN ERROR:No room for spilling register report dev,current limit 150'
I wonder if the limit couldn't be automatically adapted ? (or something approaching)
I will do that but before need to investigate (error in the emitter or very complex line) as I said in my email.
I was writing this when I receive your reply :-) so I just remove useless sentences.

@UEZ Thanks again for your report in the BasicCoder2's thread.
The error was due to 'dx' used as variable name generating an error when assembling. It's allowed in the current version but I did a mistake when compiling or copying files.
The right version (For now only Exes for WDS) http://users.freebasic-portal.de/sarg/f ... DS_exe.zip

The other issues still opened. I return a bit on fbdebugger for StillLearning. Me : StillImproving. ;-)


Edit : Usually I read all the new posts in the forum whatever are the subjects but It's safer to post also here when you find a problem.
UEZ
Posts: 614
Joined: May 05, 2017 19:59
Location: Germany

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

Postby UEZ » Jul 23, 2020 15:58

SARG wrote:@UEZ Thanks again for your report in the BasicCoder2's thread.
The error was due to 'dx' used as variable name generating an error when assembling. It's allowed in the current version but I did a mistake when compiling or copying files.
The right version (For now only Exes for WDS) http://users.freebasic-portal.de/sarg/f ... DS_exe.zip


Thanks SARG, works now properly.
wallyg
Posts: 124
Joined: May 08, 2009 7:08
Location: Tucson Arizona

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

Postby wallyg » Jul 24, 2020 20:51

During this time of working from home as a fun break from all my serious coding, I was thinking of a routine to generate assembly code for a simple interpretive language I have used for many many years for quick and dirty projects.

I looked at the assembly code generated by FB and wondered if there was any documentation on specifications of the assembly commands used by FB and where I could find out about the actual code generated?

Back in the early 80s, I wrote a Fortran compiler for the 80386 that my company used to port their mainframe software to the PC. So I am really dredging my mind for what I knew then and I am sure things have changed a bit since then.

Wally
jj2007
Posts: 1645
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

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

Postby jj2007 » Jul 24, 2020 22:05

Wally, the easiest way is to insert an asm int 3 somewhere in your code and let the executable crash. You need to have a Just-in-time debugger installed. I use OllyDbg for that - see Options/Options/Debugging/Just-in-time. When the program crashes, you are at the int 3 instruction. Press F8 repeatedly to see what's going on. Simple example:

Code: Select all

#Include Once "windows.bi"
Dim As Ubyte Ptr BinData
Dim As SIZE_T iLen = 1000
Dim As DWORD old
BinData = Allocate(iLen)
SetLastError(123)
asm int 3
? VirtualProtect(BinData, iLen, PAGE_EXECUTE_READWRITE, @old), "Error VP: " & GetLastError()
asm nop   ' the nops serve to recognise where the above line finishes
asm nop
asm nop
asm nop
Deallocate(BinData)
Sleep

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 7 guests