	PAGE    75, 132
	TITLE   TEAM - 7        ECE 291 Spring 1995     LEGOBOT-PROJECT 4/28/95

COMMENT *
		<<<<<<<<<<<<<<< SIDE NOTES >>>>>>>>>>>>>>>

	Team 7 consists of :
		Paul Oh
		Nick Shin and
		Doug Youngwith

	The name of our legbot is: TEASER

		<<<<<<<<<<<<<<< TECH NOTES >>>>>>>>>>>>>>>

	In this final MP6 project, a fully autonomous robot is designed to do
	the following objectives:
		1) Seek out the IR laced dispenser
		2) Obtain ping pong balls from the dispenser
		3) Drive to one of the basket zone
		4) Dump the balls in to the hoop (slam dunk rule)
		5) Drive around the court to collect the balls along the side
		6) And again go for the slam dunk

	Those processes will all be foreground tasks and they will basically be
	the algorithm to complete the objectives of the game.


	The only task running in the background would be the bump sensor which
	basically means something is in the way and the situation needs to be
	dealt with.  This may be accomplished be just backing up, turn and then
	continue with the program.


	Any other specificality, please refer to
		1) MP6 LEGOBOT HANDOUT for rules and regulations
		2) VESTA SBC88A MICROCONTROLLER HANDOUT for information on the
			controller board, inputs, and outputs in use with this
			project
	*

;**********************************************************************

	PUBLIC  MAIN

STKSEG  SEGMENT STACK                   ; *** STACK SEGMENT ***
	DB      64 DUP ('STACK   ')
STKSEG  ENDS

CSEG    SEGMENT PUBLIC                  ; *** CODE SEGMENT ***
	ASSUME  CS:CSEG, DS:CSEG, SS:STKSEG, ES:NOTHING

;**********************************************************************


;=======================================================================
;               ---------------------------------------------------
;               <<<<<<<<<<   MACROS FOR DIGITAL INPUTS   >>>>>>>>>>
;               ---------------------------------------------------
;=======================================================================


;---------------------------------------------------
;<<<<<<<<<<      PORT 10H INFORMATION     >>>>>>>>>>
;---------------------------------------------------
;==============================================================================
; MACRO MIKE
; This macro function will deal with the microphone input in Port 10h.
;
;       Input:  NONE            Output: AL <- 1 if sound is sensed
;
;==============================================================================

MIKE    MACRO
	IN      AL, 10h
	AND     AL, 00000100b
	ENDM


;==============================================================================
; MACRO IR_IN
; This macro function will deal with the Infrared Reciever in Port 10h.
;       The function will lookup the particular IR reciever in question given
;       by the input in variable IR.
;
; On Port 10h for IR -
;       IR #1 : IR1 = 01000000b
;       IR #2 : IR2 = 00010000b
;
;       Input:  IR              Output: AL <- 1 if IR emittence is detected
;       
;==============================================================================

IR1     EQU     01000000b
IR2     EQU     00010000b

IR_IN   MACRO   IR
	IN      AL, 10h
	AND     AL, IR
	ENDM


;---------------------------------------------------
;<<<<<<<<<<      PORT 20H INFORMATION     >>>>>>>>>>
;---------------------------------------------------
;==============================================================================
; MACRO DIP_SW
; This macro function will deal with the dipswitch on the VESTA board in
;       port 20h.  This function will lookup the particular switch in question
;       given by the input in variable DIP.
; These switches my be used for running a different routine if needed.
;
; On Port 20h for DIP -
;       DipSwitch #1 : DIP1 = 00000001b         <<<< Starting point switch
;       DipSwitch #2 : DIP2 = 00000010b
;       DipSwitch #3 : DIP3 = 00000100b
;       DipSwitch #4 : DIP4 = 00001000b
;
;       Input:  DIP             Output: AL <- 1 if switch is depressed
;       
;==============================================================================

DIP1    EQU     00000001b
DIP2    EQU     00000010b
DIP3    EQU     00000100b
DIP4    EQU     00001000b

DIP_SW  MACRO   DIP
	IN      AL, 20h
	AND     AL, DIP
	ENDM


