English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 07 June 2020, 15:13   #1
Antiriad_UK
OCS forever!
 
Antiriad_UK's Avatar
 
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
xref best practice?

Hi,

I have a library that is used by different source files that contains various useful functions defined with xdef. How do you tend to add the xref commands? I'm doing this at the moment:
Code:
	include "../Framework/IntroLibrary.i"

; Additional external symbols 
	xref	FW_CheckUserQuitSignal_A6
	xref	FW_ClearBuffer_BlitCPU_A6
	xref	FW_ClearBuffer_CPU
	xref	FW_CopyBuffer_CPU
	xref	FW_CPUClearBuffer
	xref	FW_GetFrame
	xref	FW_InitCopperBplPtrs
	xref	FW_InitCopperColsFromPalette
	xref	FW_IsFrameOver
	xref	FW_PreMultCreate_W
	xref	FW_SetLev3Irq
	xref	FW_WaitFrame
	xref	FW_WaitRaster_A6
	xref 	FW_VBlankProxy

	xref	LIB_RGB12_Interpolate_Fast
	xref	LIB_RGB12_Interpolate_Fast_Palette
	xref	LIB_NRV2S_Depack
Which works fine. But it's a pain to have to add all the xrefs you need as that is always different (sometimes I use a couple of routines, sometimes lots).

I could always create a new file like "IntroLibrary_xref.i" and just have all the xrefs in there and include them so I've always got all the functions available and don't have to think about it. But then vasm complains about xrefs to unused functions. You can turn that warning off with -nowarn=62 though.

Had a quick look at the TrapRunner source and this seems to be doing the top version. Only adding the xrefs required in a particular file.

Just curious on what others do
Antiriad_UK is offline  
Old 07 June 2020, 18:39   #2
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by Antiriad_UK View Post
Just curious on what others do
Usually a blob with includes (even nested), so a big mess.

ross is online now  
Old 07 June 2020, 21:01   #3
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Hmm. You saw what I did in Trap Runner, because I like to have an overview which symbols I imported from which modules. This is also the reason I implemented that warning - to make it easy to find unnecessary XREFs.

But there is no problem to XREF any symbol from any object you link with. It doesn't even appear in the object file, when an XREF is unused.

There is also a third option: don't use XREF at all and don't specify the -x option. vasm will automatically import all unknown symbols (other assemblers might not).
phx is offline  
Old 07 June 2020, 22:04   #4
Antiriad_UK
OCS forever!
 
Antiriad_UK's Avatar
 
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
Hmm, I think I'll just ditch the -x. Less work all around for me
Antiriad_UK is offline  
Old 08 June 2020, 08:46   #5
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by Antiriad_UK View Post
Just curious on what others do
I don't use xref. Instead, i abuse of the include directive.
meynaf is offline  
Old 08 June 2020, 09:22   #6
Antiriad_UK
OCS forever!
 
Antiriad_UK's Avatar
 
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
I used to as well but in the initial versions of the visual studio code debugger I used it couldn’t handle source level debugging within includes so I got into the habit of separating everything. A bit of a pain at first but much neater now.
Antiriad_UK is offline  
Old 09 June 2020, 11:37   #7
sparhawk
Registered User
 
sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
In vasm, I use the '::' syntax to export symbols. I don't need to use any xref/xdef with this. Or am I missing something?
sparhawk is offline  
Old 13 April 2023, 14:23   #8
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
If I assemble a single assembly file to an object file (no linking) and put an "xdef randomsymbol" statement in the file, I get:
Quote:
warning 62: imported symbol <randomsymbol> was not referenced
Shouldn't that be an error (and a different message) since I am exporting a non-existing symbol?

If I change xdef to xref, I get the exact same warning, by the way.

vasm command: vasmm68k_mot -quiet -m68000 -Fhunk -showcrit -x -o <object> <source>

Last edited by hooverphonique; 13 April 2023 at 14:38. Reason: vasm line
hooverphonique is offline  
Old 13 April 2023, 21:01   #9
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
In fact
xdef
and
xref
refer to the same function in vasm's mot-syntax module. It is best comparable to the
.global
directive of std-syntax (GNU-as).
This means an xref'd/xdef'd symbol stays xref until it is defined, which makes it xdef.

Maybe for better error checking and Devpac compatibility I should add some flags to differentiate between these two?
phx is offline  
Old 14 April 2023, 10:56   #10
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
Quote:
Originally Posted by phx View Post
Maybe for better error checking and Devpac compatibility I should add some flags to differentiate between these two?
Well, that's up to you - it would be more intuitive to get an error when you export a non-existing symbol, but if not, I think at least you should update the documentation with something similar to what you said above
hooverphonique is offline  
Old 14 April 2023, 12:46   #11
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Done (last night).

Try today's daily source snapshot: http://sun.hasenbraten.de/vasm/daily/vasm.tar.gz
phx is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Soldering practice: Charlie Hardware mods 7 22 March 2010 14:14
Will Bridge Practice series needs an overhaul mk1 HOL data problems 1 02 April 2009 21:55

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:57.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.12561 seconds with 15 queries