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
Your next step is to analyze "proposed" technical requirements/specs based on the business requirements (new performance needs) for Big Bucks. 1.Create a "CRUD" Matrix in an Exce

Operating system services: In this section we consider basic services supported by an operating system. There are many building blocks to be considered, not all of which will

Consider a class called Configuration. This class “encapsulates” the configuration management for any software system. For example, once created, the user can simply ask the config

Running more than a few threads is like running several different programs at the same time as, but with the following profits: • Multiple threads inside a process share the same d

QUESTION 1 Write short notes on controlled vocabulary indexing. QUESTION 2 (a) List five types of abstracts. (b) Describe four types of abstracts. QUESTION 3

What constitutes ERP? ERP typically comprises a client server architecture, fourth generation language, RDBMS and graphical user interface in an open systems environment. It

TELECOMMUNICATION PROTOCOLS: The two major components relating to a WAN are the Protocol and the Media. The media are the actual path ways that the protocol travels on. The ne

• It is also known as Shortest-Process-Next (SPN). • Shortest-Job-First (SJF) is a non-preemptive order in which waiting job (or process) with the smallest predictable run-time-to-

Ask question #Minimum. Hello. ser can. you. tell. me. that. what. is. the. batter. side. for. BIOLOGY. Students. from. class. 12. / xii. 100 words accepted#

What are two types of evidence geologists use to learn about Earth''s interior.?