This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: What is the specification about BFD_RELOC_AVR_7_PCREL, BFD_RELOC_AVR_13_PCREL ?


> -----Original Message-----
> From: binutils-owner On Behalf Of Houda Benabderrazik
> Sent: 10 June 2004 17:11
> To: binutils
> Subject: Re: What is the specification about 
> BFD_RELOC_AVR_7_PCREL, BFD_RELOC_AVR_13_PCREL ?
> 
> > > I want to know, how to determine the bit size of
> > howto
> > > relocation?
> > 
> > Look at the ABI.
> 
> What ABI?, I want to create Relocation for a specific
> micocontrolor as Motorola 68hc05, and i don't know how
> to create this relocation?  I don't know if i have to
> write fixup and relaxation before determining the
> relocation?
> From instruction like add for example, how to
> determine the relocation i need? 8bit, 16bit..?

  You have to look at the kind of instructions the CPU provides that contain
immediate memory addresses and branch offsets, and look at the format of the
opcodes for those instructions, and see how many bits are defined for the
addressing info.

  E.g. if 68hc05 had relative branches with a -128/+127 range, you'd want an
8-bit pc-relative relocation type for that.  If it had an immediate
addressing mode that could access any address between 0000 and 0xffff, you'd
need a 16-bit relocation type.  Etc, etc.

> there is an operation to do, that permit to compute
> the relocation address from the Program Counter
> address? 

  Generally when the cpu takes a branch, it calculates

    pc = pc + branch_offset_from_instruction

So you'd want to calculate the branch_offset as being 

     destination_of_branch - pc_address_of_branch_instruction

and put that value into the bitfield in the branch opcode that's for the
branch offset.


    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]