
#include<reg51.h>
#include<stdio.h>
# define servoport P2
static unsigned char ms_tenth_countdown;

// dynamically setup table.
// Indexed top down.
// setup this table glitchlessly (IRQ save).
// (located absolutely at the start of a 256 byte block)
unsigned char __xdata __at(0x0000) table_P2_over_time[200 + 1];

table_P2_over_time[200 + 1]={0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0d,0x0d,0x0d,0x0d,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
// for executing the function servo(23,10,14,21); of my previous code.

void Timer0_ISR (void) interrupt 1 {

    // assuming P2 is only used for servos.
    P2 = table_P2_over_time [ ms_tenth_countdown ];

    if (!--ms_tenth_countdown)
        ms_tenth_countdown = 200;

    TF0 = 0;
}

void main(void)
{TMOD=0x02;
IE=0x82;
TH0=0xA3;
servoport=0;
ms_tenth_countdown=200;
TR0=1;
for(;;);
}
