Article View: gnu.utils.bug
Article #1650gas-1.33(ns32k) fixups to .word and .int are byte-reversed
From: John F. Peters
Date: Wed, 31 May 1989 19:08
Date: Wed, 31 May 1989 19:08
182 lines
5763 bytes
5763 bytes
DESCRIPTION:
(1) .word and .int are fixed-up with bytes reversed
(2) "Probably harmless" used-before-set error in encode_operand(ns32k.c)
(3) Minor typo in #if !defined(32032) (ns32k.c)
REPEAT-BY:
Assemble this trivial program with a32k and inspect the output. Note
that ordinary integers appear (correctly) with lsb first, but expressions
requiring fixup are rendered msb first.
---------------------
.text
words:
.word 1
.word 2
.word L1-L0
.word L2-L0
ints:
.int 1
.int 2
.int L1-L0
.int L2-L0
labels:
L0:
.byte 0
L1:
.byte 0
L2:
.byte 0
---------------------
FIX:
32k has three sorts of constants:
big-endian immediate (md_number_to_imm) im_disp==0
big-endian displacement (md_number_to_disp) im_disp==1
little-endian (md_number_to_chars) im_disp==2
Fixup_segment(write.c) decides among these three cases based on
the fixS field fx_im_disp. However, cons(read.c) builds a fixS
using fix_new(write.c), which forces fx_im_disp to 0.
A similar situation arises during "broken_word" handling in
write_object_file(write.c).
My fix is conditional compiling of calls to fix_new_ns32k(ns32k.c),
with the im_disp parameter set to 2. This is not such a desirable
strategy since it introduces machine-dependence; a better approach
would be machine-dependent procedures for constants and "broken_words".
*** Makefile.00 Fri May 12 11:45:32 1989
--- Makefile Wed May 31 10:46:53 1989
***************
*** 50,59 ****
# to include the mc68851 mmu coprocessor instructions un-comment
# the next line, and comment out the following line. (68020 only)
! OPTIONS = -Dm68851
! # OPTIONS =
! a: a68
! @rm -f a
! @ln a68 a
! lint: lint_68k
# To make the VAX assembler compile as the default, un-comment the next five
--- 50,59 ----
# to include the mc68851 mmu coprocessor instructions un-comment
# the next line, and comment out the following line. (68020 only)
! # OPTIONS = -Dm68851
! #OPTIONS =
! #a: a68
! # @rm -f a
! # @ln a68 a
! #lint: lint_68k
# To make the VAX assembler compile as the default, un-comment the next five
***************
*** 75,83 ****
# To make the ns32k assembler compile as the default, un comment the
# next five lines, and comment out the 'a:' groups for the other assemblers.
! #OPTIONS =
! #a: a32k
! # @rm -f a
! # @ln a32k a
! #lint: lint_32k
# To make the sparc assembler compile as the default, un comment the
--- 75,83 ----
# To make the ns32k assembler compile as the default, un comment the
# next five lines, and comment out the 'a:' groups for the other assemblers.
! OPTIONS = -DNS32032
! a: a32k
! @rm -f a
! @ln a32k a
! lint: lint_32k
# To make the sparc assembler compile as the default, un comment the
*** ns32k.c.00 Thu May 11 12:35:16 1989
--- ns32k.c Wed May 31 10:43:06 1989
***************
*** 227,231 ****
};
! #if !defined(NS32032) && !defined(NS32032)
#define NS32032
#endif
--- 227,231 ----
};
! #if !defined(NS32032) && !defined(NS32532)
#define NS32032
#endif
***************
*** 733,736 ****
--- 733,737 ----
if (i>3) as_fatal("Internal error check ns32k-opcode.h");
pcrel=0;
+ pcrel_adjust=0;
tmp=0;
switch (operandsP[(loop<<1)+1]) {
*** read.c.00 Wed Mar 29 08:40:40 1989
--- read.c Wed May 31 10:32:37 1989
***************
*** 1300,1304 ****
--- 1300,1308 ----
register segT segment;
expressionS exp;
+ #if defined(NS32032) || defined(NS32532)
+ void fix_new_ns32k(); /* 32k requires im_disp==2 for small-endian consts */
+ #else
void fix_new();
+ #endif
/*
***************
*** 1395,1401 ****
--- 1399,1417 ----
case SEG_TEXT:
case SEG_DATA:
+ #if defined(NS32032) || defined(NS32532)
+ /*
+ * Ordinary (non-immed, non-disp) 32k constants are
+ * little-endian, communicate this to fixup_segment
+ * with im_disp == 2
+ */
+ fix_new_ns32k (frag_now, p - frag_now -> fr_literal, nbytes,
+ exp . X_add_symbol, exp . X_subtract_symbol,
+ exp . X_add_number, 0,
+ 0, 2, 0, 0);
+ #else
fix_new (frag_now, p - frag_now -> fr_literal, nbytes,
exp . X_add_symbol, exp . X_subtract_symbol,
exp . X_add_number, 0);
+ #endif
break;
*** write.c.00 Fri May 12 11:45:20 1989
--- write.c Wed May 31 10:38:50 1989
***************
*** 429,433 ****
--- 429,444 ----
for(lie=broken_words; lie; lie=lie->next_broken_word)
if(!lie->added) {
+ #if defined(NS32032) || defined(NS32532)
+ void fix_new_ns32k();
+ /*
+ * Ordinary (non-immed, non-disp) 32k constants are
+ * little-endian, communicate this to fixup_segment
+ * with im_disp == 2
+ */
+ fix_new_ns32k(lie->frag,lie->word_goes_here - lie->frag->fr_literal,2,lie->add,lie->sub,lie->addnum,0,
+ 0, 2, 0, 0);
+ #else
fix_new(lie->frag,lie->word_goes_here - lie->frag->fr_literal,2,lie->add,lie->sub,lie->addnum,0);
+ #endif
/* md_number_to_chars(lie->word_goes_here,
lie->add->sy_value
*****************
--
jfp@practic.com {uunet,sun,pyramid}!practic!jfp 408 749 8900
Technical Details
Message-ID:
<40913@practic.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!ames!versatc!leadsv!practic!jfpShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!ames!versatc!leadsv!practic!jfp From: jfp@practic.UUCP (John F. Peters) Newsgroups: gnu.utils.bug Subject: gas-1.33(ns32k) fixups to .word and .int are byte-reversed Message-ID: <40913@practic.UUCP> Date: 31 May 89 19:08:41 GMT Reply-To: jfp@practic.UUCP (John F. Peters) Distribution: gnu Organization: Practical Computing Inc., Sunnyvale Lines: 182