SPLat Logo

Builder: ONCEINLINE segment qualifier

NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map

Builder: ONCEINLINE segment qualifier

The ONCEINLINE segment qualifier allows you to have the same bit of code in two or more source (.spt) files but only get one copy in the final result. The final code is positioned according to where it is located in the source file, not according to where the segment name is located in the build (.b1d) file. (c.f. ONEONLY)

Example:

Say you have written two modules for your library, ModA.spt and ModB.spt. Both these modules use a subroutine RotR4, which rotates the X register 4 positions to the right. You want RotR4 to be contained in both library modules because they can be used separately in some jobs but both together in others. The two files might look something like this:

1st file, ModA.spt

;<CODESEG>
ModAStfuff:
;	... do some stuff
		GoSub		RotR4
;	....  more stuff
;<ROTR4SEG>	;Here's the rotate subroutine in ModA
RotR4:	RorM
		RorM
		RorM
		RorM
		Return
;<CODESEG>
;	...  Back to more "main" module A stuff

2nd file, ModB.spt

;<CODESEG>
ModBStfuff:
;	... do some stuff
		GoSub		RotR4
;	....  more stuff
;<ROTR4SEG>	;Here's the rotate subroutine in ModB
RotR4:	RorM
		RorM
		RorM
		RorM
		Return
;<CODESEG>
;	...  Back to more "main" module B stuff

In the build file:

CODESEG
ROTR4SEG ONCEINLINE
#---
ModA.SPT
ModB.SPT

The end result after the build will be:

ModAStfuff:
;	... do some stuff
		GoSub		RotR4
;	....  more stuff
;Here's the rotate subroutine in ModA
RotR4:	RorM
		RorM
		RorM
		RorM
		Return

;	...  Back to more "main" module A stuff
ModBStfuff:
;	... do some stuff
		GoSub		RotR4
;	....  more stuff
;	...  Back to more "main" module B stuff

As you can see, only one copy of RotR4 has been included, and it is positioned as it was in the original .spt file.