This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LAST segment misplacement

hi,

according manual, when we need a segment to be placed at the end of specified memory we should use linker directive SEGMENTS. Well, in the field "User Segments" of LX51 Locate I have next string:

?PR?LAST(LAST)
Then next test program:
; reset vector --------------------------;
?PR?RESET	SEGMENT CODE AT 0x0000
		RSEG	?PR?RESET
		JMP	START
; timer 0 vector ------------------------;
?PR?T0INT	SEGMENT CODE AT 0x000B
		RSEG	?PR?T0INT
		JMP	T0INT

; work segment --------------------------;
?PR?TEST	SEGMENT CODE
		RSEG	?PR?TEST
START:		JMP	$
T0INT:		RETI

; last segment --------------------------;
?PR?LAST	SEGMENT CODE
		RSEG	?PR?LAST
		NOP

		END

produces next map file:
START     STOP      LENGTH    ALIGN  RELOC    MEMORY CLASS   SEGMENT NAME
=========================================================================
* * * * * * * * * * *   C O D E   M E M O R Y   * * * * * * * * * * * * *
000000H   000002H   000003H   BYTE   AT..     CODE           ?PR?RESET
000003H   000005H   000003H   BYTE   UNIT     CODE           ?PR?TEST
000006H   000006H   000001H   BYTE   UNIT     CODE           ?PR?LAST
000007H   00000AH   000004H   ---    ---      **GAP**
00000BH   00000DH   000003H   BYTE   AT..     CODE           ?PR?T0INT
And this is wrong because last segment named ?PR?LAST is not last one in the code space area.
But when I use next test program:
; reset vector --------------------------;
?PR?RESET	SEGMENT CODE AT 0x0000
		RSEG	?PR?RESET
		JMP	START
; timer 0 vector ------------------------;
		ORG	0x000B
		JMP	T0INT

; work segment --------------------------;
?PR?TEST	SEGMENT CODE
		RSEG	?PR?TEST

START:		JMP	$
T0INT:		RETI

; last segment --------------------------;
?PR?LAST	SEGMENT CODE
		RSEG	?PR?LAST
		NOP

		END
the MAP file shows correct results:
START     STOP      LENGTH    ALIGN  RELOC    MEMORY CLASS   SEGMENT NAME
=========================================================================
* * * * * * * * * * *   C O D E   M E M O R Y   * * * * * * * * * * * * *
000000H   00000DH   00000EH   BYTE   AT..     CODE           ?PR?RESET
00000EH   000010H   000003H   BYTE   UNIT     CODE           ?PR?TEST
000011H   000011H   000001H   BYTE   UNIT     CODE           ?PR?LAST

The only difference I see is that in the first case there is code gap in which linker has placed the last segment. Is there a way to avoid such behaviour?

Thanks,
Oleg