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]

Q for inline arm assembly: 'M' constraint?


Ok guys, I'm trying to work up some fixed-point multiplication routines optimized in assembly for arm7. Here are two different functions.

The first does 16.16 multiply with 64-bit intermediate precision and the shifting / rounding for a 16.16 result.

[code]
inline int fixp_mul_32s_n16( int a, int b ) {
	int res, tmp;
	__asm__ __volatile__ (
		"smull	%0, %1, %2, %3			\n\t"
		"movs	%0, %0, lsr #16			\n\t"
		"adc	%1, %0, %1, lsl #(32-16)	\n\t"
		: "=&r" (res), "=&r" (tmp)
		: "r" (a), "r" (b)
	);
	return res;
}
[/code]

The other function was supposed to take a const argument for the "n" part of the Qm.n fixed-point format.

[code]
inline int fixp_mul_32s_nX( int a, int b, char n ) {
	int res, tmp;
	__asm__ __volatile__ (
		"smull	%0, %1, %2, %3			\n\t"
		"movs	%0, %0, lsr #%4			\n\t"
		"adc	%1, %0, %1, lsl #(32-%4)	\n\t"
		: "=&r" (res), "=&r" (tmp)
		: "r" (a), "r" (b), "M" (n)
	);
	return res;
}
[/code]

But the assembler complains with the below error output:

[console]
arm-elf-gcc -g -c -I ../../include -save-temps -O0 -MMD -MP -MF dep/test_math.d -o obj/test_math.o test_math.c
In file included from test_math.c:8:
fixp.h: In function `fixp_mul_32s_nX':
fixp.h:26: warning: asm operand 4 probably doesn't match constraints
fixp.h:26: error: impossible constraint in `asm'
[/console]


I assume that the problem is something to do with the "M" constraint, as I can use the first function without issue. So what is the correct way to use the "M" constraint? Or do I even need the "M" constraint? Or is there a better way to do this altogether?

Thanks in advance for your help,
- Bryce Schober

---
[This E-mail scanned for viruses by digiposs.com]


------ 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]