This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH 1/3] [ARC] Add arithmetic and logic instructions for nps

> I think that these functions have slightly different behaviour from the
> default case - I have used these for operands which encode e.g. the
> values 1-8 in 3 bits, where the values 1-7 are represented in the usual
> way, and the value 8 is encoded as 0. If I understand it correctly, the
> default behaviour will encode the values 0 to 7 literally. Does my
> understanding seem correct?
In include/opcode/arc.h for arc_operand we can find:

     If it is NULL, execute
	 i |= (op & ((1 << o->bits) - 1)) << o->shift;

which looks identical like your proposed insert function.

And for extract we have:

     If it is NULL, compute
	 op = ((i) >> o->shift) & ((1 << o->bits) - 1);
	 if ((o->flags & ARC_OPERAND_SIGNED) != 0
	     && (op & (1 << (o->bits - 1))) != 0)
	   op -= 1 << o->bits;

which looks like your extract function as described by MAKE_1BASED_INSERT_EXTRACT_FUNCS macro.

The range should be checked also based on the number of bits and signees of the operand. 

In general, the insert and the extract functions should be used as an exception from the rule.  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]