delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/07/02/14:09:43

Date: Thu, 02 Jul 92 18:56:37 PRT
From: "Jose M. Cerqueira Esteves" <FESTEVES%PTEARN AT clvm DOT clarkson DOT edu>
Subject: shifting long long ints creates bad assembler
To: djgpp AT sun DOT soe DOT clarkson DOT edu

Greetings

Apparently, GCC 2.01 for the 386 (DJGPP 1.06) can't handle shifts of
long long ints (64 bit ints) (was this expected?), and produces BAD
assembler when one tries to use those shifts:

When I tried to compile the following
======================= file tbug.c ======================
#include <stdio.h>

void
main()
{
  long long int one = 1;
  double trouble;

  scanf ("%lf",&trouble);

  trouble = trouble / (one << 35);
  printf ("%f/n",trouble);
}
==========================================================
GCC reported:

 tbug.c:25:invalid character '%' in opcode


The "25" above refers in fact to line 25 of the assembler file:

======================= file tbug.s ======================
        .file   "tbug.c"
gcc2_compiled.:
.text
LC0:
        .ascii "%lf\0"
LC1:
        .ascii "%f/n\0"
        .align 2
.globl _main
_main:
        pushl %ebp
        movl %esp,%ebp
        subl $16,%esp
        call ___main
        movl $1,-8(%ebp)
        movl $0,-4(%ebp)
        leal -16(%ebp),%eax
        pushl %eax
        pushl $LC0
        call _scanf
        movl -8(%ebp),%eax
        movl -4(%ebp),%edx
        movl %eax,%edx
        xorl %eax,%eax
        sal%edx $3,%edx             <---- this is line 25
        pushl %edx
        pushl %eax
        fildll (%esp)
        addl $8,%esp
        fdivrl -16(%ebp)
        fstpl -16(%ebp)
        pushl -12(%ebp)
        pushl -16(%ebp)
        pushl $LC1
        call _printf
L1:
        leave
        ret
==========================================================

If a variable is used instead of "35" in "(one << 35)" the effects are
even more catastrofic.

Perhaps this is not the correct mailing list to report this, but it may
be of interest to you...

I am using DJGPP 1.06 on a 486, under MS-DOS 5.00.

                                       Jos\'e Esteves
Acknowledge-To: <FESTEVES AT PTEARN>

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019