
	INCDIR	Includes:
	INCLUDE	exec/resident.i

*********************************************************************
*	IN:	e.BPTR	A0 first segment
*	OUT:	e.APTR	D0 start of verstring

	XDEF	_GetResidentID

_GetResidentID	move.l	(a7)+,(a7)	;because Oberon 3.11 pushes any senseless waste
		moveq	#0,d0				;return 0 if no match
	
.seg		adda.l	a0,a0				;BPTR -> APTR
		adda.l	a0,a0
		move.l	(-4,a0),d1			;D1 size of segment
		move.l	(a0)+,a1			;A1 BPTR to next segment
	
		subq.l	#8,d1
		lsr.l	#1,d1				;because WORDs
		subq.l	#1,d1				;because DBcc
.lp		cmpi.w	#RTC_MATCHWORD,(a0)+
		dbeq	d1,.lp
		beq	.found

.next		addq.w	#1,d1				;hunks > 128k
		subq.l	#1,d1
		bcc	.lp

		move.l	a1,a0
		move.l	a0,d1
		bne	.seg
		rts

.found		subq.w	#1,d1				;because DBcc
		blo	.next
		subq.l	#2,a0
		cmp.l	(RT_MATCHTAG,a0),a0
		addq.l	#2,a0
		bne	.lp
		move.l	(RT_IDSTRING-2,a0),d0		;D0 = APTR verstring
		rts

*********************************************************************

	END
