Beispiel #1
0
/* to the text records of the object stream except relocated and modified.   */
void OUTPUT_MEM(MEM_SPACE MEMORY,FILE *OUTPUT)
{ 
  struct BUFFER_ELEMENT *CURRENT; /* Current block outputing                 */
  int COUNT;                   /* Simple loop counter                        */
  char ADDRESS[MEM_ADDR_SIZE_1/BITS_PER_HALFBYTE_1 + 2];/* String version of */
                               /*                        address             */
  char STR_BYTE[HEX_CHAR_PER_BYTE_1 + 1]; /* String version of byte          */

  CURRENT = LOCATIONS_USED.HEAD;
  while (CURRENT != NULL) {
    NUM_TO_STR((*CURRENT).START,16,MEM_ADDR_SIZE_1/BITS_PER_HALFBYTE_1+1,
	       ADDRESS);
    NUM_TO_STR((*CURRENT).LENGTH,16,HEX_CHAR_PER_BYTE_1,STR_BYTE);
    (void) fprintf(OUTPUT,"T%s%s",ADDRESS,STR_BYTE);

    for (COUNT = (*CURRENT).START; 
	 COUNT < ((*CURRENT).START + (*CURRENT).LENGTH);
	 COUNT ++) {
      NUM_TO_STR(INT(MEMORY[COUNT]),16,HEX_CHAR_PER_BYTE_1,STR_BYTE);
      (void) fprintf(OUTPUT,"%s",STR_BYTE);
    }
    (void) fprintf(OUTPUT,"\n");
    CURRENT = (*CURRENT).NEXT;
  }
}
Beispiel #2
0
/* and previous block is large enough.                                       */
void PRINT_ELIPSE(struct BUFFER_ELEMENT *PREV,struct BUFFER_ELEMENT *CURR,
                  int PREV_ADDR,FILE *OUTPUT)
{
  int LOOP_COUNTER;
/* ---------- STR_ADDR               String rep of addr.                     */
  char STR_ADDR[MEM_ADDR_SIZE_1/BITS_PER_HALFBYTE_1 + 1];
  

/* -------------- Check if gap is large enough                               */
  if ( LINES_OF_GAP(PREV,CURR) >= LINES_OF_GAP_TO_ELIPSE ) {

    NUM_TO_STR(PREV_ADDR,16,MEM_ADDR_SIZE_1/BITS_PER_HALFBYTE_1, STR_ADDR);
    (void) fprintf(OUTPUT,
		   " %s    xxxxxxxx  xxxxxxxx  xxxxxxxx  xxxxxxxx\n",
		   STR_ADDR);

    for (LOOP_COUNTER = 1;LOOP_COUNTER <= 3; LOOP_COUNTER++)
      (void) fprintf(OUTPUT,
		     "   .          .         .         .         .\n");
    
    if (CURR != NULL) 
      NUM_TO_STR(START_OF_LINE_ADDR( (*CURR).START)-
		 BYTES_PER_GROUP*GROUPS_PER_LINE, 
		 16,MEM_ADDR_SIZE_1/BITS_PER_HALFBYTE_1, STR_ADDR);
    else 
      NUM_TO_STR(START_OF_LINE_ADDR( MEM_SIZE_1) -
		 BYTES_PER_GROUP*GROUPS_PER_LINE, 
		 16,MEM_ADDR_SIZE_1/BITS_PER_HALFBYTE_1, STR_ADDR);

    (void) fprintf(OUTPUT,
		   " %s    xxxxxxxx  xxxxxxxx  xxxxxxxx  xxxxxxxx\n",
		   STR_ADDR);
  }
}
Beispiel #3
0
/**
 * @brief   显示滚动条文字
 */
