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 ?

Assembly language, write and run the following programs using 8086 assembly...

write and run the following programs using 8086 assembly language that interchange the upper and lower four bits of AL register.

String problem, c program to convert S to palindromes with minimum number o...

c program to convert S to palindromes with minimum number of character replacements

Operation system, how to create 1000 random processes with time scales betw...

how to create 1000 random processes with time scales between 10 to 400 milliseconds

SCM, advantages of E-SCM?

advantages of E-SCM?

Function, function of arithmetic logic unit

function of arithmetic logic unit

Communications programs , Communications Programs : By communications prog...

Communications Programs : By communications programs, we mean those programs which allow a computer to communicate via a transmission cable to another electronic device. Here we d

Database, how does one create a database in mysql

how does one create a database in mysql

Control unit of the processor, Control Unit of the processor: The  Con...

Control Unit of the processor: The  Control Unit  of the processor is that unit which controls and coordinates the execution of instructions by the processor. It is responsibl

Flow decomposition technique to list the cycles, QUESTION (a) Consider ...

QUESTION (a) Consider the graph below, use the Flow Decomposition technique to list the cycles and paths produced.                                                (b) Pr

Qbasic, write a program of circle of any colour

write a program of circle of any colour

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