learn,how to mix C and Assembly Language ?, Basic Computer Science

Assignment Help:
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.

Related Discussions:- learn,how to mix C and Assembly Language ?

Write a note on modems, Question 1 Write a note on modems Question ...

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

Random access memory (ram), RANDOM ACCESS MEMORY (RAM): The RAM-type me...

RANDOM ACCESS MEMORY (RAM): The RAM-type memory will allow data to be written into it, as well as read from it. With very few exceptions, RAMS lose their contents when the powe

M s word., explain the steps to form a colourful card

explain the steps to form a colourful card

Types of policy, want to get detail understanding of the types of security ...

want to get detail understanding of the types of security policies including enterprise security policy, issues specific policies etc

Microprocessor, what is computer mapped input / output

what is computer mapped input / output

Data processing, Data Processing In any computer-based system, d...

Data Processing In any computer-based system, data storage and retrieval plays an important role. Data storage involves decision about the encoding of data, assignment o

Base, 123 is not valid in which base value

123 is not valid in which base value

DATA STRUCTURE, WHAT IS DATA STRUCTURE AND EXPLAIN ME.

WHAT IS DATA STRUCTURE AND EXPLAIN ME.

Explain fdma and tdma concepts, Question 1 Explain Wireless Protocol Requi...

Question 1 Explain Wireless Protocol Requirements and also explain in brief medium access control protocol Question 2 Explain FDMA and TDMA concepts Question 3 Exp

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd