//----------------------------------------------------------------------
//----------------------------------------------------------------------
//Template, version 4 (containing an AND gate program)
//----------------------------------------------------------------------
//----------------------------------------------------------------------
ubyte global g_obyt, g_polarity, g_mode
include "S215XC_Std_func_4.bas"		//Include the S215 standard functions

//----------------------------------------------------------------------
proc main()

ubyte in0, in1, ibyt, out0	//Declare variables
Initp(0, 1)			//Do initialization

while 1==1 do			//Loop forever
  ibyt = GetInBts()		//Get input byte
  in0 = SelBit(ibyt,0)		//Put bit 0 into in0
  in1 = SelBit(ibyt,1)		//Put bit 1 into in1
  
  if in0 == 1 then
    if in1 == 1 then
      out0 = 1			//If the computer reaches here,
				//both bit 0 and bit 1 are 1,
				//and the AND "gate" should output
				//a 1. 
    else
      out0 = 0
    endif
  else
    out0 = 0
  endif

  Ob(out0, 0, 1)		//Output whatever is in out0 to bit 0
 
done

endproc
//----------------------------------------------------------------------