;==============================================================================
; MACRO BUMPIN
; This macro function will deal with the microswitch in port 20h.
;       This function will lookup the particular switch in question given
;       by the input in variable MS.
;
; On Port 20h for MS -
;       MicroSwitch #1 : MS1 = 00010000b        <<<< TUBE SENSOR
;       MicroSwitch #2 : MS2 = 00100000b        <<<< REAR SENSOR
;       MicroSwitch #3 : MS3 = 01000000b        <<<< FRONT LT SENSOR
;       MicroSwitch #4 : MS4 = 10000000b        <<<< FRONT RT SENSOR
;
;       Input:  MS              Output: AL <- 1 if switch is depressed
;
;==============================================================================

MS1     EQU     00010000b
MS2     EQU     00100000b
MS3     EQU     01000000b
MS4     EQU     10000000b

BUMPIN  MACRO   MS
	IN      AL, 20h
	AND     AL, MS
	ENDM


;=======================================================================
;               ---------------------------------------------------
;               <<<<<<<<<<   MACROS FOR ANALOG INPUTS   >>>>>>>>>>>
;               ---------------------------------------------------
;=======================================================================


;---------------------------------------------------
;<<<<<<<<<<  PORT 10h & 30h-CHANNEL INFO  >>>>>>>>>>
;---------------------------------------------------
;==============================================================================
; MACRO REFLECTIVE
; This macro procedure will deal with the reflective object sensor by writing
;       to port 10h to activate which channel is to be read in, then to port
;       30h to convert the analog data to digital data and then the sensor
;       value can be obtained be getting the data from port 30h. 
; This procedure will lookup the particular sensor in question given
;       by the input in variable RS.
;
; On Port 30h for RS -
;       ReflectiveSwitch #1 : RS1 = 0
;       ReflectiveSwitch #2 : RS2 = 2
;       ReflectiveSwitch #3 : RS3 = 4
;       ReflectiveSwitch #4 : RS4 = 6
;
;       Input:  RS              Output: AL <- contains the analog value
;                                               from 0 to 255
;
;==============================================================================

RS1     EQU     0
RS2     EQU     2
RS3     EQU     4
RS4     EQU     6

REFLECTIVE      MACRO   RS
	LOCAL   DELAY0
	MOV     AL, RS                  ; Accessing channel via RS
	OUT     10h, AL
	MOV     AL, 0                   ; Initiate conversation
	OUT     30h, AL
	MOV     CX, 30                  ; Setting up delay time
DELAY0: LOOP    DELAY0
	IN      AL, 30h
	ENDM


;==============================================================================
; MACRO PHOTO
; This macro procedure will deal with the phototransistor sensor.  This
;       procedure is just like the procedure in MACRO REFLECTIVE.
; This procedure will lookup the particular sensor in question given
;       by the input in variable PT.
;
; On Port 30h for PT -
;       PhotoTransistor #1 : PT1 = 7
;       PhotoTransistor #2 : PT2 = 1
;
;       Input:  PT              Output: AL <- contains the analog value 
;                                               from 0 to 255
;
;==============================================================================

PT1     EQU     7
PT2     EQU     1

PHOTO   MACRO   PT
	LOCAL   DELAY1 
	MOV     AL, PT                  ; Accessing channel PT
	OUT     10h, AL
	MOV     AL, 0                   ; Initiate conversation
	OUT     30h, AL
	MOV     CX, 30                  ; Setting up delay time
DELAY1: LOOP    DELAY1
	IN      AL, 30h
	ENDM


;==============================================================================
; MARCO POT
; This macro procedure will deal with the potentiometer sensor.  This
;       procedure is just like the procedure in MACRO REFLECTIVE.
; This procedure will lookup the particular sensor in question given
;       by the input in variable PM.
;
; On Port 30h for PM -
;       Potentiometer #1 : PM1 = 5
;       Potentiometer #2 : PM2 = 3
;
;       Input:  PM              Output: AL <- contains the analog value
;                                               from 0 to 255
;
;==============================================================================

PM1     EQU     5
PM2     EQU     3

POT     MACRO   PM
	LOCAL   DELAY2
	MOV     AL, PM                  ; Accessing channel PM
	OUT     10h, AL
	MOV     AL, 0                   ; Initiate conversation
	OUT     30h, AL
	MOV     CX, 30                  ; Setting up delay time
DELAY2: LOOP    DELAY2
	IN      AL, 30h
	ENDM


;=======================================================================
;               ---------------------------------------------------
;               <<<<<<<< MACRO PROCEDURES FOR MOTOR USAGE  >>>>>>>>
;               ---------------------------------------------------
;=======================================================================


