
	;Open the Dos library.
		MOVE.L	4.w,A6
		LEA	DosName,A1
		JSR	_LVOOldOpenLibrary(A6)
		MOVE.L	D0,DosBase

	;Check the dos library version
		MOVE.L	D0,A0
		CMP.W	#37,20(A0)
		BLO	WrongDos

	;Call ReadArgs to pre-parse the command line.
		MOVE.L	DosBase,A6
		MOVE.L	#Template,D1
		MOVE.L	#Array,D2
		MOVEQ.L	#0,D3
		JSR	_LVOReadArgs(A6)
		MOVE.L	D0,RdArgs
		BEQ	SyntaxError

	;Check for 'on' parameter
		CMP.L	#0,Array
		BNE	LedOn
	
	;Check for 'off' parameter
		CMP.L	#0,Array+4
		BNE	LedOff
		
	;Neither parameter was given so do syntax error.
		BRA	SyntaxError

SyntaxError:
	;Print a message telling user of the correct syntax
		MOVE.L	DosBase,A6
		MOVE.L	#SyntaxErrorText,D1
		JSR	_LVOPutStr(A6)
		BRA.S	Exit

LedOn:
	;Turn on the LED
		BCLR	#1,$BFE001
		BRA.S	Exit

LedOff:
	;Turn off the LED
		BSET	#1,$BFE001

Exit:
	;Free the RdArgs structure
		MOVE.L	DosBase,A6
		MOVE.L	RdArgs,D1
		JSR	_LVOFreeArgs(A6)

	;Close the dos library
		MOVE.L	4.w,A6
		MOVE.L	DosBase,A1
		JSR	_LVOCloseLibrary(A6)
		
WrongDos:
	;Return to the CLI
		CLR.L	D0
		RTS



		SECTION data,data

Template:		DC.B	"ON/S,OFF/S",0
DosName:		DC.B	"dos.library",0
SyntaxErrorText:	DC.B	"LED [ON|OFF]		©1999 Mike Archer",10,10,0
CursorOnText:		DC.B	$9B," p",0
CursorOffText:		DC.B	$9B,"0 p",0
Version:		DC.B	"$VER: LED 1.1",0

		SECTION data2,bss

DosBase:	DS.L	1
RdArgs:		DS.L	1
Array:		DS.L	2


