Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [nasmfunc64.asm]
- global print_message_asm
- section .text
- ;
- ; x64 args passed in RDI, RSI
- ;
- print_message_asm:
- mov rdx, rsi
- mov rsi, rdi
- mov rax, 1
- mov rdi, 1
- syscall
- ret
- [prog.cpp]
- extern "C" void print_message_asm(const char *message, unsigned int length);
- int main()
- {
- print_message_asm("hello, ASM + C++ world!\n", 24);
- print_message_asm("abracadabra\n", 12);
- return 0;
- }
- [build x64]
- $ nasm -f elf64 nasmfunc64.asm -o nasmfunc64.o
- $ g++ prog.cpp nasmfunc64.o -o prog
- $ ./prog
Add Comment
Please, Sign In to add comment