;---------------------------------------------------
;<<<<<<<<<<     DC MOTOR(S) PROCEDURE     >>>>>>>>>>
;---------------------------------------------------
;==============================================================================
; MACRO MOTOR
; This macro procedure will deal with activating the motors in the legobot.
;       Motor#, speed and direction of the motors will be implemented.
;
;       Motor# is in -> MTR
;               1 = MOTOR1 in 10h       Bits : 0-3      <<< TUBE MOTOR
;               2 = MOTOR2 in 10h       Bits : 4-7      <<< RT TIRE
;               3 = MOTOR3 in 20h       Bits : 0-3      <<< LT TIRE
;       Direction in -> DIR
;       Speed value is in  -> SPD
;
;       Input:  MTR                      Output: NONE
;               SPD
;               DIR
;
;==============================================================================

MOTOR1  EQU     1
MOTOR2  EQU     2
MOTOR3  EQU     3

MOTOR   MACRO   MTR, DIR, SPD
	LOCAL   MTR2, MTR2_2, MTR3, MTREND
	PUSH    AX
	MOV     AL, MTR

	CMP     AL, 1                   ; Checking to see if motor1 is wanted
	JNE     MTR2
	MOV     AL, DIR                 ; Setting direction
	OUT     00h, AL
	MOV     AL, SPD                 ; Setting speed
	OUT     10h, AL
	JMP     MTREND

MTR2:   CMP     AL, 2                   ; Checking to see if motor2 is wanted
	JNE     MTR3
	MOV     AL, DIR                 ; Setting direction
	OUT     01h, AL

	MOV     AL, SPD                 ; Setting speed
	MOV     CL, 4                   ; Moving the speed value for Motor2 in
MTR2_2: SHL     AL, 1                   ;       bits 4-7 for port 10h
	LOOP    MTR2_2
	OUT     10h, AL
	JMP     MTREND

MTR3:                                   ; Motor3 is the only one left
	MOV     AL, DIR                 ; Setting direction
	OUT     02h, AL
	MOV     AL, SPD                 ; Setting speed
	OUT     20h, AL

MTREND: POP     AX
	ENDM


;---------------------------------------------------
;<<<<<<<<<<    FORWARD MOTOR FUNCTION     >>>>>>>>>>
;---------------------------------------------------
;==============================================================================
; MACRO FORWARD
; This macro function is just to make coding easier.
;       Only speed needs to be implemented given in variable SPDF.
;
;       Input:  SPDF                    Output: NONE
;
;==============================================================================

FORWARD MACRO   SPDF
	MOTOR   2, 0, SPDF              ; Motor 2 is accessed and going forward
	MOTOR   3, 0, SPDF              ; Motor 3 is accessed and going forward
	ENDM


;---------------------------------------------------
;<<<<<<<<<<    REVERSE MOTOR FUNCTION     >>>>>>>>>>
;---------------------------------------------------
;==============================================================================
; MACRO REVERSE
; This macro function is just to make coding easier.
;       Only speed needs to be implemented given in variable SPDR.
;
;       Input:  SPDR                    Output: NONE
;
;==============================================================================

REVERSE MACRO   SPDR
	MOTOR   2, 1, SPDR              ; Motor 2 is accessed and going reverse
	MOTOR   3, 1, SPDR              ; Motor 3 is accessed and going reverse
	ENDM


;---------------------------------------------------
;<<<<<<<<<<      STOP MOTOR FUNCTION      >>>>>>>>>>
;---------------------------------------------------
;==============================================================================
; MACRO STOP
; This macro function is just to make coding easier.
;
;       Input:  NONE                    Output: NONE
;
;==============================================================================

STOP    MACRO
	MOTOR   1, 0, 000h              ; Motor 1, 2, and 3 are accessed and
	MOTOR   2, 0, 000h              ;       all set to clear
	MOTOR   3, 0, 000h
	ENDM


;---------------------------------------------------
;<<<<<<<<<<   LEFT TURN MOTOR FUNCTION    >>>>>>>>>>
;---------------------------------------------------
;==============================================================================
; MACRO LEFT
; This macro function is just to make coding easier.  All that is done is that
;       the left tire will rotate faster than the right tire.
;
;       Input:  NONE                    Output: NONE
;
;==============================================================================

LEFT    MACRO
	MOTOR   2, 0, 03h               ; Setting RT parameters
	MOTOR   3, 0, 0Fh               ; Setting LT parameters
	ENDM


