;------------------------------------------------------------------------------
;Name: example7.asm
;Description: Example 8051 assembly program
;Programmer: Roger Arrick - Arrick Robotics (c)
;Language: 8051 ASM
;Date: 9/7/98
;Edit: 1
;
;Function:
;Allows the Dip switch to control the headlight, laser, and LEDs.
;Example program used to test the process of assembling, downloading
;and running user assembly programs.
;See the trilodef.asm for details about system functions.
;
;Example DOS batch file to assemble and upload to Trilobot.
;Assumes COM1 serial port connected to Trilobot.
;Assumes example7.asm program is in C:\TRILOBOT directory.
;Assumes Dunfield Micro-C/asm is in C:\MC directory.
;Set Trilobot to download mode first.
;
;    cd \trilobot
;    c:\mc\macro example7.asm > example7.as
;    c:\mc\asm51 example7.as -I -F -S
;    mode com1:9600,n,8,1
;    copy c:\trilobot\example7.hex com1:
;
;
;Modules used:
;  trilodef.asm
;
;Revision History:
;
;Public Routines:
;
;Public Variables:
;
;Public Constants:
;
;Private Routines:
;
;Private Variables:
;
;Private Constants:
;
;------------------------------------------------------------------------------


	include	"trilodef.asm"	;Trilobot system definitions.

	org	0100h		;Start program above vectors.

ex7:
	;LCD signon.
	lcall	trmclr		;Clear LCD.
	lcall	trmpsi		;Message on LCD.
	db	0		;Top line.
	str	'Trilobot'
	db	0
	lcall	trmpsi		;Message on LCD.
	db	40h		;Bottom line.
	str	'Example7.asm'
	db	0

	;Wait.
	mov	a,#1		;Wait 1 sec
	lcall	utlwas

	;Sound signon.
	mov	a,#8h		;'Hello' code.
	lcall	sndput
ex70:
	;If N key pressed then return to system
	lcall	trmgk		;Get keypad status.
	jnc	ex71
	ljmp	sysres		;If key pressed then return
				;to system.
	;Check dip switch.
ex71:	lcall	utlgd		;Get dip switch into A.

	;Dip switch #1.
	jnb	acc.0,ex72		;If switch #1 ON then
	lcall	utlhlon		;Headlight on,
	ljmp	ex73
ex72:	lcall	utlhloff		;else Headlight off.
	
	;Dip switch #2.
ex73:	jnb	acc.1,ex74		;If switch #2 ON then
	lcall	utllaon		;Laser on,
	ljmp	ex75
ex74:	lcall	utllaoff		;else Laser off.

	;Dip switch #3.
ex75:	jnb	acc.2,ex76		;If switch #2 ON then
	lcall	utlrlon		;red LED on,
	ljmp	ex77
ex76:	lcall	utlrloff		;else red LED off.

	;Dip switch #4.
ex77:	jnb	acc.3,ex78		;If switch #2 ON then
	lcall	utlglon		;green LED on,
	ljmp	ex70
ex78:	lcall	utlgloff		;else green LED off.

	ljmp	ex70		;Loop.

;----------------------------------------------------------------------
	end
