Bug 14480 - PDP11 gas generates invalid code for deferred indirect JSR with 0 index
Summary: PDP11 gas generates invalid code for deferred indirect JSR with 0 index
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-16 16:40 UTC by Jordi Guillaumes Pons
Modified: 2012-08-22 12:41 UTC (History)
2 users (show)

See Also:
Host:
Target: pdp11-aout
Build:
Last reconfirmed:


Attachments
Assembly source file (97 bytes, application/octet-stream)
2012-08-16 16:40 UTC, Jordi Guillaumes Pons
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jordi Guillaumes Pons 2012-08-16 16:40:31 UTC
Created attachment 6582 [details]
Assembly source file

As seen at the following assembly listing:


GNU assembler version 2.22.0 (pdp11-aout) using BFD version (GNU Binutils) 2.22.0.20120725
GAS LISTING dic.s 			page 1


   1 0000 C0151000 	start:	mov	$ind,r0
   2 0004 C809     		jsr	pc,@(r0)
   3 0006 F8090000 		jsr	pc,@0(r0)
   4 000a F8090200 		jsr	pc,@2(r0)
   5 000e 0000     		halt
   6              	
   7              	
   8 0010 1400     	ind:	.WORD	dest
   9 0012 1600     		.WORD	dest2
  10              	
  11 0014 8700     	dest:	rts	pc
  12              	
  13 0016 8700     	dest2:	rts	pc
  14              		
  15              		.END

The instructions in lines 2 and 3 should both assemble to F8090000, but line 2 assembles like it was JSR PC,(R0).
Comment 1 Larry Baker 2012-08-22 00:39:29 UTC
See the NOTE at the bottom of page 5-5 in Section 5.8, INDEX DEFERRED MODE, in the PDP-11 MACRO-11 Language Reference Manual on the BitSavers web site (http://www.bitsavers.org/pdf/dec/pdp11/rsx11/RSX11M_V4.1_Apr83/4_ProgramDevelopment/AA-V027A-TC_macro11_Mar83.pdf):

   The expression @(ER) may be used, but it
   will be assembled as if it were written
   @0(ER), and a word will be used to store
   the 0.
Comment 2 Jordi Guillaumes Pons 2012-08-22 12:41:22 UTC
Additional information: the gcc compiler generates a JSR PC,@(Rx) to implement an indirect call thru a function pointer table, so this bug causes gcc generating invalid code.