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 ?

What is a view, Question (a) What is a view? (b) Can we use a view t...

Question (a) What is a view? (b) Can we use a view to insert or update a record into a table? Do we have any limitation to perform the above command? (c) The syntax to cr

C++, whats the out put of int main(){ int n=310; funcone(n); functwo(&n); ...

whats the out put of int main(){ int n=310; funcone(n); functwo(&n); cout return 0; } void funcone(intn) n=240; } void func two(intn*) { n=120; }

File management, explain the objectives of file management?

explain the objectives of file management?

Input devices, Input Devices Keyboard Keyboard is the dev...

Input Devices Keyboard Keyboard is the device through which the commands, instructions required for execution of a program is entered. It consists of a number of

Text, text graphics audio video

text graphics audio video

Discuss about xpointer, Question 1 How PHP works? Explain the structure of...

Question 1 How PHP works? Explain the structure of PHP Question 2 Write a note on links and webs Question 3 Explain why do you need Document Type Definition (DTD)?

What is heuristic evaluation, Question 1: (a) How would you describe h...

Question 1: (a) How would you describe human reasoning? (b) Describe the different types of human reasoning? Question 2: (a) What are the computational factors affec

Describe counting instructions, They are used to reduce or enlarge the cont...

They are used to reduce or enlarge the content of the counters. DEC INC DEC INSTRUCTION Idea: To diminish the operator. Syntax: DEC destiny This action subtracts 1 from the destiny

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