Soit le fichier fma.c suivant: float fma(float a, float b, float c) { asm("mul.fma %0,%2,%3" : "=f" (a) : "0" (a), "f" (b), "f" (c)); return a; } main(){ float a=2.0; float b=3.0; float c=4.0; a=fma(a,b,c);/*a=a*b+c=10.0*/ printf("%f\n", a); } L'instruction "mul.fma" est une nouvelle instruction à ajouter à Pisa. On commence par définir "mul.fma" dans machine.def (lien vers target-pisa/pisa.def) #define FMA_S_IMPL \ { \ if (((FD) & 01) || ((FS) & 01) || ((FT) & 01)) \ DECLARE_FAULT(md_fault_alignment); \ \ SET_FPR_F(FD, FPR_F(FD) * FPR_F(FS) + FPR_F(FT)); \ } DEFINST(FMA_S, 0x7e, "mul.fma", "D,S,T", FloatMULT, F_FCOMP|F_LONGLAT, DFPR_F(FD), DNA, DFPR_F(FD), DFPR_F(FS), DFPR_F(FT)) Elle reçoit le code opération 7e qui est libre. On ajoute en fin de fichier la ligne: #undef FMA_S_IMPL C'est tout pour le simulateur. Il faut cependant modifier l'assembleur pour qu'il sache reconnaître l'instruction. L'assembleur est dans simpleutils-990811. On va éditer le fichier opcodes/ss-opc.c: {"mul.fma", "D,V,T", 0x0000007e, 0x0000ffff, 0 }, La ligne est insérée entre "mul.d" et "mul.s". Il faut reconstruire les utils: ./configure --host=i386-unknown-linux --target=sslittle-na-sstrix --with-gnu-as --with-gnu-ld --prefix=/home/goossens/Sim3 make make install Il faut aussi reconstruire le simulateur: make config-pisa make Il reste à compiler le fichier fma.c: bin/sslittle-na-sstrix-gcc -o fma fma.c On exécute la simulation: ./sim-outorder fma