
 int modify_reg(void)
 {
  int c4,c1,c2,c3;
  char buff[64];
  gotoxy(1,0);
  write(1,".              ",16);
  c4 = getch();
  if((c4 < '4' || c4 > 'f') || (c4 < 'a' && c4 > '9') ) {
	gotoxy(1,0);
	if(c4 != 'r') {
		reset();
		return(0);
	}
	gotoxy(1,0);
	write(1,"_ups  85",8);
	return(0);
  }
  gotoxy(1,0);
  switch(c4) {
case'a':sprintf(buff,"A     %02x",reg[7]);
	write(1,buff,8);
	c1 = edit_data_byte(reg[7]);
	if(c1 == 0) return(0);
	c2 = c1 & 0xff;
	reg[7] = c2;
	c2 = c1 & 0x300;
	if(c2 == 0x200) return(0);
case'b':sprintf(buff,"B     %02x",reg[0]);
	write(1,buff,8);
	c1 = edit_data_byte(reg[0]);
	if(c1 == 0) return(0);
	c2 = c1 & 0xff;
	reg[0] = c2;
	c2 = c1 & 0x300;
	if(c2 == 0x200) return(0);
case'c': sprintf(buff,"C     %02x",reg[1]);
	write(1,buff,8);
	c1 = edit_data_byte(reg[1]);
	if(c1 == 0) return(0);
	c2 = c1 & 0xff;
	reg[1] = c2;
	c2 = c1 & 0x300;
	if(c2 == 0x200) return(0);
case'd': sprintf(buff,"D     %02x",reg[2]);
	write(1,buff,8);
	c1 = edit_data_byte(reg[2]);
	if(c1 == 0) return(0);
	c2 = c1 & 0xff;
	reg[2] = c2;
	c2 = c1 & 0x300;
	if(c2 == 0x200) return(0);
case'e': sprintf(buff,"E     %02x",reg[3]);
	write(1,buff,8);
	c1 = edit_data_byte(reg[3]);
	if(c1 == 0) return(0);
	c2 = c1 & 0xff;
	reg[3] = c2;
	c2 = c1 & 0x300;
	if(c2 == 0x200) return(0);
case'f': c3 = 128;
	c2 = 0;
	for(c1 = 0;c1 < 8;c1++) {
		c2 = c2 + rf[c1] * c3;
		c3 /= 2;
	}
	sprintf(buff,"F     %02x",c2);
	write(1,buff,8);
	c1 = edit_data_byte(c2);
	if(c1 == 0) return(0);
	c2 = c1 & 0xff;
	for(c3 = 7;c3 >= 0;c3--) {
		rf[c3] = c2 % 2;
		c2 /= 2;
	}
	c2 = c1 & 0x300;
	if(c2 == 0x200) return(0);
case'8': sprintf(buff,"H     %02x",reg[4]);
	write(1,buff,8);
	c1 = edit_data_byte(reg[4]);
	if(c1 == 0) return(0);
	c2 = c1 & 0xff;
	reg[4] = c2;
	c2 = c1 & 0x300;
	if(c2 == 0x200) return(0);
case'9': sprintf(buff,"L     %02x",reg[5]);
	write(1,buff,8);
	c1 = edit_data_byte(reg[5]);
	if(c1 == 0) return(0);
	c2 = c1 & 0xff;
	reg[5] = c2;
	c2 = c1 & 0x300;
	if(c2 == 0x200) return(0);
case'4': c1 = rsp / 0x100;
	sprintf(buff,"SPH   %02X",c1);
	write(1,buff,8);
	c1 = edit_data_byte(c1);
	if(c1 == 0) return(0);
	c2 = c1 & 0xff;
	rsp &= 0xff;
	rsp |= (c2 * 0x100);
	c2 = c1 & 0x300;
	if(c2 == 0x200) return(0);
case'5': c1 = rsp % 0x100;
	sprintf(buff,"SPL   %02x",c1);
	write(1,buff,8);
	c1 = edit_data_byte(c1);
	if(c1 == 0) return(0);
	c2 = c1 & 0xff;
	rsp &= 0xff00;
	rsp |= c2;
	c2 = c1 & 0x300;
	if(c2 == 0x200) return(0);
case'6': c1 = rpc / 0x100;
	sprintf(buff,"PCH   %02x",c1);
	write(1,buff,8);
	return(0);
case'7': c1 = rpc % 0x100;
	sprintf(buff,"PCL   %02x",c1); return(0);
	write(1,buff,8);
 }
 return(0);
}
