Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!rutgers!sri-spam!nike!ucbcad!ucbvax!CORY!dillon From: dillon@CORY (Matt Dillon) Newsgroups: net.micro.amiga Subject: LATTICE BUG (3.03) -unsigned? short optimization bug Message-ID: <8610020736.AA09001@cory.Berkeley.EDU> Date: Thu, 2-Oct-86 03:36:22 EDT Article-I.D.: cory.8610020736.AA09001 Posted: Thu Oct 2 03:36:22 1986 Date-Received: Sat, 4-Oct-86 05:20:18 EDT Sender: uucp@ucbvax.BERKELEY.EDU Organization: University of California at Berkeley Lines: 86 Here is an obscure lattice bug. V3.03 (no suffix) I'm probably the only one who has run into it. CODE: main() { unsigned short x, xx; unsigned short y = 0xFFFF; unsigned short z = 2; x = (y + z) / 16; xx= ((y + z) / 16); printf ("x = %ld %ld\n", x, xx); } EXPECTED RESULT: (remember, y and z are supposed to be expanded to ints first) 4096 4096 ACTUAL RESULT: 1 1 SUSPECTED CAUSE: seems to be related to the fact that I'm assigning TO a short (x,xx) rather than an int. BACKGROUND: This came up while I was programming some 3-D graphics routine.. It was a particulary tricky line which failed miserably when the compiler failed to follow the standard C def. It's very obscure, but should be fixed. -Matt ---------------------------- OMD assembly: LATTICE OBJECT MODULE DISASSEMBLER V2.00 Amiga Object File Loader V1.00 68000 Instruction Set EXTERNAL DEFINITIONS _main 0000-00 SECTION 00 "text" 00000050 BYTES 0000 4E56FFF8 LINK A6,FFF8 0004 48E72000 MOVEM.L D2,-(A7) 0008 70FF MOVEQ #FF,D0 000A 7202 MOVEQ #02,D1 000C 3D40FFFA MOVE.W D0,FFFA(A6) 0010 D041 ADD.W D1,D0 0012 243C00040000 MOVE.L #00040000,D2 <---- 0018 E468 LSR.W D2,D0 <---- 001A 3D40FFFC MOVE.W D0,FFFC(A6) should be move 001E 3D40FFFE MOVE.W D0,FFFE(A6) imm #4 and 0022 02800000FFFF ANDI.L #0000FFFF,D0 LSR.L 0028 7400 MOVEQ #00,D2 002A 342EFFFC MOVE.W FFFC(A6),D2 002E 2F02 MOVE.L D2,-(A7) 0030 2F00 MOVE.L D0,-(A7) 0032 4879 00000000-01 PEA 01.00000000 0038 3D41FFF8 MOVE.W D1,FFF8(A6) 003C 4EB9 00000000-XX JSR _printf 0042 4FEF000C LEA 000C(A7),A7 0046 4CDF0004 MOVEM.L (A7)+,D2 004A 4E5E UNLK A6 004C 4E75 RTS SECTION 01 "data" 00000010 BYTES 0000 78 20 3D 20 25 6C 64 20 25 6C 64 0A 00 00 00 00 x = %ld %ld..... SECTION 02 "udata" 00000000 BYTES -Matt