;---------------------------------------------------
;<<<<<<<<<<   RIGHT TURN MOTOR FUNCTION   >>>>>>>>>>
;---------------------------------------------------
;==============================================================================
; MACRO RIGHT
; This macro function is just to make coding easier.  All that is done is that
;       the right tire will rotate faster than the left tire.
;
;       Input:  NONE                    Output: NONE
;
;==============================================================================

RIGHT   MACRO
	MOTOR   2, 0, 0Fh               ; Setting RT parameters
	MOTOR   3, 0, 03h               ; Setting LT parameters
	ENDM


;---------------------------------------------------
;<<<<<<<<<<     SERVO MOTOR PROCEDURE     >>>>>>>>>>
;---------------------------------------------------
;==============================================================================
; MACRO SERVO
; This macro procedure will deal with activating the servo in the legobot.
;       Only angle positioning needs to be implemented given in variable ANG.
;
;       Input:  ANG                     Output: NONE
;
;==============================================================================

POS0    EQU     000h
POS1    EQU     0F0h

SERVO   MACRO   POS
	MOV     AL, POS
	OUT     20h, AL
	ENDM



;---------------------------------------------------
;<<<<<<<<<   MISC. STUFF FOR GENERAL USE   >>>>>>>>>
;---------------------------------------------------

;---------------------------------------------------
;<<<<  MACROS FOR HEX DISPLAY (FOR DEBUGGING)  >>>>>
;---------------------------------------------------

HEX0    MACRO
	MOV     AL, 1
	OUT     06h, AL
	OUT     05h, AL
	OUT     04h, AL
	OUT     03h, AL
	ENDM

HEX1    MACRO
	MOV     AL, 1
	OUT     06h, AL
	OUT     05h, AL
	OUT     04h, AL
	MOV     AL, 0
	OUT     03h, AL
	ENDM

HEX2    MACRO
	MOV     AL, 1
	OUT     06h, AL
	OUT     05h, AL
	OUT     03h, AL
	MOV     AL, 0
	OUT     04h, AL
	ENDM

HEX3    MACRO
	MOV     AL, 1
	OUT     06h, AL
	OUT     05h, AL
	MOV     AL, 0
	OUT     04h, AL
	OUT     03h, AL
	ENDM

HEX4    MACRO
	MOV     AL, 1
	OUT     06h, AL
	OUT     04h, AL
	OUT     03h, AL
	MOV     AL, 0
	OUT     05h, AL
	ENDM

HEX5    MACRO
	MOV     AL, 1
	OUT     06h, AL
	OUT     04h, AL
	MOV     AL, 0
	OUT     05h, AL
	OUT     03h, AL
	ENDM

HEX6    MACRO
	MOV     AL, 1
	OUT     06h, AL
	OUT     03h, AL
	MOV     AL, 0
	OUT     05h, AL
	OUT     04h, AL
	ENDM

HEX7    MACRO
	MOV     AL, 1
	OUT     06h, AL
	MOV     AL, 0
	OUT     05h, AL
	OUT     04h, AL
	OUT     03h, AL
	ENDM

HEX8    MACRO
	MOV     AL, 1
	OUT     05h, AL
	OUT     04h, AL
	OUT     03h, AL
	MOV     AL, 0
	OUT     06h, AL
	ENDM

HEX9    MACRO
	MOV     AL, 1
	OUT     05h, AL
	OUT     04h, AL
	MOV     AL, 0
	OUT     06h, AL
	OUT     03h, AL
	ENDM

HEXA    MACRO
	MOV     AL, 1
	OUT     05h, AL
	OUT     03h, AL
	MOV     AL, 0
	OUT     06h, AL
	OUT     04h, AL
	ENDM

HEXB    MACRO
	MOV     AL, 1
	OUT     05h, AL
	MOV     AL, 0
	OUT     06h, AL
	OUT     04h, AL
	OUT     03h, AL
	ENDM

HEXC    MACRO
	MOV     AL, 1
	OUT     04h, AL
	OUT     03h, AL
	MOV     AL, 0
	OUT     06h, AL
	OUT     05h, AL
	ENDM

HEXD    MACRO
	MOV     AL, 1
	OUT     04h, AL
	MOV     AL ,0
	OUT     06h, AL
	OUT     05h, AL
	OUT     03h, AL
	ENDM

HEXE    MACRO
	MOV     AL, 1
	OUT     03h, AL
	MOV     AL, 0
	OUT     06h, AL
	OUT     05h, AL
	OUT     04h, AL
	ENDM

