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
If L is a regular language show that L U {a} is regular

Question 1 What is HTTP? How does it work? Question 2 What are the various methods of HttpServletResponse interface? Question 3 What is Web server? What are the va

We normally think of the arts as very different from technologies in spite of the fact that art (with perhaps a few exceptions) is practiced with the help of technology. This pract

Problem 1. Explain the different categories of instructions. Explanation of 4 categories 2. Explain the steps to be followed for the addition of floating point numb

Code for Program to find the second highest number from a given array in Assembly Language by using NASM

QUESTION (a) Define z-transform of sequence x[n]. (b) A causal LTI system has impulse response h[n], for which the z-transform is                     H(z) = (1+z -1

Types of Search Engine:   Some of the basic categories of Search engines are :  a. Primary Search Engines: Such search engines use web crawlers or spiders to traverse the w

Working of web Browser:   Internet is characterized by the Client Server Computing that consists of three basic components: The Web client which may be the web browser;

Sometimes you may drop to perform conversions among the built-in types. To translate between types you just use the type name as a function. There are quite a few built-in function

Security threats on internet:  The Internet has many advantages; however, it also opens up security threat. In this section we just want to highlight some of the threats that