mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-29 20:38:44 +03:00
Add R-base numbers
This commit is contained in:
18
src/fileio.c
18
src/fileio.c
@@ -72,6 +72,8 @@ char *fileio_fmtstr(FILEFMT format) {
|
||||
return "ELF";
|
||||
case FMT_IMM:
|
||||
return "in-place immediate";
|
||||
case FMT_EEGG:
|
||||
return "R-number list";
|
||||
case FMT_BIN:
|
||||
return "0b-binary byte list";
|
||||
case FMT_DEC:
|
||||
@@ -101,6 +103,8 @@ int fileio_fmtchr(FILEFMT format) {
|
||||
return 'e';
|
||||
case FMT_IMM:
|
||||
return 'm';
|
||||
case FMT_EEGG:
|
||||
return 'R';
|
||||
case FMT_BIN:
|
||||
return 'b';
|
||||
case FMT_DEC:
|
||||
@@ -114,7 +118,6 @@ int fileio_fmtchr(FILEFMT format) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FILEFMT fileio_format(char c) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
@@ -131,6 +134,8 @@ FILEFMT fileio_format(char c) {
|
||||
return FMT_ELF;
|
||||
case 'm':
|
||||
return FMT_IMM;
|
||||
case 'R':
|
||||
return FMT_EEGG;
|
||||
case 'b':
|
||||
return FMT_BIN;
|
||||
case 'd':
|
||||
@@ -149,6 +154,7 @@ typedef enum {
|
||||
LAST_SEG = 2,
|
||||
} Segorder_t;
|
||||
|
||||
|
||||
static void print_ihex_extended_addr(int n_64k, FILE *outf) {
|
||||
unsigned char hi = (n_64k >> 8);
|
||||
unsigned char lo = n_64k;
|
||||
@@ -1199,10 +1205,15 @@ static int b2num(const char *filename, FILE *f, const AVRMEM *mem, Segment_t *se
|
||||
prefix = "0b";
|
||||
base = 2;
|
||||
break;
|
||||
|
||||
case FMT_EEGG:
|
||||
prefix = "";
|
||||
base = 'r';
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = segp->addr; i < segp->addr + segp->len; i++) {
|
||||
char cbuf[20];
|
||||
char cbuf[81];
|
||||
|
||||
if (i > 0) {
|
||||
if (putc(',', f) == EOF)
|
||||
@@ -1218,7 +1229,7 @@ static int b2num(const char *filename, FILE *f, const AVRMEM *mem, Segment_t *se
|
||||
if (fputs(prefix, f) == EOF)
|
||||
goto writeerr;
|
||||
}
|
||||
str_utoa(num, cbuf, base);
|
||||
str_utoa(num, cbuf, base);
|
||||
if (fputs(cbuf, f) == EOF)
|
||||
goto writeerr;
|
||||
}
|
||||
@@ -1601,6 +1612,7 @@ int fileio_segments(int oprwv, const char *filename, FILEFMT format,
|
||||
case FMT_DEC:
|
||||
case FMT_OCT:
|
||||
case FMT_BIN:
|
||||
case FMT_EEGG:
|
||||
thisrc = fileio_num(&fio, fname, f, mem, seglist+i, format);
|
||||
break;
|
||||
|
||||
|
||||
@@ -989,6 +989,7 @@ typedef enum {
|
||||
FMT_IHEX,
|
||||
FMT_RBIN,
|
||||
FMT_IMM,
|
||||
FMT_EEGG,
|
||||
FMT_HEX,
|
||||
FMT_DEC,
|
||||
FMT_OCT,
|
||||
|
||||
@@ -310,6 +310,30 @@ char *str_utoa(unsigned n, char *buf, int base) {
|
||||
unsigned q;
|
||||
char *cp;
|
||||
|
||||
if(base == 'r') {
|
||||
const char *units = "IVXLCDMFTYHSNabcdefghijkl";
|
||||
const char *rep[10] = {"", "a", "aa", "aaa", "ab", "b", "ba", "baa", "baaa", "ac"};
|
||||
|
||||
if(n == 0) {
|
||||
strcpy(buf, "0");
|
||||
return buf;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for(unsigned u = n; u; u /= 10)
|
||||
i++;
|
||||
for(*buf = 0; i > 0; i--) {
|
||||
unsigned u = n;
|
||||
for(int j=1; j<i; j++)
|
||||
u /= 10;
|
||||
char *q = buf+strlen(buf);
|
||||
for(const char *p = rep[u%10], *d = units + (i-1)*2; *p; p++)
|
||||
*q++ = d[*p-'a'];
|
||||
*q = 0;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
if(base < 2 || base > 36) {
|
||||
*buf = 0;
|
||||
return buf;
|
||||
|
||||
Reference in New Issue
Block a user