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 ?

Operating system, Does Process Manager in Operating System know the depende...

Does Process Manager in Operating System know the dependency order that Process A depends on Process B?

Communication networks and local area networks, Communication Networks: ...

Communication Networks: Communication networks are made up of transmission lines, concentrators, switching mechanisms and non-data processing components. Due to increased comp

Hrm , online project on hrm i.e index page

online project on hrm i.e index page

Problem occurs during pipelining , While pipelining can cruelly cut the tim...

While pipelining can cruelly cut the time taken to execute a program, there are troubles that cause it to not work as well as it possibly shall. The three stages of the instruction

Immediate addressing, These addressing modes are: With immediate addressing...

These addressing modes are: With immediate addressing, no lookup of data is essentially required. The data is located in the operands of the instruction itself, not in a different

Global positioning system, How does GPS work in the field of Sport or athle...

How does GPS work in the field of Sport or athletics?

Input and output devices, Input and Output Devices : The most common input...

Input and Output Devices : The most common input devices that you will see in your PC are the keyboard and the mouse. The keyboard of the computer looks like the keyboard o

Database, #after writing the script of rebuilting indexed on db server it g...

#after writing the script of rebuilting indexed on db server it gave output command executed succesfully does this mean i m done

Noemalization.., what is means with respect to software engineering?

what is means with respect to software engineering?

What are the uses of the internet, Question 1 What are many of the modern ...

Question 1 What are many of the modern browsers in use today? Describe all in detail Question 2 Write a long note on the uses of Domain Names Question 3 What are the use

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