HEXF    MACRO
	MOV     AL, 1
	OUT     06h, AL
	OUT     05h, AL
	OUT     04h, AL
	OUT     03h, AL
	ENDM

;---------------------------------------------------
;<<<<<<   EASY REFERENCE FOR VALUES OF SPEED  >>>>>>
;---------------------------------------------------

VSLOW   EQU     3
SLOW    EQU     5
MEDIUM  EQU     7
QUICK   EQU     9
FAST    EQU     13
VFAST   EQU     15


;---------------------------------------------------
;<<<<<<<  MACRO PROCEDURE FOR "TIME KILLER"  >>>>>>>
;---------------------------------------------------

TIMERX  MACRO   NUM_TIMES
	LOCAL   TX_1, TX_2
	PUSH    CX
	MOV     CX, NUM_TIMES
TX_2:   PUSH    CX
	MOV     CX, 10
TX_1:   LOOP    TX_1
	POP     CX
	LOOP    TX_2
	POP     CX
	ENDM


;**********************************************************************

;============================================
; *******************************************
;     ************** MAIN **************
; *******************************************
;     This is where the program starts.
;============================================

MAIN    PROC    FAR
	MOV     AX, CSEG
	MOV     DS, AX

	STOP				; Initializing all motors including
	SERVO   POS0			;	servo to "zero" position
	HEX1				; Indication board is ready

DIP4_IN: DIP_SW DIP4			; A "start" switch
	CMP     AL, DIP4
	JE      DIP4_IN

MIKE1:  MIKE				; Waiting for the "jump ball whistle"
	CMP     AL, 00000100b
	JNE     MIKE1

MAINLP:	DIP_SW  DIP4			; A stoping point in the main procedure
	CMP     AL, DIP4		;	"loop" and then the system is
	JE      DIP4_IN			;	reseted to the "starting state"

	HEX2
	; PUT IN IR DETECTION SENSOR ROUTINE
	; AND TURNING ROUTINE IN HERE

	FORWARD 0Dh			; Heading towards the dispenser tube
MAINB:  BUMPIN  MS1			; Stopping at the dispenser tube when
	CMP     AL, MS1			;	(switch is zero when contact is
	JE      MAINB			;	made)
	STOP
	MOV     CX, 4
MAINL1: TIMERX  20000
	LOOP    MAINL1

	HEX3
	MOTOR   1, 0, 0Fh		; Extracting ping pong balls from the
	MOV     CX, 7			;	dispenser
MAINL2: TIMERX  20000
	LOOP    MAINL2
	STOP

	HEX4
	; PUT IN PHOTOTRANSISTOR SENSOR ROUTINE
	; AND TURNING ROUTINE IN HERE

TO_TARGET:
	REVERSE	0Dh			; Heading towards the basket zone
	MOV     CX, 6
MAINL3: TIMERX  20000
	LOOP    MAINL3

	HEX5
	; PUT IN REFLECTOR SENSOR ROUTINE
	; AND ADJUSTING ROUTINE IN HERE

	STOP				; At the target zone
	MOV     CX, 4
MAINL4: TIMERX  20000
	LOOP    MAINL4

	SERVO   POS1			; Opening hatch for the "slam dunk"
	TIMERX  40000
COMMENT *
	REVERSE 0Dh			; Shaking out any ping pong balls that
	TIMERX  500			;	at "stuck" in the bin
	FORWARD 0Dh
	TIMERX  500
	STOP
	HEX6
	MOV     CX, 4
MAINL5:    TIMERX  20000
	LOOP    MAINL5
*

	SERVO   POS0			; Closing the hatch
	TIMERX  40000

	JMP     MAINLP			; Going for some more ping pong balls

MAIN_END:
MAIN    ENDP



COMMENT *
;==============================================================================


;=======================================================================
;               ---------------------------------------------------
;		<<<<<<<<   SOME PROCEDURES, BUT NOT USED   >>>>>>>>
;		<<<<<<<<<     DUE TO TIME CONSTRAINTS     >>>>>>>>>
;               ---------------------------------------------------
;=======================================================================


;---------------------------------------------------
;<<<<<<<<    IR DETECTION SENSOR ROUTINE    >>>>>>>>
;---------------------------------------------------

