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
Define opportunity cost The opportunity cost of any commodity is defined as the cost of next best alternative, which has been sacrificed for producing the given commodity. Th

Assess the reliability of data gathered via paid Internet users. Describe and assess the evaluation method being used by the testing company, i.e., nonvisual and verbal recording o

Why is the ATM selected as a transport network in 3G? Answer: ATM provides efficient support for transmission of voice, data, and video ATM provides QoS guarantee and reliability

CONCEPT IN PROGRAMMING LANGUAGE: A Programming Language is used to design and describe a set of instructions and computations to be executed by a computer. To do programming,

You have been approached by Company XYZ to design and deploy a new network that will span three cities in Queensland: Brisbane (12 users), Gold Coast (8 users), and Cairns (6 users

Constant: In contrast to a variable, which is used as identifier for a value and which can change, constants are identifiers that are used for values, which cannot be changed.

Evolution of ERP  The origin of using computers for business, traces the following line of story. Originally, they were designed to support the repetitive and time consuming fu

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

Question 1 Explain the following terms associated with Pattern Recognition Features Collection Question 2 Explain the working of character recognition with a suit

Algorithm : Once a problem has been defined precisely, a procedure or process must be designed to produce the required output from the given input. Since a computer is a machine t