
#include <compiler.h>
#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int

SBIT(ena, 0x80, 1);
SBIT(rs, 0x80, 2);
SBIT(rd_wr, 0x80, 0);


void lcddatwr(uchar dbyte){
	rs=1;
	ena=1;
	P1=dbyte;
	ena=0;
	rd_wr=1;
}

void lcdcmdwr(uchar dbyte){
	rs=1;
	ena=1;
	P1=dbyte;
	ena=0;
}

void display (uchar startloc, uchar *s){
	lcdcmdwr(0x80 | startloc);
	while(*s) {lcddatwr(*s++);
	}
}
//This funktion stil try to understand its funktionality 
void numdsp(uchar startloc, uint number, bit dpt){
	uint m=1000;
	bit ldgzero=0;	//hear shows also wrong
	lcdcmdwr(0x80 | startloc);
	do{
		if((((number/m)>0) || (m==1)) || ((m==100) && (dpt==1))) ldgzero=1;
		if (ldgzero == 1) lcddatwr(number/m+'0');
		else lcddatwr(' ');
		number %=m;
		if ((dpt==1) && (m==100)){
			lcddatwr('.');
	  }
	 }while((m/=10)>0);
}

	void initialize(void){
rd_wr=1; //i want this bit always 1 but point me wrong message
		lcdcmdwr(0x30);	
		
	}

	void main(void){
		uint x=0;
		initialize();
		display(0, "test");
		for(;;){
		numdsp(69,x++,0);
		}
}
