FreeBASIC 1.10.1 Release Discussion

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
fbfans
Posts: 17
Joined: Nov 27, 2023 0:29

Re: FreeBASIC 1.10.1 Release Discussion

Post by fbfans »

Code: Select all

#define _DllFullPath "xxx.dll"
#ifndef INCFILE_LIGHT_
#define INCFILEX_LIGHT_

 #macro __MACRO__INCLIGHT__(label, file)
  #if __FUNCTION__ = "__FB_MAINPROC__"
    #error =====> Error  INCBIN outside Sub/Function!
  #else
    Dim label As UByte Ptr
    Dim label##_len As ULong
    #if file = ""
        #error =====> Error  no given exe/dll_file!
    #else
        #if __FB_DEBUG__
            asm jmp .LT_END_OF_FILE_##label##_DEBUG_JMP
        #else 
            Asm .section .Data
        #endif 
        asm .LT_START_OF_FILE_##label##:
        Asm __##label##__start = . 
        Asm .incbin ##file 
        asm __##label##__len = . - __##label##__start
        Asm .LT_END_OF_FILE_##label##: 
        #if __FB_DEBUG__
            Asm .LT_END_OF_FILE_##label##_DEBUG_JMP:
        #else 
            Asm .section .text 
            asm .balign 16
        #endif
        Asm .LT_SKIP_FILE_##label##:
        Asm mov DWORD Ptr [label], offset .LT_START_OF_FILE_##label
        Asm mov DWORD Ptr [label##_len], offset __##label##__len
   #endif
  #endif
 #endmacro 
 #endif
Sub Test()
   #ifdef __FB_64BIT__
      __MACRO__INCLIGHT__(DLL64, _DllFullPath) 
   #else
      __MACRO__INCLIGHT__(DLL32, _DllFullPath) 
   #endif
End Sub
Last edited by fxm on Jan 16, 2024 19:26, edited 1 time in total.
Reason: Added code tags.
SARG
Posts: 1768
Joined: May 27, 2005 7:15
Location: FRANCE

Re: FreeBASIC 1.10.1 Release Discussion

Post by SARG »

Try that.
I removed my first post as the code was not ok.

Code: Select all

#define _DllFullPath "xxx.dll"
#ifndef INCFILE_LIGHT_
	#define INCFILEX_LIGHT_

	#macro __MACRO__INCLIGHT__(label, file)
		#if __FUNCTION__ = "__FB_MAINPROC__"
			#error =====> Error INCBIN outside Sub/Function!
		#else
			Dim label As UByte Ptr
			Dim label##_len As integer
			#if file = ""
				#error =====> Error no given exe/dll_file!
			#else
				#if __FB_DEBUG__
					asm jmp .LT_END_OF_FILE_##label##_DEBUG_JMP
				#else
					Asm .section .Data
				#endif
				asm LT_START_OF_FILE_##label##:
				
				Asm __##label##__start = .
				Asm .incbin ##file
				asm __##label##__len = . - __##label##__start
				Asm .LT_END_OF_FILE_##label##:
				#if __FB_DEBUG__
					Asm .LT_END_OF_FILE_##label##_DEBUG_JMP:
				#else
					Asm .section .text
					asm .balign 16
				#endif
				Asm .LT_SKIP_FILE_##label##:
				Asm mov r11, offset  LT_START_OF_FILE_##label[rip]
				Asm mov QWORD Ptr [label], r11
				Asm mov QWORD Ptr [label##_len], offset __##label##__len
			#endif
		#endif
	#endmacro
#endif
Sub Test()
	print "debut"
	#ifdef __FB_64BIT__
	__MACRO__INCLIGHT__(DLL64, _DllFullPath)
	#else
	__MACRO__INCLIGHT__(DLL32, _DllFullPath)
	#endif
	print dll64,DLL64_len
	print "end"
End Sub
test
sleep
fbfans
Posts: 17
Joined: Nov 27, 2023 0:29

Re: FreeBASIC 1.10.1 Release Discussion

Post by fbfans »

Thank you for your reply :D
Compile is ok now, but APPCRASH c0000005
SARG
Posts: 1768
Joined: May 27, 2005 7:15
Location: FRANCE

Re: FreeBASIC 1.10.1 Release Discussion

Post by SARG »

Replace

Code: Select all

Asm mov r11, offset  LT_START_OF_FILE_##label[rip]
by

Code: Select all

Asm lea r11, LT_START_OF_FILE_##label[rip]
R11 can be replaced by RAX (in both line)
fbfans
Posts: 17
Joined: Nov 27, 2023 0:29

Re: FreeBASIC 1.10.1 Release Discussion

Post by fbfans »

SARG wrote: Jan 17, 2024 14:33 Replace

Code: Select all

Asm mov r11, offset  LT_START_OF_FILE_##label[rip]
by

Code: Select all

Asm lea r11, LT_START_OF_FILE_##label[rip]
R11 can be replaced by RAX (in both line)
Cool, the program can run now. Thank you very much.
:P :P :P
Post Reply