 int block_move(void)
 {
  int start_adr, end_adr, destination_adr;
  gotoxy(1, 0);
  write(1, ".       ", 9);
  start_adr = adr('m'); 
  if(start_adr < 0) 
	return(-1);
  shift_help();
  gotoxy(1, 0);
  write(1, ".       ", 9);
  end_adr = adr('m'); 
  if(end_adr < 0 )
	return(-1);
  if(end_adr < start_adr) {
	reset();
	return(-1);
  }
  shift_help();
  gotoxy(1, 0);
  write(1, ".       ", 9);
  destination_adr = adr('g'); 
  if(destination_adr < 0) 
	return(-1);
  shift(start_adr, end_adr, destination_adr);
  return(0);
}



 int deletes(void)
 {
  int ad1, ad2, ad3, ad4;
  gotoxy(1, 0);
  write(1, ".       ", 9);
  ad1 = adr('m'); 
  if(ad1 < 0) return(-1); /*low limit*/
  delete_help();
  gotoxy(1, 0);
  write(1, ".       ", 9);
  ad2 = adr('m'); 
  if(ad2 < 0) return(-1); /*high limit*/
  delete_help();
  gotoxy(1, 0);
  write(1, ".       ", 9);
  ad3 = adr('m');
  if(ad3 < 0) return(-1); /*low delete*/
  delete_help();
  gotoxy(1, 0);
  write(1, ".       ", 9);
  ad4 = adr('g');
  if(ad4 < 0) return(-1); /*high delete*/
  if( (ad4 > ad2) || (ad2 < ad1) || (ad3>ad4) || (ad3>ad2) ) {
	reset();
	return(-1);
  }
  shift(ad4+1, ad2, ad3);
  return(-1);
 }
  
  
  
 int inserts(void)
 {
  int ad1, ad2, ad3, num;
  gotoxy(1, 0);
  write(1, ".       ", 9);
  ad1 = adr('m');
  if(ad1 < 0) return(-1); /*low limit*/
  gotoxy(1, 0);
  write(1, ".       ", 9);
  ad2 = adr('m');
  if(ad2 < 0) return(-1);    /*high limit*/
  gotoxy(1, 0);
  write(1, ".       ", 9);
  ad3 = adr('g');
  if(ad3 < 0) return(-1);   /*low insert*/
  num = edit_data_byte(0);            /*no of bytes*/
  if(num == 0) return(0);
  if(ad2 < ad1 || ad3 > ad2) {
	reset();
	return(-1);
  }
  num &= 0xff;
  shift(ad3,  ad2,  ad3 + num);
  memo(ad3);
  return(0);
 }
  
  
 int shift(int ad1, int ad2, int ad3)
 {
  int upper_destination_addr;
  if(ad3 > ad2 || ad3 <= ad1) {
	while(ad1 <= ad2) {
		memw(ad3,memr(ad1));
		ad1++;
		ad3++;
	}
  }
  else {
	upper_destination_addr = ad2 - ad1 + ad3;
	while(ad2 >= ad1) {
		memw(upper_destination_addr,memr(ad2));
		upper_destination_addr--;
		ad2--;
	}
  }
  return(0);
 }
  
  
 int edit_data_byte(int val)
 {
  int c1, c2, c3, c4;
  char buff[2];
  c1 = val / 0x10;
  c2 = val % 0x10;
  if(c1 > 9) c1 += 87;
  else c1 += 48;
  if(c2 > 9) c2 += 87;
  else c2 += 48;
  while(1) {
	c3 = getch();
	if((c3 >= '0' && c3 <= '9') || (c3 >= 'a' && c3 <= 'f')) {
		c1 = c2;
		c2 = c3;
		gotoxy(7, 0);
		sprintf(buff, "%c%c", c1, c2);
		write(1, buff, 2);
		continue;
	}
	c4 = ascci_to_int(c1) * 0x10 + ascci_to_int(c2);
	if(c3 == 'n') {
		c4 = c4|0x100;
		return(c4);
	}
	if(c3 == 'x') {
		c4 |= 0x200;
		gotoxy(1, 0);
		write(1, "_              ", 15);
		return(c4);
	}
	reset();
	return(0);
  }
 }
  
  
  
  
 int trans(int by)
 {
  int m2, md, ms = 0, m1 = 0;
  md = by / 0x10;
  m2 = by % 0x10;
  if(m2 == 0xa || m2 == 0xc || m2 == 8)   ms++;
  switch(ms) {
case 0: switch(md) {
	case 12:if(!rf[1]) m1++;
		break;
	case 13:if(!rf[7]) m1++;
		break;
	case 14:if(!rf[5]) m1++;
		break;
	case 15:if(!rf[0]) m1++;
	}
	break;
case 1: switch(md) {
	case 12:if(rf[1]) m1++;
		break;
	case 13:if(rf[7]) m1++;
		break;
	case 14:if(rf[5]) m1++;
		break;
	case 15:if(rf[0]) 
		m1++;
	}
  }
  return(m1);
 }                /* END OF FUNCTION "trans(by)" */
  
