3Fermer5
FarewellLe 06/01/2014 à 22:11
cry

Voilà ce que ça donne, chez moi, au final :
ValidateSymbolName
StrCommonSymbolsChars:	dc.b	"-"
StrFirstSymbolsChar:	dc.b	"\_@:.",0
StrLettersAndFigures:	dc.b	"09"
StrLetters:		dc.b	"AZaz",0
;===============================================================================
;
;	ValidateSymbolName
;
;	in	a0	char* str
;		fp	Stack frame
;
;	out	d0.w	Number of valid chars
;
;	destroy	d0.w
;
;===============================================================================

ValidateSymbolName:

	movem.l	d1/a0-a2,-(sp)

	;----------------------------------------------------------------------
	;	First char may be \ _ @ : . A-Z a-z
	;----------------------------------------------------------------------

	move.b	(a0)+,d0
	lea	StrFirstSymbolsChars(pc),a1
	lea	StrLetters(pc),a2
	bsr	\CheckCharsAndIntervals
	bne.s	\End

	;----------------------------------------------------------------------
	;	Other chars may be \ _ @ : . A-Z a-z 0-9 -
	;----------------------------------------------------------------------

\NextChar:
	lea	StrCommonSymbolsChars(pc),a1
	lea	StrLettersAndFigures(pc),a2
	bsr	\CheckCharsAndIntervals
	beq.s	\NextChar

	;----------------------------------------------------------------------
	;	Remove trailing ':' and return the number of valid chars
	;----------------------------------------------------------------------

\End:	move.l	(sp)+,d1
\Loop:	subq.l	#1,a0				; Point to the first invalid char
	cmp.l	(sp),a0				; Return if it is the beginning of the string
	beq.s	\Ret
	cmpi.b	#':',-1(a0)			; Remove the last valid char if it is ':'
	beq.s	\Loop

\Ret:	suba.l	(sp),a0
	move.w	a0,d0
	movem.l	(sp)+,a0-a2
	rts

	;----------------------------------------------------------------------
	;	Check for chars and intervals
	;----------------------------------------------------------------------

\CheckCharsAndIntervals:			; Return Z-Flag == 1 if found, else 0
	move.b	(a1)+,d1
	beq.s	\CheckIntervals
	cmp.b	d0,d1
	bne.s	\CheckCharsAndIntervals
\Found:	moveq.l	#0,d0
	rts

\CheckIntervals:
	move.b	(a2)+,d1
	beq.s	\NotFound
	cmp.b	d1,d0
	bcs.s	\NotFound
	cmp.b	(a2)+,d0
	bls.s	\Found
	bra.s	\CheckIntervals

\NotFound:
	moveq.l	#1,d0
	rts

En fait, j'utilise jamais mes jolis tricks tsss

fun fact : A68k ne considère pas que les ':' en fin de symboles en fassent partie. Mais ils sont tolérés sur les labels, en nombre quelconque.
Donc :
abc:::: est un label valide, le symbole est 'abc'
abc::::: equ 2 est un equate valide, le symbole est 'abc'
bra label:::: est invalide