Template Arguments in inline ASM

John Kiro johnkirollos at yahoo.com
Fri Sep 7 05:37:18 PDT 2007


Hell There

I made the following example to see how far can inline asm blocks use template args:
	========================================
	void asm_template(T)(T Tval,T* pDest)
	{
		asm{
			fld Tval;
			mov EAX,pDest;
			fstp T ptr[EAX];             //#1
			fstp float ptr[EAX];        //#2
			mov EDX,T.sizeof;        //#3
			mov ECX,float.sizeof;   //#4
		}//asm
	}//asm_template
		
	void main()
	{
	  float f1=4.0;
	  float f2=5.0;
	
	  asm_template!(float)(f1,&f2);
	}
	========================================
Here is the compilation result of the 4 statements marked above:
#1: ERROR: "cannot use type float as an operand"
#2: OK
#3: OK!!!
#4: ERROR: "ptr expected"

For me, if #1 would be illegal, then the error should not have mentioned "type float". In other words, why would it fail if T is correctly interpreted to float?
I also see that it's surprising that #3 compiles while #4 doesn't (the reverse would be more natural).
In conclusion, I see that template args are partially (and unclearly) supported inside ASM blocks. Me, I hope to have better support for aliases & template args in ASM blocks.
What do you think friends?

Regards,
John



More information about the Digitalmars-d mailing list