I have the following function:

void syscall3(int num, int arg1, int arg2, int arg3) { asm("int\t$0x80\n\t" : /* Сюда надо впихнуть возврат значения */ : "a"(num), "b"(arg1), "c"(arg2), "d"(arg3) ); } 

How to make a function return the result of a system call in a long int?

1 answer 1

As I understand, now you are not writing under ARM, but under x86? Here is:

 int syscall3(int num, int arg1, int arg2, int arg3) { int ret; __asm__ __volatile__( "int $0x80;" : "=a"(ret) : "a"(num), "b"(arg1), "c"(arg2), "d"(arg3) ); return ret; } 

Returns an int , not a long int , since, apparently, your system is 32-bit.

  • And under the arm and under the x86 .;) hmm did absolutely and also received a segmentation error, I had a volatile development without a volatile__ - Vitaly Karpenko