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 ?

Inside earth, What are two types of evidence geologists use to learn about ...

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

How does a flash drive work?, Question 1 What is a desktop? Explain the...

Question 1 What is a desktop? Explain the Windows XP desktop? 2 How does a flash drive work? 3 Write the procedure for creating Macro 4 Explain the process of applyin

Discuss the advantages and disadvantages of printed indexes, QUESTION 1 ...

QUESTION 1 Discuss the advantages and disadvantages of printed indexes. QUESTION 2 (i) The Library of Congress Subject Headings List and the Sears Subject Headings List

Generations of computers, Ask question #Minimum assignment on generations o...

Ask question #Minimum assignment on generations of computers 100 words accepted#

What help with this Assembly language Subroutine, Write an ARM subroutine w...

Write an ARM subroutine which will extract a substring from a string. You will need to use the library routine malloc to allocate memory for the new string. The subroutine signatu

Operating system problems, 1. In discussing software algorithms for mutual ...

1. In discussing software algorithms for mutual exclusion, we noted that optimizing compilers and out-of-order execution by processors could invalidate most of these algorithms bec

Necessary nurses records, Necessary Nurses Records The software shoul...

Necessary Nurses Records The software should generate all registers/reports in detail summary for various permutations and combinations of options. A powerful SQL (Structure

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