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
product of two numbers

Ask question #Minimum assignment on generations of computers 100 words accepted#

Backup Storage: Back up (backing) storage, also termed external storage, is used to hold programs and data which are read into internal storage when required. The most common

define complement?

Bandwidth: Bandwidth is the second concept important for transmission. This concept can be explained with the help of the traffic network mentioned earlier. If there is a two-

How do I change file permissions? Every time I execute chmod commands it tells me permission denied.

Advantages:- • Sharing Treads permit the sharing of a lot resources that cannot be shared in process, for instance, sharing code section, data section, Operating System resource

THE MICROPROCESSOR The three fundamental units, which comprise a CPU, have now been discussed in general terms.  So too has a microprocessor, because a microprocessor can be de

Question 1 Write a note on modems Question 2 What are the Safe Chatting Rules Question 3 Explain three basic kinds of hypertext links Question 4 Write a no

Question 1 Explain the operations of ALU Question 2 Write down the Booth's Multiplication Algorithm with an example Question 3 Explain the characteristics of memor