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 Assembler Programming?, To build assembler programs with TASM prog...

To build assembler programs with TASM programs is a different program structure than from using debug program. It''s important to comprise the subsequent assembler commands: ..CODE

Algorithm, to print first n even numbers

to print first n even numbers

Optical mark recognition, Optical Mark Recognition (OMR): OMR is the s...

Optical Mark Recognition (OMR): OMR is the scanning of paper to detect the presence or absence of a mark in a predetermined position. Now days, it is used as an input device f

Data structure, #question.a tree has 0 off springs at each node. if it had ...

#question.a tree has 0 off springs at each node. if it had a label L, what will be the maximum number of nodes that the tree can have. only an expression involving the number of no

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

C, What is a Structure?

What is a Structure?

Iterative deepening search-artificial intelligence, Iterative Deepening Sea...

Iterative Deepening Search- Artificial intelligence: So, breadth first search is guaranteed to find a solution (if one exists), but it grape whole memory. However, Depth first

Extension.., short note about extension..

short note about extension..

Data output, DATA OUTPUT : Whatever, data or information that you feed int...

DATA OUTPUT : Whatever, data or information that you feed into a computer will be the data output from a computer system and will be a data file sent from the computer to a periph

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