Stepping Motor Control For CSS Compiler

 
#include <16F877.h>
#fuses  XT,NOLVP,NOWDT,NOPROTECT
#use    delay(clock = 4000000)     
#use    fast_io(A)
#use    fast_io(B) 
byte    num[5] = {0x00,0x01,0x02,0x04,0x08};   
int8    disp,i; 
void Forward(){

   for(i=0; i<=4;i++){
         disp =num[i];
         output_b(disp);
         delay_ms(200);
    }
 } 
void Backward(){
    for(i=4;i>0;i--){
         disp =num[i];
         output_b(disp);
         delay_ms(200);
    }
 } 
void Stop(){ 
    disp =0;
    output_b(disp);
    delay_ms(50);
 } 

void main(){
   setup_adc(adc_off);
   set_tris_a(0xFF);           
   set_tris_b(0B00000000);
   stop();
while(true){
      if(!input(pin_a0)){
         do{
           Forward(); 
          } 
        while(input(pin_a2));  
      }
      else if(!input(pin_a1)){  
         do{
           Backward();
          } 
        while(input(pin_a2));                    
      }

      else if(!input(pin_a2)){
               Stop();           
       }
       else{}

   }
}