Computed lengths are used as 32 bit values, even when they are less than 128. Symbols assigned values less than 128 and used generate a one byte immediate in pushl $value, while symbols with computed lengths appear as 4 byte immediate values, even though they have the same small value.
Alan azp:68% cat b.s ; as -a b.s -o b.o .text msg: .asciz "hello world.\n" msglen = .-msg-1 # determine length, an absolute value #msglen=msglen & 0xff # this crashes the assembler if included foo = 13 pushl $13 # this generates a 2 byte instruction pushl $msglen # this generates 4 bytes for the same pushl $foo # but this generates 2 bytes pushl msg GAS LISTING b.s page 1 1 .text 2 3 0000 68656C6C msg: .asciz "hello world.\n" 3 6F20776F 3 726C642E 3 0A00 4 msglen = .-msg-1 # determine length, an absolute value 5 #msglen=msglen & 0xff # this crashes the assembler if included 6 foo = 13 7 8 000e 6A0D pushl $13 # this generates a 2 byte instruction 9 0010 680D0000 pushl $msglen # this generates 4 bytes for the same 9 00 10 0015 6A0D pushl $foo # but this generates 2 bytes 11 0017 FF350000 pushl msg 11 00008D76 11 00 GAS LISTING b.s page 2 DEFINED SYMBOLS b.s:3 .text:00000000 msg *ABS*:0000000d msglen *ABS*:0000000d foo NO UNDEFINED SYMBOLS -- Summary: generates non-optimal instruction... Product: binutils Version: 2.12.1 Status: NEW Severity: normal Priority: P2 Component: gas AssignedTo: unassigned at sources dot redhat dot com ReportedBy: larson at w6yx dot stanford dot edu CC: bug-binutils at gnu dot org GCC host triplet: Freebsd i386 GCC target triplet: i386 http://sources.redhat.com/bugzilla/show_bug.cgi?id=998 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils