bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

supposed bug in assembler "as"


From: Daniela Rütting
Subject: supposed bug in assembler "as"
Date: Tue, 06 Nov 2007 14:46:45 +0100

Hello,
I encountered a problem which seems to be a bug in the assembler 'as':
Redefining a symbol with the '.set' directive in connection with the location 
counter does not work correctly.
I am using:
GNU assembler 2.14 20030612, configured for `i586-pc-msdosdjgpp', getting to 
DOS from Windows 98.

I hope that the condensed little program I append (also in the file 
'astest.S'), while isolating the supposed bug, contains all necessary 
information.

Greetings from Germany,  B. Strowitzki 

#----- start of sample program ----
 .section .data
 .p2align 4,,15
somedata: .int 1,2,3,4,5,6,7,8,9,0  /* dummy values */
 .set goodval_1, (.-somedata)/4  /* calculate number of entries */
 .set badval, (.-somedata)/4
startval: .int badval     /* retaining badval for later printing */
/*      in real program to be stored into a "C"-defined struct
        producing an entry like "datablock.length" */

moredata:
 .rept 1024
 .byte 32
 .endr
 .set goodval_2, (.-moredata)  /* same procedure again */
 .set badval, (.-moredata)     /* redefining badval, ok */
midval: .int badval

evenmoredata: .space 200
 .set goodval_3, (.-evenmoredata)
 .set badval, (.-evenmoredata)  /* third definition: doesn't work!
                                   'as' seems to get confused   */
#  /* shortcut with self-diagnosis by 'as' */
#  /* gives an extra error message, but works */
#    .if (goodval_3-badval) 
#    .print "difference encountered"
#    .err
#    .endif
breakval: .int badval

lastdata:
 .space 1200, -1
 .set goodval_4, (.-lastdata)/4
 .set badval, (.-lastdata)/4  /* doesn't work also */

# further strange behavior
 .set dotval_good_1, .
 .set dotval_bad, .
firstdot: .int dotval_bad   /* no problem so far */
 .space 12  /* dummy */
 .set dotval_good_2, .
 .set dotval_bad, .   /* corrupts the value already stored in 'firstdot' */
nextdot: .int dotval_bad  

format: .asciz " %i. right val: %i,  badval: %i\12\15"
 .section .text
 .p2align 4,,15
.globl _main
_main:
   pushl %ebp
   movl %esp,%ebp

    movl $startval,%eax
    pushl (%eax)
    pushl $goodval_1
    pushl $1
    pushl $format
    call _printf        /* emits equal numbers, ok */

    movl $midval,%eax
    pushl (%eax)
    pushl $goodval_2
    pushl $2
    pushl $format
    call _printf        /* emits equal numbers, ok */

    movl $breakval,%eax
    pushl (%eax)
    pushl $goodval_3
    pushl $3
    pushl $format
    call _printf      /* emits two different numbers */

    pushl $badval
    pushl $goodval_4
    pushl $4
    pushl $format
    call _printf       /* different numbers again */

    pushl $10   /* newline */
    call _putch

    movl $firstdot,%eax
    pushl (%eax)
    pushl $dotval_good_1
    pushl $5
    pushl $format
    call _printf      /* emits two different numbers
                         with last value assigned to 'dotval_bad' */

    movl $nextdot,%eax
    pushl (%eax)
    pushl $dotval_good_2
    pushl $6
    pushl $format
    call _printf      /* emits equal numbers, ok */

   xorl %eax,%eax   /* exit code zero */
   movl %ebp,%esp
   popl %ebp
   ret



_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066

Attachment: astest.S
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]