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

See the CrossGCC FAQ for lots more information.


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: More inline arm assembly woes... (long)


Bryce Schober wrote:
int main() {

	float float_a, float_b;
	INT_32 int_a, int_b, result;
...
 	int_a = int_rand[0];
	int_b = int_rand[1];
	result = fixp_mul_32u_n16( int_a, int_b );
	int_a = int_rand[2];
	int_b = int_rand[3];
	result = result + fixp_mul_32u_n16( int_a, int_b );

	/* Loop forever */
	while(1) { GPIOC->dr ^= 0x08; }

Yup, gcc will optimize away 'result'. Declare it outside main, and/or make it volatile, and gcc will keep it around.

- Dan

--
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045


------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


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