learn,how to mix C and Assembly Language ?, Basic Computer Science

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.
Posted Date: 5/4/2012 8:26:11 AM | Location : United States







Related Discussions:- learn,how to mix C and Assembly Language ?, Assignment Help, Ask Question on learn,how to mix C and Assembly Language ?, Get Answer, Expert's Help, learn,how to mix C and Assembly Language ? Discussions

Write discussion on learn,how to mix C and Assembly Language ?
Your posts are moderated
Related Questions



WHAT DO MEAN BY ALGORITHM,HOW CAN ALGORITHM HELP TO WRITE BETTER COMPUTER PROGRAM ,WRITE AN ALGORITHM IN COMPUTER INTEREST

Question: CarRide.com is the web portal to CarRide Ltd; a car rental company that makes full use of technological advances to make sure you enjoy the ride with your rental car.


Question 1 What is Content Addressable Storage? Explain the elements of Content Addressable Storage Question 2 Explain briefly about DAS Question 3 Explain about N

Opening Documents Situated on Different Computers In order to work with documents situated on other computers, you need sufficient rights to access the folder in which it is

Characteristics of Artificial Intelligence: Artificial Intelligence is not an easy science to describe, as it has fuzzy borders with simulation mathematics, computer science t

You may have seen, as, that many programs can be run so that they give you with some basic information concerning how they should be run. Python permits you to do this with -h: $ p