From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <626179c9c80b6b82cfbaa9789a485bac@terzarima.net> To: 9fans@cse.psu.edu Subject: Re: [9fans] fp: stack underflow error From: Charles Forsyth Date: Fri, 2 Jul 2004 10:34:41 +0100 In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-jknstduvduujhofdsqdvrfxrsd" Topicbox-Message-UUID: b353191e-eacd-11e9-9e20-41e7f4b1d025 This is a multi-part message in MIME format. --upas-jknstduvduujhofdsqdvrfxrsd Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit that produced invalid operation when i tried it, not the stack underflow of the previous example. the result won't fit in a signed integer, and unsigned integer isn't supported by the hardware, so you get a trap as documented. in fact, the compiler could and probably should compensate by converting to and from 64-bit signed integers, which would also eliminate the test-and-skip mentioned earlier. i think 64-bit is supported, since it's listed with an opcode, although the textual description then claims `word- or short-integer format' only. it's an Intel handbook. ``beware DEC manuals'' the stack underflow is more likely to be a compiler problem. (stack overflow on the other hand is quite likely to be a missing prototype.) --upas-jknstduvduujhofdsqdvrfxrsd Content-Type: message/rfc822 Content-Disposition: inline Received: from mail.cse.psu.edu ([130.203.4.6]) by lavoro; Thu Jul 1 20:20:30 BST 2004 Received: from psuvax1.cse.psu.edu (localhost [127.0.0.1]) by mail.cse.psu.edu (CSE Mail Server) with ESMTP id 0BB201A110 for ; Thu, 1 Jul 2004 15:18:33 -0400 (EDT) X-Original-To: 9fans@cse.psu.edu Delivered-To: 9fans@cse.psu.edu Received: from localhost (neuromancer.cse.psu.edu [130.203.4.2]) by mail.cse.psu.edu (CSE Mail Server) with ESMTP id C244319EE4 for <9fans@cse.psu.edu>; Thu, 1 Jul 2004 15:18:20 -0400 (EDT) Received: from mail.cse.psu.edu ([130.203.4.6]) by localhost (neuromancer [130.203.4.2]) (amavisd-new, port 10024) with LMTP id 22286-02-58 for <9fans@cse.psu.edu>; Thu, 1 Jul 2004 15:18:17 -0400 (EDT) Received: from smtp.vitanuova.com (unknown [62.254.170.97]) by mail.cse.psu.edu (CSE Mail Server) with ESMTP id E6D6519BAC for <9fans@cse.psu.edu>; Thu, 1 Jul 2004 15:18:16 -0400 (EDT) Message-ID: To: 9fans@cse.psu.edu Subject: Re: [9fans] fp: stack underflow error Date: Thu, 1 Jul 2004 20:24:23 +0100 From: rog@vitanuova.com In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at cse.psu.edu X-BeenThere: 9fans@cse.psu.edu X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> List-Id: Fans of the OS Plan 9 from Bell Labs <9fans.cse.psu.edu> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: 9fans-bounces+forsyth=terzarima.net@cse.psu.edu Errors-To: 9fans-bounces+forsyth=terzarima.net@cse.psu.edu > I encountered a "sys: fp: stack underflow" error in my program. looks like a compiler bug. here's a simpler version of the code that does the same thing. who'd've thought that a2b() would generate such convoluted code? what's that comparison for? TEXT a2b+0(SB),0,$12 MOVL tb+4(FP),CX SUBL fb+0(FP),CX MOVL CX,.safe+-4(SP) FMOVL .safe+-4(SP),F0 CMPL CX,$0 JGE ,2(PC) FADDD $(4.29496729600000000e+09),F0 FMULD dis+8(FP),F0 FSTCW ,.safe+-8(SP) MOVW $3967,.safe+-6(SP) FLDCW .safe+-6(SP), FMOVLP F0,.safe+-4(SP) FLDCW .safe+-8(SP), MOVL .safe+-4(SP),AX RET , #include #include int a2b(int fb, uint tb, double dis) { return (tb - fb)*dis; } void main(void) { a2b(1, 0, 65); a2b(1, 0, 66); } --upas-jknstduvduujhofdsqdvrfxrsd--