DarkoreXOR

Untitled

Jul 25th, 2020 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. [nasmfunc64.asm]
  2.  
  3. global print_message_asm
  4.  
  5. section .text
  6.  
  7. ;
  8. ; x64 args passed in RDI, RSI
  9. ;
  10. print_message_asm:
  11. mov rdx, rsi
  12. mov rsi, rdi
  13. mov rax, 1
  14. mov rdi, 1
  15. syscall
  16. ret
  17.  
  18.  
  19.  
  20. [prog.cpp]
  21.  
  22. extern "C" void print_message_asm(const char *message, unsigned int length);
  23.  
  24. int main()
  25. {
  26. print_message_asm("hello, ASM + C++ world!\n", 24);
  27. print_message_asm("abracadabra\n", 12);
  28.  
  29. return 0;
  30. }
  31.  
  32. [build x64]
  33. $ nasm -f elf64 nasmfunc64.asm -o nasmfunc64.o
  34. $ g++ prog.cpp nasmfunc64.o -o prog
  35. $ ./prog
  36.  
  37.  
Add Comment
Please, Sign In to add comment