From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 112314 invoked by alias); 13 May 2015 11:02:36 -0000 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org Received: (qmail 112258 invoked by uid 48); 13 May 2015 11:02:36 -0000 From: "igorr at gitatechnologies dot com" To: gdb-prs@sourceware.org Subject: [Bug sim/18407] New: Bfin simulator - error in handling >>> (S), when shift value > 16 Date: Wed, 13 May 2015 11:02:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: sim X-Bugzilla-Version: 7.9 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: igorr at gitatechnologies dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-q2/txt/msg00266.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=18407 Bug ID: 18407 Summary: Bfin simulator - error in handling >>> (S), when shift value > 16 Product: gdb Version: 7.9 Status: NEW Severity: normal Priority: P2 Component: sim Assignee: unassigned at sourceware dot org Reporter: igorr at gitatechnologies dot com CC: vapier at gentoo dot org Target Milestone: --- 1. Let's compile the following code: $ cat > test1.s .global __start __start: LINK 0xc ; R1 = 2 ; R1 = R1 >>> 1; R1 = 2; R1 = R1 >> 1; R1 = 2; R1 = R1 >>> 1 (S); R1 = 2; .byte 0x82, 0xc6, 0xf9, 0x43 ; UNLINK; RTS; $ bfin-linux-uclibc-gcc -nostdlib test1.s -o test1 2. Run objdump on it: bfin-linux-uclibc-objdump -d test1 test1: file format elf32-bfinfdpic Disassembly of section .text: 00000074 <__start>: 74: 00 e8 03 00 LINK 0xc; /* (12) */ 78: 11 60 R1 = 0x2 (X); /* R1=0x2( 2) */ 7a: 82 c6 f9 03 R1 = R1 >>> 0x1; 7e: 11 60 R1 = 0x2 (X); /* R1=0x2( 2) */ 80: 82 c6 f9 83 R1 = R1 >> 0x1; 84: 11 60 R1 = 0x2 (X); /* R1=0x2( 2) */ 86: 82 c6 f9 43 R1 = R1 << 0x3f (S); 8a: 11 60 R1 = 0x2 (X); /* R1=0x2( 2) */ 8c: 82 c6 f9 43 R1 = R1 << 0x3f (S); 90: 01 e8 00 00 UNLINK; 94: 10 00 RTS; 3. Bug/Feature (binutils?) R1 = R1 >>> 1(S) is displayed as R1 = R1 << 0x3f (S); 4. Let's compile and run this code on VisualDSP++ environment simulator. in all 4 cases R1 will get the value 0x1 after the shift 5. Let's run the same test in bfin-simulator: $ bfin-linux-uclibc-gdb test1 GNU gdb (GDB) 7.9 ... Reading symbols from test1...(no debugging symbols found)...done. (gdb) b *0x74 Breakpoint 1 at 0x74 (gdb) set disassemble-next-line on (gdb) target sim Connected to the simulator. (gdb) load Loading section .text, size 0x24 lma 0x74 Start address 0x74 Transfer rate: 288 bits in <1 sec. (gdb) r Starting program: ./test1 Breakpoint 1, 0x00000074 in _start () => 0x00000074 <_start+0>: 00 e8 03 00 LINK 0xc; /* (12) */ (gdb) display/x $r1 1: /x $r1 = 0x0 (gdb) si 0x00000078 in _start () => 0x00000078 <_start+4>: 11 60 R1 = 0x2 (X); /* R1=0x2( 2) */ 1: /x $r1 = 0x0 (gdb) si 0x0000007a in _start () => 0x0000007a <_start+6>: 82 c6 f9 03 R1 = R1 >>> 0x1; 1: /x $r1 = 0x2 (gdb) si 0x0000007e in _start () => 0x0000007e <_start+10>: 11 60 R1 = 0x2 (X); /* R1=0x2( 2) */ 1: /x $r1 = 0x1 (gdb) si 0x00000080 in _start () => 0x00000080 <_start+12>: 82 c6 f9 83 R1 = R1 >> 0x1; 1: /x $r1 = 0x2 (gdb) si 0x00000084 in _start () => 0x00000084 <_start+16>: 11 60 R1 = 0x2 (X); /* R1=0x2( 2) */ 1: /x $r1 = 0x1 (gdb) si 0x00000086 in _start () => 0x00000086 <_start+18>: 82 c6 f9 43 R1 = R1 << 0x3f (S); 1: /x $r1 = 0x2 (gdb) si 0x0000008a in _start () => 0x0000008a <_start+22>: 11 60 R1 = 0x2 (X); /* R1=0x2( 2) */ 1: /x $r1 = 0x7fffffff (gdb) 6. Bug. After the last shift R1 should be equal to 0x1. Saturated shift Right is treated as saturated shift left. -- You are receiving this mail because: You are on the CC list for the bug.