SPARC Assembly Language Reference Manual

B.1 Example 1

This example shows how to use the following pseudo-ops to specify the bindings of variables in C:

common, .global, .local, .weak

The following C definitions/declarations:

	int			foo1 = 1;
	#pragma				weak foo2 = foo1
	static			int foo3;
	static			int foo4 = 2;

can be translated into the following assembly code:


Example B–1

	.pushsection	".data"

	.global	foo1	! int foo1 = 1
	.align	4
foo1:
	.word	0x1
	.type		foo1,#object				! foo1 is of type data object,
	.size		foo1,4				! with size = 4 bytes
       
	.weak			foo2			! #pragma weak foo2 = foo1
	foo2 = foo1

	.local			foo3			! static int foo3
	.common			foo3,4,4

	.align			4			! static int foo4 = 2
   foo4:
	.word			0x2
	.type			foo4,#object
	.size			foo4,4

	.popsection