bfd/
[deliverable/binutils-gdb.git] / gas / config / tc-maxq.c
index 43784c9c330da13fc821487dc1132b1cab62141b..e6987e15c2af6cba6b42ca1acf835015d40e72b4 100644 (file)
@@ -20,7 +20,7 @@
 
    You should have received a copy of the GNU General Public License along
    with GAS; see the file COPYING.  If not, write to the Free Software
-   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #include "as.h"
 #include "safe-ctype.h"
@@ -376,7 +376,9 @@ md_estimate_size_before_relax (fragS *fragP, segT segment)
 
       /* This is the offset if it is a PC relative jump.  */
       call_addr = S_GET_VALUE (fragP->fr_symbol) + fragP->fr_offset;
-      diff = (call_addr - instr);
+
+      /* PC stores the value of the next instruction.  */
+      diff = (call_addr - instr) - 1;
 
       if (diff >= (-128 * 2) && diff <= (2 * 127))
        {
@@ -492,7 +494,7 @@ md_convert_frag (object_headers * headers ATTRIBUTE_UNUSED,
                 fragS *          fragP)
 #endif
 {
-  unsigned char *opcode;
+  char *opcode;
   offsetT target_address;
   offsetT opcode_address;
   offsetT displacement_from_opcode_start;
@@ -510,7 +512,8 @@ md_convert_frag (object_headers * headers ATTRIBUTE_UNUSED,
     (fragP->fr_address / MAXQ_OCTETS_PER_BYTE) +
     ((fragP->fr_fix - 2) / MAXQ_OCTETS_PER_BYTE);
 
-  displacement_from_opcode_start = (target_address - opcode_address);
+  /* PC points to the next Instruction.  */
+  displacement_from_opcode_start = ((target_address - opcode_address)  - 1);
 
   if ((displacement_from_opcode_start >= -128
        && displacement_from_opcode_start <= 127)
@@ -518,9 +521,7 @@ md_convert_frag (object_headers * headers ATTRIBUTE_UNUSED,
          || fragP->fr_subtype == NO_PREFIX))
     {
       /* Its a displacement.  */
-      char *p = (char *) &opcode[0];
-
-      *p = (char) displacement_from_opcode_start;
+      *opcode = (char) displacement_from_opcode_start;
     }
   else
     {
@@ -539,7 +540,6 @@ md_convert_frag (object_headers * headers ATTRIBUTE_UNUSED,
       if (fragP->fr_subtype != SHORT_PREFIX)
        {
          RELOC_ENUM reloc_type;
-         unsigned char *opcode;
          int old_fr_fix;
          int size = 2;
 
@@ -554,7 +554,6 @@ md_convert_frag (object_headers * headers ATTRIBUTE_UNUSED,
          if (reloc_type == 1)
            size = 0;
          old_fr_fix = fragP->fr_fix;
-         opcode = (unsigned char *) fragP->fr_opcode;
 
          fragP->fr_fix += (size);
 
@@ -584,13 +583,13 @@ maxq_number_to_chars (char *buf, valueT val, int n)
 
 /* GAS will call this for each fixup. It's main objective is to store the
    correct value in the object file. 'fixup_segment' performs the generic
-   overflow check on the 'valueT *val' argument after md_apply_fix3 returns.
+   overflow check on the 'valueT *val' argument after md_apply_fix returns.
    If the overflow check is relevant for the target machine, then
-   'md_apply_fix3' should modify 'valueT *val', typically to the value stored 
+   'md_apply_fix' should modify 'valueT *val', typically to the value stored 
    in the object file (not to be done in MAXQ).  */
 
 void
-md_apply_fix3 (fixS *fixP, valueT *valT, segT seg ATTRIBUTE_UNUSED)
+md_apply_fix (fixS *fixP, valueT *valT, segT seg ATTRIBUTE_UNUSED)
 {
   char *p = fixP->fx_frag->fr_literal + fixP->fx_where;
   char *frag_to_fix_at =
@@ -2766,7 +2765,8 @@ output_disp (fragS *insn_start_frag, offsetT insn_start_off)
            ((((expressionS *) symbol_get_value_expression (sym))->
              X_add_number) - insn_start_off);
 
-         diff = diff / MAXQ_OCTETS_PER_BYTE;
+         /* PC points to the next instruction.  */
+         diff = (diff / MAXQ_OCTETS_PER_BYTE) - 1;
 
          if (diff >= -128 && diff <= 127)
            {
This page took 0.024399 seconds and 4 git commands to generate.