Subversion Repositories DevTools

Rev

Rev 1026 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1026 Rev 1028
Line 94... Line 94...
94
int cmd_repeat_nest_level = -1;
94
int cmd_repeat_nest_level = -1;
95
 
95
 
96
/**************************************************************************/
96
/**************************************************************************/
97
 
97
 
98
/* PROTOTYPES */
98
/* PROTOTYPES */
-
 
99
void ins_quad(unsigned __int64 value);
99
void ins_long(unsigned long value);
100
void ins_long(unsigned long value);
100
void ins_word(unsigned long value);
101
void ins_word(unsigned long value);
101
void ins_byte(unsigned long value);
102
void ins_byte(unsigned long value);
102
 
103
 
103
 
104
 
Line 145... Line 146...
145
   arg_ptr = endp;
146
   arg_ptr = endp;
146
 
147
 
147
   return arg_ptr;
148
   return arg_ptr;
148
}
149
}
149
 
150
 
-
 
151
char * next_value64(char * arg_ptr, unsigned __int64 * value, int * got_a_value)
-
 
152
{
-
 
153
   char * endp;
-
 
154
   unsigned __int64 calc = 0;
-
 
155
 
-
 
156
   unsigned long arg_val = 0;
-
 
157
 
-
 
158
   *got_a_value = FALSE;
-
 
159
 
-
 
160
   // skip to the first numeric
-
 
161
   while ( ((*arg_ptr < '0') || (*arg_ptr > '9')) && (*arg_ptr != 0) ) {
-
 
162
        arg_ptr++;
-
 
163
   }
-
 
164
 
-
 
165
   // Process Data
-
 
166
   endp = arg_ptr;
-
 
167
   while ( ((*endp >= '0') && (*endp <= '9')) && (*endp != 0) ) {
-
 
168
        calc = calc * 10;
-
 
169
        calc += *endp - '0';
-
 
170
        endp++;
-
 
171
   }
-
 
172
 
-
 
173
   *value = calc;
-
 
174
 
-
 
175
   if (endp > arg_ptr)
-
 
176
      *got_a_value = TRUE;
-
 
177
 
-
 
178
   arg_ptr = endp;
-
 
179
 
-
 
180
   return arg_ptr;
-
 
181
}
-
 
182
 
-
 
183
 
150
char * remove_trailing_spaces(char * pStr)
184
char * remove_trailing_spaces(char * pStr)
151
{
185
{
152
   int str_len = strlen(pStr);
186
   int str_len = strlen(pStr);
153
   if (str_len > 0)
187
   if (str_len > 0)
154
   {
188
   {
Line 378... Line 412...
378
         ins_long(value);
412
         ins_long(value);
379
      }
413
      }
380
   }
414
   }
381
}
415
}
382
 
416
 
-
 
417
void fn_DQ(char * arg_ptr)
-
 
418
{
-
 
419
   unsigned __int64  value;
-
 
420
   int got_a_value = TRUE;
-
 
421
 
-
 
422
   DEBUG( DEBUG_OUTPUT_CMD_MASK, "DQ %s", arg_ptr );
-
 
423
 
-
 
424
   while ( (*arg_ptr != 0) && (got_a_value) )
-
 
425
   {
-
 
426
      arg_ptr = next_value64(arg_ptr, &value, &got_a_value);
-
 
427
      if (got_a_value)
-
 
428
      {
-
 
429
         ins_quad(value);
-
 
430
      }
-
 
431
   }
-
 
432
}
-
 
433
 
-
 
434
 
383
 
435
 
