Code: Select all
Procedure proc1()
Define.s st
st = "proc111111111111111111111111111111"
EndProcedure
Procedure proc2()
Define.s st
st = "proc222222222222222222222222222222"
EndProcedure
proc1()
Code: Select all
Procedure proc1()
Define.s st
st = "proc111111111111111111111111111111"
EndProcedure
Procedure proc2()
Define.s st
st = "proc222222222222222222222222222222"
EndProcedure
proc1()
Code: Select all
Procedure a()
; *NOT NEEDED* and not included, OK
; never referenced
EndProcedure
Procedure b()
; *NOT NEEDED* but included
; referenced only by itself (recursive)
b()
EndProcedure
Procedure c()
; *NOT NEEDED* but included
; referenced by a function never referenced: d()
EndProcedure
Procedure d()
; *NOT NEEDED* and not included, OK
; never referenced
c()
EndProcedure
Procedure e()
; NEEDED
; referenced and called
EndProcedure
Code: Select all
IncludeFile "lib.pbi"
e()
Code: Select all
;
; PureBasic 4.31 (Windows - x86) generated code
;
; (c) 2009 Fantaisie Software
;
; The header must remain intact for Re-Assembly
;
; :System
; KERNEL32
; :Import
;
format MS COFF
;
extrn _ExitProcess@4
extrn _GetModuleHandleA@4
extrn _HeapCreate@12
extrn _HeapDestroy@4
;
extrn _memset
extrn _PB_StringBase
extrn PB_StringBase
extrn _SYS_InitString@0
;
extrn _PB_StringBasePosition
public _PB_Instance
public _PB_ExecutableType
public _PB_MemoryBase
public PB_Instance
public PB_MemoryBase
public _PB_EndFunctions
macro pb_public symbol
{
public _#symbol
public symbol
_#symbol:
symbol:
}
macro pb_align value { rb (value-1) - ($-_PB_DataSection + value-1) mod value }
macro pb_bssalign value { rb (value-1) - ($-_PB_BSSSection + value-1) mod value }
extrn SYS_CpuID
public PureBasicStart
;
section '.code' code readable executable
;
;
PureBasicStart:
;
PUSH dword I_BSSEnd-I_BSSStart
PUSH dword 0
PUSH dword I_BSSStart
CALL _memset
ADD esp,12
PUSH dword 0
CALL _GetModuleHandleA@4
MOV [_PB_Instance],eax
PUSH dword 0
PUSH dword 4096
PUSH dword 0
CALL _HeapCreate@12
MOV [PB_MemoryBase],eax
CALL SYS_CpuID
;
CALL _SYS_InitString@0
; :
; IncludeFile "lib.pbi"
; Procedure a()
macro MP0{
_Procedure0:
PS0=4
; *NOT NEEDED* and not included, OK
; never referenced
; EndProcedure
XOR eax,eax
_EndProcedure1:
RET
}
;
; Procedure b()
macro MP2{
_Procedure2:
PS2=4
; *NOT NEEDED* but included
; referenced only by itself (recursive)
; INCLUDED by PB
; b()
CALL _Procedure2
; EndProcedure
XOR eax,eax
_EndProcedure3:
RET
}
;
; Procedure c()
macro MP4{
_Procedure4:
PS4=4
; *NOT NEEDED* but included
; referenced by a function never referenced: d()
; EndProcedure
XOR eax,eax
_EndProcedure5:
RET
}
;
; Procedure d()
macro MP6{
_Procedure6:
PS6=4
; *NOT NEEDED* and not included, OK
; never referenced
; c()
CALL _Procedure4
; EndProcedure
XOR eax,eax
_EndProcedure7:
RET
}
;
; Procedure e()
macro MP8{
_Procedure8:
PS8=4
; NEEDED
; referenced and called
; EndProcedure
XOR eax,eax
_EndProcedure9:
RET
}
;
; e()
CALL _Procedure8
;
;
;
_PB_EOP_NoValue:
PUSH dword 0
_PB_EOP:
CALL _PB_EndFunctions
PUSH dword [PB_MemoryBase]
CALL _HeapDestroy@4
CALL _ExitProcess@4
_PB_EndFunctions:
RET
;
MP2
MP4
MP8
;
section '.data' data readable writeable
;
_PB_DataSection:
pb_public PB_DEBUGGER_LineNumber
dd -1
pb_public PB_DEBUGGER_IncludedFiles
dd 0
pb_public PB_DEBUGGER_FileName
db 0
_PB_ExecutableType: dd 0
;
; Dynamic functions jump table
;
public _SYS_StaticStringStart
_SYS_StaticStringStart:
pb_public PB_NullString
db 0
public _SYS_StaticStringEnd
_SYS_StaticStringEnd:
align 4
align 4
s_s:
dd 0
dd -1
align 4
;
section '.bss' readable writeable
_PB_BSSSection:
align 4
;
I_BSSStart:
_PB_MemoryBase:
PB_MemoryBase: rd 1
_PB_Instance:
PB_Instance: rd 1
;
align 4
PB_DataPointer rd 1
align 4
align 4
align 4
align 4
I_BSSEnd:
section '.data' data readable writeable
SYS_EndDataSection:
Code: Select all
; this is the include
Procedure LoadTIFF()
UseTIFFImageDecoder()
; code for load the tiff
EndProcedure
Procedure TIFF_DoSomethingToTheFile()
LoadTIFF()
; do something to the tiff file
EndProcedure
Procedure LoadJPEG()
UseJPEGImageDecoder()
; code for load the jpeg
MessageRequester("TEST", "Hello, I'm working!")
EndProcedure
; this is my program, is using a jpg file
LoadJPEG()
; do something to the jpeg
End
; now ... don't think you are only using the JPEG part of your include
; because the TIFF decoder has been included too in your exe !
Code: Select all
EnableASM
DisableDebugger
OpenConsole()
Global x.l = 0
Procedure proc1()
! nop
! nop
! nop
mov eax, 1
ProcedureReturn
EndProcedure
Procedure proc2()
! nop
! nop
! nop
mov eax, 2
ProcedureReturn
EndProcedure
x = proc2()
PrintN("x equals: " + Str(x))
Print("Press [ENTER] to exit... ")
Input()
CloseConsole()
End
Yes, but wasn't that clear already ?Logman wrote: As you can see in the code I only make a call to "proc2()" so only "proc2()" is actually used.
And this remark is direct to ... whom ?Logman wrote: Doing actual tests on code is far better than guessing.
Code: Select all
procedure a()
x = @b()
endprocedure
procedure b()
endprocedure
procedure c()
endprocedure
c()