Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!ucla-cs!ucla-ma!euphemia!pmontgom From: pmontgom@euphemia.math.ucla.edu (Peter Montgomery) Newsgroups: comp.sys.mips Subject: Re: double -> int Message-ID: <1991Jun13.035702.2567@math.ucla.edu> Date: 13 Jun 91 03:57:02 GMT References: <1991Jun12.172740.22629@cs.cornell.edu> Sender: news@math.ucla.edu Organization: UCLA Mathematics Dept. Lines: 36 In article <1991Jun12.172740.22629@cs.cornell.edu> charney@cs.cornell.edu (Mark Charney) writes: > >Can someone give me the documentation for trunc.w.d? > >I'm trying to figure out what is going on with DOUBLE->INT conversion >on my mips chip. I've included a C program, the associated assembly >language file and a disassembly. > > # 5 c = (int) a ; > trunc.w.d $f6, $f4, $14 > swc1 $f6, 4($sp) > > [con.c: 5] 0x4001b0: 444ef800 cfc1 t6,$31 > [con.c: 5] 0x4001b4: 444ef800 cfc1 t6,$31 > [con.c: 5] 0x4001c0: 35c10003 ori at,t6,0x3 > [con.c: 5] 0x4001c4: 38210002 xori at,at,0x2 > [con.c: 5] 0x4001c8: 44c1f800 ctc1 at,$31 > [con.c: 5] 0x4001d0: 462021a4 cvt.w.d $f6,$f4 >x [con.c: 5] 0x4001d8: e7a60004 swc1 $f6,4(sp) > [con.c: 5] 0x4001dc: 44cef800 ctc1 t6,$31 >--------------------------------------------------------- I have Gerry Kane's "mips RISC Architecture", Prentice-Hall, 1989. Since register t6 is register 14 (p. D-2), I assume that the $14 on the trunc.w.d macro specifies which scratch register to use. I don't know why the cfc1 t6,$31 apears twice, but the code reads the Control/Status register FCR31 (p. 6-5) into t6 and changes its bottom bits to 01 binary before writing it back. Those are the RM (rounding mode) bits. The 01 says round to zero (p. 6-7). After the cvt.w.d, FCR31 is reset to its saved value from t6. -- Peter L. Montgomery pmontgom@MATH.UCLA.EDU Department of Mathematics, UCLA, Los Angeles, CA 90024-1555 If I spent as much time on my dissertation as I do reading news, I'd graduate.