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 ?

Explain the characteristics of vector processing, Question 1 Draw the bloc...

Question 1 Draw the block diagram of von Neumann Architecture and explain about its parts in brief Question 2 Draw the block diagram of Intel 8085 CPU organization and explai

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.

Assembly, Design and develop a program to calculate the sum of an integer n...

Design and develop a program to calculate the sum of an integer number using MIPS assembly language.

Data structures, let me know if you can do this assignment and how long it ...

let me know if you can do this assignment and how long it takes

Unix, How do I change file permissions? Every time I execute chmod commands...

How do I change file permissions? Every time I execute chmod commands it tells me permission denied.

Assignment - concept of programming language , Assignment :  It is compose...

Assignment :  It is composed of variable name, an assignment operator of the language and a value or variable or some expression as per composition allowed based on rules defined

Explain the terms sampling and aliasing, QUESTION (a) Consider a syste...

QUESTION (a) Consider a system with input x[n] and output y[n] that satisfy the difference equation:                                   Y[n] = x[n] + 0.5 x[n-2] + 0.2 x[n+1]

What is a stateless and and a stateful server, StatefulServer, maintains so...

StatefulServer, maintains some information between requests. Requires smaller messages, since some information is kept between contacts, example: FTP, telnet. Stateless Server req

C, programm for fibonacci series

programm for fibonacci series

Web browser, Web Browser:   A Web browser is software application that ...

Web Browser:   A Web browser is software application that enables you to find, retrieve, and display information available on the World Wide Web (WWW). Browser also allows you

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