This is the mail archive of the binutils@sourceware.org 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: GNURX toolchain generates incorrect opcode for "mov.b #0xff, [r0]" instruction.


Hi Nick,

Thanks for your help. 

>> As DJ explained, you need an extra instruction inside these patterns in order to insert the register value.  IE:
>>
>> 	| MOV DOT_B '#' EXPR ',' '[' REG ']'
>>	 { B2 (0xf8, 0x04); F ($7, 9, 3); IMMB ($4, 12);}
>>
>>	| MOV DOT_W '#' EXPR ',' '[' REG ']'
>>         { B2 (0xf8, 0x01); F ($7, 9, 3); IMMW ($4, 12);}
>>
>>	| MOV DOT_L '#' EXPR ',' '[' REG ']'
>>	  { B2 (0xf8, 0x02); F ($7, 9, 3); IMM ($4, 12);}

Below patch fixes the issue reported. This is verified using following testcase.

/*test.s*/ 
$cat test.s
/*With size = byte */
mov.b #0xff, [r0]
mov.b #0xff, [r1]
mov.b #0xff, [r2]
mov.b #0xff, [r13]
mov.b #0xff, [r14]
mov.b #0xff, [r15]

/*With size = word */
mov.w #0xff, [r0]
mov.w #0xff, [r1]
mov.w #0xff, [r2]
mov.w #0xff, [r13]
mov.w #0xff, [r14]
mov.w #0xff, [r15]

/*With size = long */
mov.l #0xff, [r0]
mov.l #0xff, [r1]
mov.l #0xff, [r2]
mov.l #0xff, [r13]
mov.l #0xff, [r14]
mov.l #0xff, [r15]

$rx-elf-as test4.s -o test.o -aln

   1                                    /*With size = byte */
   2 0000 F8 04 FF                      mov.b #0xff, [r0]
   3 0003 F8 14 FF                      mov.b #0xff, [r1]
   4 0006 F8 24 FF                      mov.b #0xff, [r2]
   5 0009 F8 D4 FF                      mov.b #0xff, [r13]
   6 000c F8 E4 FF                      mov.b #0xff, [r14]
   7 000f F8 F4 FF                      mov.b #0xff, [r15]
   8
   9                                    /*With size = word */
  10 0012 F8 09 FF 00                   mov.w #0xff, [r0]
  11 0016 F8 19 FF 00                   mov.w #0xff, [r1]
  12 001a F8 29 FF 00                   mov.w #0xff, [r2]
  13 001e F8 D9 FF 00                   mov.w #0xff, [r13]
  14 0022 F8 E9 FF 00                   mov.w #0xff, [r14]
  15 0026 F8 F9 FF 00                   mov.w #0xff, [r15]
  16
  17                                    /*With size = long */
  18 002a F8 0A FF 00                   mov.l #0xff, [r0]
  19 002e F8 1A FF 00                   mov.l #0xff, [r1]
  20 0032 F8 2A FF 00                   mov.l #0xff, [r2]
  21 0036 F8 DA FF 00                   mov.l #0xff, [r13]
  22 003a F8 EA FF 00                   mov.l #0xff, [r14]
  23 003e F8 FA FF 00                   mov.l #0xff, [r15]

The patch is also regression tested. Please review and commit.

Regards,
Vinay

/*******************************************************************/
gas/ChangeLog
2016-02-10  Vinay  <Vinay.G@kpit.com>

	* config/rx-parse.y (MOV):  Opcode generation for index 
	register addressing mode.	

Index: gas/config/rx-parse.y
===================================================================
--- gas/config/rx-parse.y       (revision 3180)
+++ gas/config/rx-parse.y       (working copy)
@@ -271,7 +271,15 @@
              } }

/* ---------------------------------------------------------------------- */
+       | MOV DOT_B '#' EXPR ',' '[' REG ']'
+        { B2 (0xf8, 0x04); F ($7, 8, 4); IMMB ($4, 12);}

+       | MOV DOT_W '#' EXPR ',' '[' REG ']'
+         { B2 (0xf8, 0x01); F ($7, 8, 4); IMMW ($4, 12);}
+
+       | MOV DOT_L '#' EXPR ',' '[' REG ']'
+        { B2 (0xf8, 0x02); F ($7, 8, 4); IMM ($4, 12);}
+
        | MOV DOT_B '#' EXPR ',' disp '[' REG ']'
          /* rx_disp5op changes the value if it succeeds, so keep it last.  */
          { if ($8 <= 7 && rx_uintop ($4, 8) && rx_disp5op0 (&$6, BSIZE))

-----Original Message-----
From: Nick Clifton [mailto:nickc@redhat.com] 
Sent: Wednesday, February 03, 2016 8:23 PM
To: Vinay Kumar. G <Vinay.G@kpit.com>
Cc: binutils@sourceware.org
Subject: Re: GNURX toolchain generates incorrect opcode for "mov.b #0xff, [r0]" instruction.

Hi Vinay,

> +	| MOV DOT_B '#' EXPR ',' '[' REG ']'
> +	 { B2 (0xf8, 0x04); IMMB ($4, 12);}

> However I am still facing issue with registers other than r0 like 
> r1-r15. Can you please give some hints how to go about with this.

As DJ explained, you need an extra instruction inside these patterns in order to insert the register value.  IE:

	| MOV DOT_B '#' EXPR ',' '[' REG ']'
	 { B2 (0xf8, 0x04); F ($7, 9, 3); IMMB ($4, 12);}

	| MOV DOT_W '#' EXPR ',' '[' REG ']'
          { B2 (0xf8, 0x01); F ($7, 9, 3); IMMW ($4, 12);}

	| MOV DOT_L '#' EXPR ',' '[' REG ']'
	  { B2 (0xf8, 0x02); F ($7, 9, 3); IMM ($4, 12);}

Cheers
   Nick


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