1 Replies - 160 Views - Last Post: 02 July 2019 - 07:43 AM Rate Topic: -----

#1 ove   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-July 19

How do I make system call in inline assembly?

Posted 02 July 2019 - 05:30 AM

How do I make a "Hello, World!" system call in C++/AT&T Inline assembly, (x86_64/Linux)?

This is my latest attempt:

int main(){
    
    char line[] = "Hellow, World!\n";
    
    __asm__ ("movq $1, %rax;"
             "movq $1, %rdi;"
             "movq $14, %rdx;"
             : "S" = (*test));

    return 0;
}



The error message I get:

Quote

In function ‘int main(int, char**)’:
88:17: error: expected ‘(’ before ‘=’ token
: "S" = (*test));
^
88:17: error: expected primary-expression before ‘=’ token
88:27: error: expected ‘)’ before ‘;’ token
: "S" = (*test));


Is This A Good Question/Topic? 0
  • +

Replies To: How do I make system call in inline assembly?

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6801
  • View blog
  • Posts: 31,396
  • Joined: 10-May 07

Re: How do I make system call in inline assembly?

Posted 02 July 2019 - 07:43 AM

** Moved to C/C++ **

** Added quote/code tags **

Your C code appears to be missing commas between the arguments sent to your function. That's probably your syntax error.

Here is a tutorial that I wrote years ago that called asm from C in Linux. It goes over linking & file types. Without knowing what the asm code looks like, or how you are compiling, this is the best suggestion that I can give.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1