the technique to mix c and assembly language is


The technique to mix C and assembly language is to apply the "asm" directive. To access C-language variables from assembly language, you just use the C identifier that name is a memory operand. These variables cannot be local to a procedure, and also cannot be static within a procedure. They have to be global (but can be static global). The newline characters are essential.
unsigned long a1, r;
void junk( void )
{
asm(
"pushl %eax \n"
"pushl %ebx \n"
"movl $100,%eax \n"
"movl a1,%ebx \n"
"int $59 \n"
"movl %eax,r \n"
"popl %ebx \n"
"popl %eax \n"
);
}

This instance does the following:
1. Pushes the value stored in %eax and %ebx onto the stack.
2. Puts a value of 100 into %eax.
3. Copies the value in global variable a1 into %ebx.
4. Executes a software interrupt number 59.
5. Copies the value in %eax into the global variable r.
6. Restores (pops) the contents of the temporary registers %eax and %ebx.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: the technique to mix c and assembly language is
Reference No:- TGS0154902

Expected delivery within 24 Hours