Assembler (Inline): OverviewHome | How Do I | DetailsAssembly language serves many purposes, such as improving program speed, reducing memory needs, and controlling hardware. You can use the inline assembler to embed assembly-language instructions directly in your C and C++ source programs without extra assembly and link steps. The inline assembler is built into the compiler — you don't need a separate assembler such as the Microsoft Macro Assembler (MASM).Note Programs with inline assembler code are not fully portable to other hardware platforms. If you are designing for portability, avoid using inline assembler.What do you want to know more about?Inline assemblerThe __asm keywordC or C++ in __asm blocksRegistersJumps to labelsC function calls from an __asm blockC++ function calls from an __asm block__asm blocks as C macrosOptimizing inline assembly code
he sabido que uno en un programa escrito en c (no se si en c++) puede tener partes de codigo en assembly ,mi pregunta va dirigida a que reglas y consideraciones hay que tener cuando uno hace esto ya que he intentado escribir algun trozo en assembly asi:ams{ //trozo de codigo}y los resultados han sido nefastos.alguien tiene experiencia en esto,con algunos consejos quedaria bien.
float Vector::operator * (const Vector& Vec){#if asm3dnow float total; _asm { femms movd mm0,dword ptr [ecx] movd mm1,dword ptr [ecx+4] movd mm2,dword ptr [ecx+8] mov eax,dword ptr [esp+8] movd mm3,dword ptr [eax] //Vec.x movd mm4,dword ptr [eax+4] //Vec.y movd mm5,dword ptr [eax+8] //Vec.z pfmul mm0,mm3 pfmul mm1,mm4 pfmul mm2,mm5 pfadd mm0,mm1 pfadd mm0,mm2 movd total,mm0 femms } return total;#endif#if asmsse float total; _asm { movss xmm0,dword ptr [ecx] movss xmm1,dword ptr [ecx+4] movss xmm2,dword ptr [ecx+8] mov eax,dword ptr [esp+8] movss xmm3,dword ptr [eax] movss xmm4,dword ptr [eax+4] movss xmm5,dword ptr [eax+8] mulss xmm0,xmm3 mulss xmm1,xmm4 mulss xmm2,xmm5 addss xmm0,xmm1 addss xmm0,xmm2 movss total,xmm0 } return total;#endif#if normal return x*Vec.x+y*Vec.y+z*Vec.z;#endif}