This is the mail archive of the binutils@sourceware.org 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: Is it possible to branch to an absolute address ?


Amarnath wrote:
> HI,
> 
> I have a query in my mind. Please check the following sample assembly file:
> 
> ----------- Snip ---------------
> 
> 	.file	1 "TestingBranch.c"
> 	.set	mips16
> 
> gcc2_compiled.:
> __gnu_compiled_c:
> 	.text
> 	.align	2
> 	.globl	func
> 
> 	.align	2
> 	.globl	main
> 	.ent	main
> main:
> 	.frame	$17,16,$31		# vars= 8, regs= 2/0, args= 0,
> extra= 0
> 	.mask	0x80020000,-4
> 	.fmask	0x00000000,0
> 
>       b           0x4000            # >>> branch with absolute operand
>       move   	$sp,$17	
> $L2:
> 	.end  	main
> 
> 	.ent  	func
> 	func:
> 	.frame	$17,16,$31		# vars= 8, regs= 1/0,
> args= 0, extra= 0
> 	.mask	0x00020000,-8
> 	.fmask	0x00000000,0
> 	
> 	$L1:
> 		
> 	.end	func
> 
> -------------- End Snip ----------------
>
> - In the above, why GCC was not assembling the branch instruction with
> absolute value as operand in it?

Can you also provide the C source code?  I fail to see how C code could
result in such assembly.

> - Is there any restriction in branching towards absolute value in ELF?

The MIPS architecture defines branches as PC relative. For an absolute
address you need a jump.


Thiemo


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