384
void fn_TEXT(char * arg_ptr)
436
void fn_TEXT(char * arg_ptr)
385
{
437
{
386
   if (*arg_ptr != 0)
438
   if (*arg_ptr != 0)
387
   {
439
   {
Line 1519... Line 1571...
1519
            else if (strnicmp(cmd_line, "DL", 2) == 0) {
1571
            else if (strnicmp(cmd_line, "DL", 2) == 0) {
1520
               strip_trailing_comment_and_spaces( cmd_line );
1572
               strip_trailing_comment_and_spaces( cmd_line );
1521
               if (OutputFileOpen())
1573
               if (OutputFileOpen())
1522
                  fn_DL(cmd_args);
1574
                  fn_DL(cmd_args);
1523
            }
1575
            }
-
 
1576
            else if (strnicmp(cmd_line, "DQ", 2) == 0) {
-
 
1577
               strip_trailing_comment_and_spaces( cmd_line );
-
 
1578
               if (OutputFileOpen())
-
 
1579
                  fn_DQ(cmd_args);
-
 
1580
            }
-
 
1581
            
1524
            else {
1582
            else {
1525
               if (  ( cmd_line[0] != ' '  )
1583
               if (  ( cmd_line[0] != ' '  )
1526
                  && ( cmd_line[0] != 0    )
1584
                  && ( cmd_line[0] != 0    )
1527
                  && ( cmd_line[0] != '\n' )
1585
                  && ( cmd_line[0] != '\n' )
1528
                  && ( cmd_line[0] != '#'  ) )
1586
                  && ( cmd_line[0] != '#'  ) )
Line 1585... Line 1643...
1585
   printf("  OUTPUT BINARY FILE COMMANDS---------------------------------------------------------------------\n\n");
1643
   printf("  OUTPUT BINARY FILE COMMANDS---------------------------------------------------------------------\n\n");
1586
   printf("  DUP  n,v               Add the 8-bit value v to the output file, n times\n");
1644
   printf("  DUP  n,v               Add the 8-bit value v to the output file, n times\n");
1587
   printf("  DB v,v,..,v            Add the specified list of  8-bit values to the output file\n");
1645
   printf("  DB v,v,..,v            Add the specified list of  8-bit values to the output file\n");
1588
   printf("  DW v,v,..,v            Add the specified list of 16-bit values to the output file\n");
1646
   printf("  DW v,v,..,v            Add the specified list of 16-bit values to the output file\n");
1589
   printf("  DL v,v,..,v            Add the specified list of 32-bit values to the output file\n");
1647
   printf("  DL v,v,..,v            Add the specified list of 32-bit values to the output file\n");
-
 
1648
   printf("  DQ v,v,..,v            Add the specified list of 64-bit values to the output file\n");
1590
   printf("  TEXT text              Add the specified text to the output file\n");
1649
   printf("  TEXT text              Add the specified text to the output file\n");
1591
   printf("  NTEXT v,text           Add exactly v characters of the specified text to the output file\n");
1650
   printf("  NTEXT v,text           Add exactly v characters of the specified text to the output file\n");
1592
   printf("                           - pad output file with 0's if insufficient text provided\n");
1651
   printf("                           - pad output file with 0's if insufficient text provided\n");
1593
   printf("  ZTEXT v,text           Add exactly v-1 characters and a NULL terminator of the specified text to the output file\n");
1652
   printf("  ZTEXT v,text           Add exactly v-1 characters and a NULL terminator of the specified text to the output file\n");
1594
   printf("  BIG_ENDIAN             Turn Big-endian on (default behaviour)\n");
1653
   printf("  BIG_ENDIAN             Turn Big-endian on (default behaviour)\n");
Line 1858... Line 1917...
1858
      fputc((value >> 16) & 255, op_stream);
1917
      fputc((value >> 16) & 255, op_stream);
1859
      fputc((value >> 24) & 255, op_stream);
1918
      fputc((value >> 24) & 255, op_stream);
1860
   }
1919
   }
1861
}
1920
}
1862
 
1921
 
-
 
1922
void ins_quad(unsigned __int64 value)
-
 
1923
{
-
 
1924
   if (endianism == BIG_ENDIAN)
-
 
1925
   {
-
 
1926
      fputc((int)(value >> 7*8) & 255, op_stream);
-
 
1927
      fputc((int)(value >> 6*8) & 255, op_stream);
-
 
1928
      fputc((int)(value >> 5*8) & 255, op_stream);
-
 
1929
      fputc((int)(value >> 4*8) & 255, op_stream);
-
 
1930
      fputc((int)(value >> 3*8) & 255, op_stream);
-
 
1931
      fputc((int)(value >> 2*8) & 255, op_stream);
-
 
1932
      fputc((int)(value >> 1*8) & 255, op_stream);
-
 
1933
      fputc((int)(value)        & 255, op_stream);
-
 
1934
   }
-
 
1935
   else
-
 
1936
   {
-
 
1937
      fputc((int)value          & 255, op_stream);
-
 
1938
      fputc((int)(value >> 1*8 )& 255, op_stream);
-
 
1939
      fputc((int)(value >> 2*8) & 255, op_stream);
-
 
1940
      fputc((int)(value >> 3*8) & 255, op_stream);
-
 
1941
      fputc((int)(value >> 4*8) & 255, op_stream);
-
 
1942
      fputc((int)(value >> 5*8) & 255, op_stream);
-
 
1943
      fputc((int)(value >> 6*8) & 255, op_stream);
-
 
1944
      fputc((int)(value >> 7*8) & 255, op_stream);
-
 
1945
   }
-
 
1946
}
-
 
1947
 
-
 
1948
 
1863
 
1949
 
1864
 
1950
 
1865
/* END OF File */
1951
/* END OF File */