Correct bit number for lone 'a' in config_gram.y

When an SPI command has a lone 'a' the initialisation now is as would be
expected by all commands that take an address. Atmel's opcodes for SPI
programming are consistent in this respect. This commit makes specifying
the bit number in avrdude.conf optional. Instead of

 read_lo = "0 0 1 0 0 0 0 0  0 0 a13 a12 a11 a10 a9 a8  a7 a6 a5 a4 a3 a2 a1 a0  o o o o o o o o";

one can now use

 read_lo = "0 0 1 0 0 0 0 0  0 0 a a a a a a  a a a a a a a a  o o o o o o o o";
This commit is contained in:
Stefan Rueger 2022-07-19 14:46:08 +01:00
parent 8989e6515b
commit 8da9c2bbf6
1 changed files with 13 additions and 5 deletions

View File

@ -45,7 +45,7 @@ int yywarning(char * errmsg, ...);
static int assign_pin(int pinno, TOKEN * v, int invert); static int assign_pin(int pinno, TOKEN * v, int invert);
static int assign_pin_list(int invert); static int assign_pin_list(int invert);
static int which_opcode(TOKEN * opcode); static int which_opcode(TOKEN * opcode);
static int parse_cmdbits(OPCODE * op); static int parse_cmdbits(OPCODE * op, int opnum);
static int pin_name; static int pin_name;
%} %}
@ -1317,7 +1317,8 @@ part_parm :
free_token($1); free_token($1);
YYABORT; YYABORT;
} }
if(0 != parse_cmdbits(op)) YYABORT; if(0 != parse_cmdbits(op, opnum))
YYABORT;
if (current_part->op[opnum] != NULL) { if (current_part->op[opnum] != NULL) {
/*yywarning("operation redefined");*/ /*yywarning("operation redefined");*/
avr_free_opcode(current_part->op[opnum]); avr_free_opcode(current_part->op[opnum]);
@ -1455,7 +1456,8 @@ mem_spec :
free_token($1); free_token($1);
YYABORT; YYABORT;
} }
if(0 != parse_cmdbits(op)) YYABORT; if(0 != parse_cmdbits(op, opnum))
YYABORT;
if (current_mem->op[opnum] != NULL) { if (current_mem->op[opnum] != NULL) {
/*yywarning("operation redefined");*/ /*yywarning("operation redefined");*/
avr_free_opcode(current_mem->op[opnum]); avr_free_opcode(current_mem->op[opnum]);
@ -1579,7 +1581,7 @@ static int which_opcode(TOKEN * opcode)
} }
static int parse_cmdbits(OPCODE * op) static int parse_cmdbits(OPCODE * op, int opnum)
{ {
TOKEN * t; TOKEN * t;
int bitno; int bitno;
@ -1635,7 +1637,10 @@ static int parse_cmdbits(OPCODE * op)
case 'a': case 'a':
op->bit[bitno].type = AVR_CMDBIT_ADDRESS; op->bit[bitno].type = AVR_CMDBIT_ADDRESS;
op->bit[bitno].value = 0; op->bit[bitno].value = 0;
op->bit[bitno].bitno = 8*(bitno/8) + bitno % 8; op->bit[bitno].bitno = bitno < 8 || bitno > 23? 0:
opnum == AVR_OP_LOAD_EXT_ADDR? bitno+8: bitno-8; /* correct bit number for lone 'a' */
if(bitno < 8 || bitno > 23)
yywarning("address bits don't normally appear in Byte 0 or Byte 3 of SPI programming commands");
break; break;
case 'i': case 'i':
op->bit[bitno].type = AVR_CMDBIT_INPUT; op->bit[bitno].type = AVR_CMDBIT_INPUT;
@ -1679,5 +1684,8 @@ static int parse_cmdbits(OPCODE * op)
} /* while */ } /* while */
if(bitno > 0)
yywarning("too few opcode bits in instruction");
return rv; return rv;
} }