Try round brackets instead of braces as the compiler suggests.
Try round brackets instead of braces as the compiler suggests.
and gettingQt Code:
#include <iostream> using namespace std; int main() { char * am="int 5"; (__asm__ int 5); // generate intertupt 5 return 0; }To copy to clipboard, switch view to plain text mode
g++ a.c
a.c: In function ‘int main()’:
a.c:6: error: expected primary-expression before ‘asm’
a.c:6: error: expected `)' before ‘asm’
Anurag Shukla
A man who never makes mistake is the man who never does anything! Theodre Rosvelt!
I meant:
or
getting the following error respectively
g++ a.c__asm__ ( int 5 );
a.c: In function ‘int main()’:
a.c:7: error: expected string-literal before ‘int’
g++ a.c__asm__ { int 5 };
a.c: In function ‘int main()’:
a.c:7: error: expected `(' before ‘{’ token
a.c:7: error: expected unqualified-id before numeric constant
Anurag Shukla
A man who never makes mistake is the man who never does anything! Theodre Rosvelt!
How about this:
This is an assembler error, your assembly code is invalid.
Probably, you are saying right!
This is one of my program which is runned successfully;
Thanks for your help & quick response.Qt Code:
#include <iostream> using namespace std; int a, b; void f1(void) { a = 5; b = 30; asm ( /*"movl $12, %ebx;" "movl %ebx, a;" "movl %ebx, b;"*/ "movl %eax, a;" ); // cout<<""; std::cout<<a<<std::endl; std::cout<<b<<std::endl; } int main(){f1();}To copy to clipboard, switch view to plain text mode
But How a way I generate a interrupt no. 5 for print screen which doesn't take any input.
Anurag Shukla
A man who never makes mistake is the man who never does anything! Theodre Rosvelt!
Are you sure the interrupt is handled by Fedora? I never heard of a "print screen" interrupt in Linux. And it is surely doubtful the kernel will let you run one in user mode. Linux uses syscalls and not direct interrupts.
Anurag Shukla
A man who never makes mistake is the man who never does anything! Theodre Rosvelt!
Provided that a particular OS has this interrupt and allows calling them in user mode.
So "any" or "DOS and windows"? DOS and Windows do use interrupts...But I have not gotted the code for that. But I am sure it is working on DOS and windows.
man syscall![]()
Here's an example from qatomic_i386.h:
Searching Google for example "g++ inline asm" would have surely been also productive.Qt Code:
inline int q_atomic_fetch_and_add_int(volatile int *ptr, int value) { asm volatile("lock\n" "xaddl %0,%1" : "=r" (value), "+m" (*ptr) : "0" (value) : "memory"); return value; }To copy to clipboard, switch view to plain text mode
J-P Nurmi
Bookmarks