templates and assembler
manu
manu_member at pathlink.com
Sat Mar 25 09:41:46 PST 2006
Hi there!
I´m new to D and quite surprised about all the nice features it provides. So I
started to write some test apps and also tried to write some templates. It all
worked perfect until I wanted to use template identifiers in asm blocks.
consider the following:
/* file - main.d **************************************/
01: template sine(REAL) // where REAL should be one of float,double,real
02: {
03: float sine(REAL x)
04: {
05: asm
06: {
07: naked ; // <- make it naked to get maximum speed
08: fld REAL ptr[ESP+4] ; // <- critical opcode
09: fsin ;
10: ret ;
11: }
12: }
13: }
14: alias sine!(float) sine_float; // instantiation
/ *****************************************************/
An error occurs when typing the last line, due to the instantiation. It says:
main.d(8): end of instruction
I´ve figured out that it comes because of the REAL in the asm block. I also
tried this for line 08:
08: fld x
Though this compiles there remains an error at runtime: the program assumes x to
be at a different position on the stack and so just a dump of stack memory is
loaded into the FPU. May this an unfixed bug of the compiler(I´m using dmd)?
I would be very thankful to everybody who helps me fixing that problem!
More information about the Digitalmars-d
mailing list