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 IS DATA STRUCTURE AND EXPLAIN ME.

Question 1 Write short note on                             1) NFS 2) CIFS Question 2 What is Virtual Application? Write down the benefits and drawbacks of it Questi

1. What actions need to be taken when a program terminates or a process is killed? What if that process destruction is not the consequence of normal termination, but rather is the

what is the short and complete definition of computer

Question (a) A dairy wants to determine the quantity of butter it should produce to meet the demand. Past records have shown the following demand pattern:

Information Units In order for the PC to process information, it is essential that this information be in unique cells called registers. The registers are sets of 8 or 16 flip-flop

Memory : Computers store information internally as well as externally. Linked to CPU is an internal memory unit where all the instructions and data are stored. It contains the

Artificial Intelligence Agents: We discussed what we will be talking about in Artificial Intelligence and why those things are important. This chapter is all about how we wi

Hi There, can you help me with my small project please, i have sent it yesterday and you dont replay. can you please ethir lem me know you can do it or no Regrads Meshari

Assignment Task: You are required to develop working solutions in Excel that will manage the annual budget, current month’s inventory, and a list of the current month’s transaction