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 ?

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

Types of search engine, Types of Search Engine:   Some of the basic ca...

Types of Search Engine:   Some of the basic categories of Search engines are :  a. Primary Search Engines: Such search engines use web crawlers or spiders to traverse the w

Idk, A rock weighs 33.6 N on Planet X and 49 N on Earth. What is g on Plane...

A rock weighs 33.6 N on Planet X and 49 N on Earth. What is g on Planet X

Loading instructions, They are particular register instructions. They are u...

They are particular register instructions. They are used to load bytes or sequences of bytes onto a register. LODS (LODSB) (LODSW) LAHF LDS LEA LES LODS (LODSB) (LODSW) INSTRUCTION

Php, Which of the following is NOT a type of SQL constraint?

Which of the following is NOT a type of SQL constraint?

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

List two i/o virtualization methods, Question 1 List two I/O virtualizatio...

Question 1 List two I/O virtualization methods. Based on different features compare these two methods Question 2 Discuss three areas considered by organizations to secure the

Abstraction is a popular way to organize concurrent programs, 1. The proces...

1. The process abstraction is a popular way to organize concurrent programs, but it is not the only choice. An alternative to the process abstraction is to design a single-threaded

IPC in linux, to do a assignment regarding IPC in linux

to do a assignment regarding IPC in linux

Data communications, Data communication as a need developed in the 1960s wi...

Data communication as a need developed in the 1960s with the interconnection of peripheral devices to mainframe computers. Within the immediate vicinity of the mainframe computer t

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