#define __16F876
#include "pic16f876.h"

// How do I set the __CONFIG word?  Bingo, libero.it gives it in one of his questions:
typedef unsigned int word;
word at 0x2007  __CONFIG = _CP_OFF & _WDT_OFF & _BODEN_ON & \
         _PWRTE_ON & _HS_OSC & _WRT_ENABLE_ON & \
         _LVP_OFF & _DEBUG_OFF & _CPD_OFF;
//Should look like this: 0x3f72;

unsigned char count, x;
unsigned char ms_delay;

void timer_intr() interrupt 0 {
  ms_delay++;
  PIR1 = 0;
  PEIE = 1;
}

void main() {
  NOT_RBPU=0;
  T2CON=0x7f;
  GIE = 1;
  PEIE = 1;
  //INTCON=0xc0;
  PIR1 = 0;
  PIE1 = 2;
  PR2 = 200;
  
  TRISB = 0;
  count = 0;
  while(1) {
    count = ms_delay;
    x = PIE1;
    PORTB = (count & 0xf0) | (x & 0xf);
  }
}
