#define DISPLAY_ADDR (0x08000000)
#define RLU_IN_ADDR (0x0c000000)
#define RLU_OUT_ADDR (0x0c000020)

int put_char(char d);
void put_hex_digit(char a);
void put_short_hexstr(short a);
int str_len(char *s);

int main(){

  char* b = "Hello Mics SH-GDB";
  short* d;
  int i, len, offset;
  char val[2];
  short v;

  len = str_len(b);
  for(i = 0; i < len; i++){
	put_char(b[i]);
  }
  d = (short*)RLU_IN_ADDR;
  *d = 10;
  d++;
  *d = 20;
  for(i = 0; i < 64; i++){
  }
  put_short_hexstr(0x3434);
  d = (short*)RLU_OUT_ADDR;
  put_short_hexstr(*d);
  d++;
  put_short_hexstr(*d);
}

int str_len(char* s){
  int i = 0;
  while(s[i] != '\0'){
	i++;
  }
  return i;
}

int display_index;
int put_char(char d){
  *((char*)DISPLAY_ADDR+display_index) = d;
  display_index++;
}

char chartbl[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};

void put_hex_digit(char a){
  put_char(chartbl[(a >> 4) & 0x0f]);
  put_char(chartbl[a & 0x0f]);
}

void put_short_hexstr(short a){
  put_char(chartbl[(a >> 12) & 0x0f]);
  put_char(chartbl[(a >> 8)  & 0x0f]);
  put_char(chartbl[(a >> 4) & 0x0f]);
  put_char(chartbl[a & 0x0f]);
}
