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
The skill of Assembly Language Programming (AoA), Randy Hyde''s acclaimed text on assembly language programming, is the most-frequently recommended book on 80x86 assembly language

#queA register is a memory location surrounded by the CPU itself, designed to be rapidly accessed for purposes of fast data retrieval. Processors normally hold a register array, wh

WHAT IS DATA STRUCTURE AND EXPLAIN ME.

Server In a network, the resources of computers comprising network are usually shareable. In fact, one of the main objectives of networking is to make the computing resources

concepts and components of computer security

Question: a) Illustrate, in detail, what is virtual memory? b) The Memory Management Unit is responsible for the translation of virtual addresses to their corresponding phy

EVOLUTION OF A COMPUTER: Although 'computer', as we understand it today, is relatively of recent innovation, its development rests on centuries' of research. This section pres

Question 1 Explain the concept of knowledge discovery in database Question 2 Discuss the following types of Multidimensional Data Models                    Stars, Snowflakes and

Internal interruptions are produced by convinced events which come during the execution of a program. These types of interruptions are handled on their totality by the hardware and

function of each status flags Z80 status flags