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 ?

Software development, requirement analysis and specification for online vot...

requirement analysis and specification for online voting

Environment for intelligent agents-artificial intelligence, Environments ...

Environments We have seen that intelligent agents might take into account certain information when   choosing   a   rational   action, by  including information from its sensor

HOMEWORK 9.., AsBased on Chapter Review Problems from the book. 1 #1. Wh...

AsBased on Chapter Review Problems from the book. 1 #1. What is meant by data independence? Explain your answer. #2. Identify two benefits of separating application software fr

Development of personnel computer operating system, Development of Personne...

Development of Personnel Computer Operating System: The next important breakthrough in computer use occurred in 1982, with the introduction of the IBM personal computer. The I

Graphical user interface and arrays, In this program, you are going to writ...

In this program, you are going to write a program for playing the game of Hangman. In this game, the computer will pick a word and display a sequence of blanks to be filled in; one

Explain different types of attacks, Question 1 Explain synchronous and asy...

Question 1 Explain synchronous and asynchronous Data Replication Question 2 Write a short note on Access Time, Latency, Transfer Time, and Streaming Tape Question 3

Integers, what is the size of a void integer and what is it''s range

what is the size of a void integer and what is it''s range

Command processor and user interface, Command Processor and User Interface:...

Command Processor and User Interface: To the user, the most important and visible services provided by the OS is the user interface and the capabilities that it provides to ex

C++, You are to code a C++ program that will read the file IntList into an ...

You are to code a C++ program that will read the file IntList into an integer array. There are no more than 20 integers in the file. After all of the data is read into the file,

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