static void MenuDispScrollBarTxt(void)
{
	static char sScrollBarTxt[MENU_SCROLL_TXT_SIZE];
	menu_t lI;
	uint8_t lLen = 0;
	S_Value_Scroll_Bar_Txt lArray;

	// 首先添加一下结束符,这样才好检查字符串长度
	sScrollBarTxt[0] = 0;

	// 备份菜单项数值
	if (sMenuBak.Depth > 0)
	{
		// 因为深度都是指向的是需要写入的下一个,所以for循环就这样就可以了
		for (lI = 0; lI < sMenuBak.Depth; lI++)
		{
			// 转换菜单项
			lLen = strlen(sScrollBarTxt);
			// 注意显示的菜单项是从1开始的,所以要+1
			lArray.Char = sScrollBarTxt + lLen;
			lArray.Value.Num = sMenuBak.Item[lI] + 1;
			lArray.Value.Point = POINT_HHHHH;
			NUM_TO_STR(&lArray);
//			NUM_TO_STR(sScrollBarTxt + lLen,
//						sMenuBak.Item[lI] + 1, POINT_HHHHH);

			// 转换字符'-'
			lLen = strlen(sScrollBarTxt);
			sScrollBarTxt[lLen] = '-';
			sScrollBarTxt[lLen + 1] = 0;
		}
	}

	// 当前菜单项数值
	lLen = strlen(sScrollBarTxt);
	lArray.Char = sScrollBarTxt + lLen;
	lArray.Value.Num = sMenuItem.Item + 1;
	lArray.Value.Point = POINT_HHHHH;
	NUM_TO_STR(&lArray);

//	NUM_TO_STR(sScrollBarTxt + lLen, sMenuItem.Item + 1, POINT_HHHHH);

	// 整个字符串的长度
	lLen = strlen(sScrollBarTxt);

	// 显示滚动条文字
//	DisScrollBarTxt(sScrollBarTxt,
//			CONFIG_SCROLL_BAR_TXT_X_END - lLen * CONFIG_SCROLL_BAR_TXT_X,
//			CONFIG_SCROLL_BAR_TXT_Y_START);
	Lcd__MenuScrollBarTxtDisp(sScrollBarTxt);
}
Beispiel #4
0
/* Add the integer NUM to what is store at LOCATION in MEMORY.               */
void ADD_INT_TO_LOC(int NUM,int LOCATION,int HALF_BYTES,MEM_SPACE MEMORY,
                    BOOLEAN *ERROR)
{
  int INT_MEM_VAL = 0;      /* Integer stored at the relavant location.      */
  char CHAR_MEM_VAL[BITS_PER_WORD_1/BITS_PER_HALFBYTE_1+2]; 
                            /* CHAR_MEM_VAL is the string representation of  */
                            /*   the number stored at a location of size     */
                            /*   HALF_BYTES.                                 */

  if ( ((int) HALF_BYTES/2)*2 != HALF_BYTES)
    HALF_BYTES ++;          /* If odd number of half_bytes include an extra  */
                            /*   one so that have an even number always.     */

/* ----------------- Check if store is legal (fits in memory)                */
  if ( (LOCATION + HALF_BYTES/HEX_CHAR_PER_BYTE_1 <= MEM_SIZE_1) 
      && (LOCATION + HALF_BYTES/HEX_CHAR_PER_BYTE_1 >= 0)) {
    int I;

/* ------ Get what is stored there                                           */
    for (I = 0; I < HALF_BYTES/HEX_CHAR_PER_BYTE_1; I ++)
      INT_MEM_VAL = INT_MEM_VAL*256 + INT(MEMORY[LOCATION+I]);

/* ------ Add the NUMber to what was there                                   */
    INT_MEM_VAL += NUM;

/* ------ Put the result back                                                */
    NUM_TO_STR(INT_MEM_VAL,16,HALF_BYTES,CHAR_MEM_VAL);
    DO_STORE(CHAR_MEM_VAL,HALF_BYTES/HEX_CHAR_PER_BYTE_1, LOCATION,
	     MEMORY, ERROR,FALSE_1);
  } else {
    (void) printf("ERROR: Illegal store[2] ADDRESS = %d, BYTES = %d.\n",
		  LOCATION,HALF_BYTES/HEX_CHAR_PER_BYTE_1);
    (*ERROR) = TRUE_1;
  }
}
Beispiel #5
0
/* Output the loaded areas of memory in a nice user readable way.            */
void PRINT_MEM(MEM_SPACE MEMORY,FILE *OUTPUT)
{
  struct BUFFER_ELEMENT *STEP;     /* Current block of memory outputing.     */
  struct BUFFER_ELEMENT *PREVIOUS = NULL; /* Last block output               */
  int PREVIOUS_ADDR = 0;           /* Start address of the last output block */
  int ADDRESS;                     /* Next address of memory to output.      */
  char STR_ADDR[MEM_ADDR_SIZE_1/BITS_PER_HALFBYTE_1 + 1];/* String version of*/
                                   /*                     address            */

  (void) fprintf(OUTPUT,"MEMORY\n");
  (void) fprintf(OUTPUT,"ADDRESS                  Contents\n");
  (void) fprintf(OUTPUT,"-------   --------------------------------------\n");
/*                        12345    12345678  12345678  12345678  12345678 */
/*                       123456789012345678901234567890123456789012345678 */

  if (LOCATIONS_USED.HEAD == NULL) 
    (void) fprintf(OUTPUT,
		   "=========> NOTHING LOADED INTO MEMORY <=========\n");
  else {

/* --------------- STEP through the list of loaded blocks                    */
    for (STEP = LOCATIONS_USED.HEAD; STEP != NULL; STEP = (*STEP).NEXT) {

      PRINT_ELIPSE(PREVIOUS,STEP,PREVIOUS_ADDR,OUTPUT);
      ADDRESS = START_OF_LINE_ADDR((*STEP).START);

/* ------ repeat until consequtive blocks are output on seperate lines.      */
      do {
	BOOLEAN REST_EMPTY = FALSE_1;
	int I,J;
	char STR_BYTE[HEX_CHAR_PER_BYTE_1 + 1];

	NUM_TO_STR(ADDRESS,16,MEM_ADDR_SIZE_1/BITS_PER_HALFBYTE_1,STR_ADDR);
	(void) fprintf(OUTPUT," %s    ",STR_ADDR);
	
/* --------- OUTPUT 1 line                                                   */
	for (I=0;I<GROUPS_PER_LINE;I++) {
	  for (J=0;J<BYTES_PER_GROUP;J++) {
	    int LOC;

	    LOC = ADDRESS+I*BYTES_PER_GROUP+J;
	    if (!REST_EMPTY && (LOC >= ((*STEP).START + (*STEP).LENGTH)))
	      {
		if ( ((*STEP).NEXT == NULL) ||
		    (LINES_OF_GAP(STEP,(*STEP).NEXT) > 0)) REST_EMPTY = TRUE_1;
		else STEP = (*STEP).NEXT;
	      }

	    if ( REST_EMPTY || (LOC < (*STEP).START))
	      (void) fprintf(OUTPUT,"xx");
	    else {
	      NUM_TO_STR(INT(MEMORY[LOC]),16,HEX_CHAR_PER_BYTE_1,STR_BYTE);
	      (void) fprintf(OUTPUT,"%s",STR_BYTE);
	    }
	  }
	  (void) fprintf(OUTPUT,"  ");
	}
	(void) fprintf(OUTPUT,"\n");

	ADDRESS = END_OF_LINE_ADDR(ADDRESS) + 1;
      } while (ADDRESS <= 
	       END_OF_LINE_ADDR( (*STEP).START + (*STEP).LENGTH - 1) );
      PREVIOUS_ADDR = ADDRESS;
      PREVIOUS = STEP;
    }
    PRINT_ELIPSE(PREVIOUS,STEP,PREVIOUS_ADDR,OUTPUT);
  }
}