Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- //asm(".intel_syntax noprefix");
- //asm(".att_syntax prefix");
- /*usa assembler extend con inclusion explicita de la instruccion imul*/
- int funcion(){
- int no = 100, val ;
- asm ("movl %1, %%ebx;"
- "movl %%ebx, %0;"
- : "=r" ( val ) /* output */
- : "r" ( no ) /* input */
- : "%ebx" /* clobbered register */
- );
- return val;
- }
- int foo()
- {
- int output(0);
- int some_obscure_name (5); // "param" will be accessible in inline Assembly.
- asm( "mov %0, %%eax "
- : "=r"(output) /* output */
- : "r" (some_obscure_name)/* input */
- : /* clobbered register */
- );
- return output;
- }
- int foo2(int entrada)
- {
- int output(0);
- asm( "mov %0, %%eax "
- : "=r"(output) /* output */
- : "r" (entrada)/* input */
- : /* clobbered register */
- );
- return output;
- }
- int foo3()
- {
- //at&t memonico fuente,destino
- struct pto{int x;int y;};
- pto punto {7,5};
- //int output(0);
- pto output {0,0};
- asm(
- "mov %0, %%eax ;"//struct punto-> eax , eax contiene la structura
- "mov %%eax, %1 ;"//eax->output
- : "=r"(output) /* %1 output */
- : "r" (punto) /* %0 input */
- : /* clobbered register */
- );
- return output.x;
- }
- int main(){
- cout <<" salida "<<funcion()<<endl;
- cout <<" salida "<<foo()<<endl;
- cout <<" salida "<<foo2(69)<<endl;
- cout <<" salida "<<foo3()<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement