#include 
#include 
#include 
#include 
#include 
#include 
#include 

void init_portd(void) {
	PDSEL=0xFF;		/* select port D bits for I/O */
	PDDIR=0xFF;		/* set bits 0-7 as output */
	PDDATA=0xFF;	/* init to off */
}

int write_output_portd_on(unsigned int which_bit) {
	unsigned char temp;
        if (which_bit>7) return -1;
        temp=0x01 <7) return -1;
        temp=0x01 <

    Source: geocities.com/hk/collinsyung

               ( geocities.com/hk)