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
Python Strings: Strings in Python are recognized as an adjacent set of characters in among quotation marks. Python permits for either pairs of single or double quotes. Subsets of s

Question 1 How can you create surface with 3D Scanner in geometric modeling? Question 2 Explain kinematics modeling in virtual reality Question 3 Describe object hierarc

Example of autonomous rational agents-Artificial intelligence The procedure of waste water treatment After the level of pollutants in waste water is find out,  following 5

• A set of process is in a deadlock state if each process in the group is waiting for an event that can be caused by only another process in the set. In other words, each member of

Given an operating system that supports a one – to –one relationship between user-level threads and kernel – level threads and allows one or more threads from a process to issue b

create a flowchart showing average score for the 3 quizzes assume that there are 3 sections each having 5 students the only valid number to be entered is 1-100 for the quizzes shou

NETWORKING AND TELECOMMUNICATIONS: Computers can now communicate with each other and with a range of peripheral devices, over distances with increasing speed and reliability.

Computer Help Inc. is a computer timesharing, and software development and sales company. It has been successful in attracting clients for both sides of its business. Staff count

Another way of classifying a computer system is based upon its size and capabilities: Microcomputers: Microcomputers are systems based on the use of microprocessors. A Micr

Assignment of computer science