Patch to h8sx short-immediate moves
Richard Sandiford
rsandifo@redhat.com
Wed Jun 25 12:20:00 GMT 2003
Another patch to the h8sx opcode table. gas was treating the immediate
fields of mov.w #xx:8,@yy and mov.l #xx:8,@yy as signed rather than
unsigned. That meant it would use the 8-bit form for instructions like:
mov.w #-1,@er0
...where the length of immediate isn't explicitly given.
Fixed with the patch below, which was tested on h8300-elf and h8300-coff.
OK to install?
Richard
include/opcode/
* h8300.h (IMM2_NS, IMM8_NS, IMM16_NS): Remove.
(IMM8U, IMM8U_NS): Define.
(h8_opcodes): Use IMM8U_NS for mov.[wl] #xx:8,@yy.
gas/
* config/tc-h8300.c (get_specific): Allow ':8' to be used for
unsigned 8-bit operands.
gas/testsuite/
* gas/h8300/h8300.[sd]: Add tests for mov.[wl] #xx:8,@yy.
Index: include/opcode/h8300.h
===================================================================
RCS file: /cvs/src/src/include/opcode/h8300.h,v
retrieving revision 1.16
diff -u -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.16 h8300.h
--- include/opcode/h8300.h 10 Jun 2003 07:33:46 -0000 1.16
+++ include/opcode/h8300.h 25 Jun 2003 11:09:47 -0000
@@ -117,6 +117,7 @@ enum h8_flags {
B31 = 0x40000000, /* Bit 3 must be high. */
E = 0x80000000, /* End of nibble sequence. */
+ /* Immediates smaller than 8 bits are always unsigned. */
IMM3 = IMM | L_3,
IMM4 = IMM | L_4,
IMM5 = IMM | L_5,
@@ -124,15 +125,14 @@ enum h8_flags {
IMM2 = IMM | L_2,
IMM8 = IMM | SRC | L_8,
+ IMM8U = IMM | SRC | L_8U,
IMM16 = IMM | SRC | L_16,
IMM16U = IMM | SRC | L_16U,
IMM32 = IMM | SRC | L_32,
IMM3NZ_NS = IMM3NZ | NO_SYMBOLS,
- IMM2_NS = IMM2 | NO_SYMBOLS,
IMM4_NS = IMM4 | NO_SYMBOLS,
- IMM8_NS = IMM8 | NO_SYMBOLS,
- IMM16_NS = IMM16 | NO_SYMBOLS,
+ IMM8U_NS = IMM8U | NO_SYMBOLS,
IMM16U_NS = IMM16U | NO_SYMBOLS,
RD8 = DST | L_8 | REG,
@@ -1475,7 +1475,7 @@ struct h8_opcode h8_opcodes[] =
{O (O_MOV, SW), AV_H8SX, 0, "mov.w", {{IMM4_NS, ABS16DST, E}}, {{0x6, 0xb, 0xd, IMM4, DSTABS16LIST, E}}},
{O (O_MOV, SW), AV_H8SX, 0, "mov.w", {{IMM4_NS, ABS32DST, E}}, {{0x6, 0xb, 0xf, IMM4, DSTABS32LIST, E}}},
- MOVFROM_IMM8 (O (O_MOV, SW), PREFIX_015D, "mov.w", IMM8_NS),
+ MOVFROM_IMM8 (O (O_MOV, SW), PREFIX_015D, "mov.w", IMM8U_NS),
MOVFROM_IMM (O (O_MOV, SW), PREFIX_7974, "mov.w", IMM16, IMM16LIST),
{O (O_MOV, SW), AV_H8, 2, "mov.w", {{RS16, RD16, E}}, {{0x0, 0xD, RS16, RD16, E}}},
@@ -1501,7 +1501,7 @@ struct h8_opcode h8_opcodes[] =
{O (O_MOV, SL), AV_H8SX, 0, "mov.l", {{IMM3NZ_NS, RD32, E}}, {{0x0, 0xf, B31 | IMM3NZ, B31 | RD32, E}}},
- MOVFROM_IMM8 (O (O_MOV, SL), PREFIX_010D, "mov.l", IMM8_NS),
+ MOVFROM_IMM8 (O (O_MOV, SL), PREFIX_010D, "mov.l", IMM8U_NS),
MOVFROM_IMM (O (O_MOV, SL), PREFIX_7A7C, "mov.l", IMM16U_NS, IMM16ULIST),
{O (O_MOV, SL), AV_H8SX, 0, "mov.l", {{IMM16U_NS, RD32, E}}, {{0x7, 0xa, 0x0, B31 | RD32, IMM16ULIST, E}}},
Index: gas/config/tc-h8300.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-h8300.c,v
retrieving revision 1.32
diff -u -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.32 tc-h8300.c
--- gas/config/tc-h8300.c 10 Jun 2003 07:27:56 -0000 1.32
+++ gas/config/tc-h8300.c 25 Jun 2003 11:09:47 -0000
@@ -1302,6 +1302,7 @@ get_specific (instruction, operands, siz
#endif
if (((x_size == L_16 && op_size == L_16U)
+ || (x_size == L_8 && op_size == L_8U)
|| (x_size == L_3 && op_size == L_3NZ))
/* We're deliberately more permissive for ABS modes. */
&& (op_mode == ABS
Index: gas/testsuite/gas/h8300/h8sx_mov_imm.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/h8300/h8sx_mov_imm.d,v
retrieving revision 1.1
diff -u -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.1 h8sx_mov_imm.d
--- gas/testsuite/gas/h8300/h8sx_mov_imm.d 10 Jun 2003 07:33:46 -0000 1.1
+++ gas/testsuite/gas/h8300/h8sx_mov_imm.d 25 Jun 2003 11:09:47 -0000
@@ -289,5 +289,19 @@ Disassembly of section \.text:
.*: 00 00 48 00 *
.*: 00 01 80 00 *
.*: R_H8_DIR32 bar
+.*: 79 74 ff ff * 79 74 ff ff 00 00 * mov.w #0xffff,@r0
+.*: 00 00 *
+.*: 01 5d 00 00 * 01 5d 00 00 * mov.w #0x0,@r0
+.*: 01 5d 00 01 * 01 5d 00 01 * mov.w #0x1,@r0
+.*: 01 5d 00 ff * 01 5d 00 ff * mov.w #0xff,@r0
+.*: 79 74 01 00 * 79 74 01 00 00 00 * mov.w #0x100,@r0
+.*: 00 00 *
+.*: 7a 74 ff ff * 7a 74 ff ff ff ff 00 00 * mov.l #0xffffffff,@r0
+.*: ff ff 00 00 *
+.*: 01 0d 00 00 * 01 0d 00 00 * mov.l #0x0,@r0
+.*: 01 0d 00 01 * 01 0d 00 01 * mov.l #0x1,@r0
+.*: 01 0d 00 ff * 01 0d 00 ff * mov.l #0xff,@r0
+.*: 7a 7c 01 00 * 7a 7c 01 00 00 00 * mov.l #0x100,@r0
+.*: 00 00 *
.* <.*>:
\.\.\.
Index: gas/testsuite/gas/h8300/h8sx_mov_imm.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/h8300/h8sx_mov_imm.s,v
retrieving revision 1.1
diff -u -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.1 h8sx_mov_imm.s
--- gas/testsuite/gas/h8300/h8sx_mov_imm.s 10 Jun 2003 07:33:46 -0000 1.1
+++ gas/testsuite/gas/h8300/h8sx_mov_imm.s 25 Jun 2003 11:09:47 -0000
@@ -93,6 +93,18 @@
mov.l #.L1,@0x18000
mov.l #bar,@0x18000
+ mov.w #-1,@er0
+ mov.w #0,@er0
+ mov.w #1,@er0
+ mov.w #0xff,@er0
+ mov.w #0x100,@er0
+
+ mov.l #-1,@er0
+ mov.l #0,@er0
+ mov.l #1,@er0
+ mov.l #0xff,@er0
+ mov.l #0x100,@er0
+
.globl bar
bar:
.space 16
More information about the Binutils
mailing list