🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #50361

Re: (int) problem.

#50361
From: john e. clark
Date: Fri, 01 Oct 1993 19:43
71 lines
2150 bytes
In article <wgeQkLS00WB9ABYUkt@andrew.cmu.edu> ks37+@andrew.cmu.edu (Kurt Jurgen Schaefer) writes:
+I'm compiling code on on a sun3, and I run it on a 68040 board.  It
+seems to work for the most part, but casting floats to ints seems to be
+crashing the '040.  Here's the offending code:

--- the following is 'real' code.... host sun4, cross to m68k. with gcc-2.4.5.


8> more t.c		# list of code...

double yyDouble;

retInt()
{
        int myInt;

        myInt = (int)yyDouble;

        return( myInt );
}


9> gcc-m68k -S -O t.c 	# compile to asm code with no options...

10> more t.s

#NO_APP
gcc2_compiled.:
___gnu_compiled_c:
.text
        .even
.globl _retInt
_retInt:
        link a6,#0
        fintrzd _yyDouble,fp0
        fmovel fp0,d0
        unlk a6
        rts
.comm _yyDouble,8

11> gcc-m68k -m68040 -S -O t.c	# compile to asm with -m68040 option...

12> more t.s			# note the change of float ops here.

#NO_APP
gcc2_compiled.:
___gnu_compiled_c:
.text
        .even
.globl _retInt
_retInt:
        link a6,#0
        movel d2,sp@-
        fdmoved _yyDouble,fp0 	# appears to do the int conversion
				# by magic.
        fmoveml fpcr,d1
        moveq #16,d2
        orl d1,d2
        andw #-33,d2
        fmoveml d2,fpcr
        fmovel fp0,d0
        fmoveml d1,fpcr
        movel a6@(-4),d2
        unlk a6
        rts
.comm _yyDouble,8

-- 

John Clark
wa137@sdcc12.ucsd.edu
Technical Details
Message-ID: <54932@sdcc12.ucsd.edu>
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!udel!gatech!swrinde!elroy.jpl.nasa.gov!usc!math.ohio-state.edu!uwm.edu!ogicse!network.ucsd.edu!sdcc12!wa137
References: <wgeQkLS00WB9ABYUkt@andrew.cmu.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,808501f76b72dda7
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-10-01 13:15:27 PST
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!udel!gatech!swrinde!elroy.jpl.nasa.gov!usc!math.ohio-state.edu!uwm.edu!ogicse!network.ucsd.edu!sdcc12!wa137
From: wa137@sdcc12.ucsd.edu (john e. clark)
Newsgroups: gnu.gcc.help
Subject: Re: (int) problem.
Message-ID: <54932@sdcc12.ucsd.edu>
Date: 1 Oct 93 19:43:07 GMT
Article-I.D.: sdcc12.54932
References: <wgeQkLS00WB9ABYUkt@andrew.cmu.edu>
Sender: news@sdcc12.ucsd.edu
Organization: University of California, San Diego
Lines: 71
Nntp-Posting-Host: sdcc12.ucsd.edu