IR1:	MOV     CX, 30                  ; The IR sensor will not work while
	LOOP    DISP1                   ;       motor is running so, this is
					;       just a time killer
	IR_IN   IR1                     ; Looking for the IR emitter with
	CMP     AL, IR1			;	IR detector #1
	JE      GOTOTUBE

	LEFT                            ; Moving to get in better position
	TIMERX	500
	STOP
	CALL    BMP_CHK                 ; Checking for collision
	JMP     IR1

GOTOTUBE:
	CALL    BMP_CHK                 ; Checking for collision, just in case


;---------------------------------------------------
;<<<<<<<<   PHOTOTRANSISTOR SENSOR ROUTINE  >>>>>>>>
;---------------------------------------------------

PHT1:	PHOTO	IR1                     ; Looking for the light source with
	CMP     AL, IR1			;	phototransistor detector #1
	JE      TO_BASKET

	RIGHT                           ; Moving to get in better position
	TIMERX	500
	STOP
	CALL    BMP_CHK                 ; Checking for collision
	JMP     PHT1

TO_BASKET:
	CALL    BMP_CHK                 ; Checking for collision, just in case


;---------------------------------------------------
;<<<<<<<<<    REFLECTOR SENSOR ROUTINE     >>>>>>>>>
;---------------------------------------------------
;	REMEMBER TO TAKE OUT THE TIMER FOR REVERSE MOVEMENT!!!!
;;;;;;;;;;;;;;;;;;;;;;;;;;;
MOVT_BUF        DB      070h		; Buffer -- indication for turning time
;;;;;;;;;;;;;;;;;;;;;;;;;;;

	REFLECTIVE      RS1		; Checking to see if reflector sensor#1
	CMP     AL, 0240		;	(left back) is on a black surface
	JG      CK_RS2

	HEXB
	REFLECTIVE      RS2
	CMP     AL, 0240
	JL      TO_TARGET               ; CONTINUE -- not on a black surface
;       INC     MOVT_BUF		; Right back sensor is in, so must turn
;       CMP     MOVT_BUF, 0F0h		;	hard right to center the machine
;       JE      BACKOUT			; Something is wrong, so backing up and
	RIGHT				;	redo search
	TIMERX  800
	JMP     TO_TARGET
	
	HEXC
CK_RS2: REFLECTIVE      RS2		; Sensor#1 is in and checking for #2
	CMP     AL, 0240
	JG      TARGET			; In the target zone
;       DEC     MOVT_BUF		; Sensor #2 is not on a black surface so
;       CMP     MOVT_BUF, 10h		;	turning the machine hard left
;       JE      BACKOUT			; Something is wrong, so backing up and
	LEFT				;	redo search
	TIMERX  800
	JMP     TO_TARGET

BACKOUT: HEXE
	MOV     MOVT_BUF, 070h		; Restarting the search for the black
	STOP				;	surface
	FORWARD 0Dh
	TIMERX  1000
	STOP
	JMP     TO_TARGET

TARGET:	MOV     MOVT_BUF, 070h		; Resetting for the next time this
					;	search is run again
	REVERSE	0Dh			; Backing up a little to reach the
	TIMERX	2000			;	basket for a "slam dunk"


;==============================================================================
; SUBROUTINE BMP_CHK
; This subroutine will go specific sensors to check to see if the bumper sensor
;       on the legobot is activated.  The sensors to be checked are the 
;       following:
;
;       1) Bumper switch by the unloading dock
;       2) Bumper switch by the ping pong ball loading - LEGOBOT guide rails
;
;	INPUT:	NONE		OUTPUT:	NONE
;
;==============================================================================
;;;;;;;;;;;;;;;;;;;;;;;
	PUBLIC	BMP_CHK
;;;;;;;;;;;;;;;;;;;;;;;

BMP_CHK PROC    NEAR


	BUMPIN	MS2			; Checking to see if something is in
	CMP	AL, MS2			;       the way
	JNE	BMP1
	FORWARD	0D0H
	TIMERX	3000
	STOP
	JMP	BMP_END

BMP1:	BUMPIN	MS3
	CMP	AL, MS3
	JNE	BMP2
	REVERSE 0Dh
	TIMERX	3000
	RIGHT
	TIMERX	500
	STOP
	JMP	BMP_END

BMP2:	BUMPIN	MS4
	CMP	AL, MS4
	JNE	BMP_END
	REVERSE	0Dh
	TIMERX	3000
	LEFT
	TIMERX	500
	STOP

BMP_END:
BMP_CHK ENDP


;==============================================================================
*


CSEG    ENDS
	END     MAIN
