Add an x86-64 assembly way

This commit is contained in:
NguyenLe1605 2024-06-12 22:09:51 +07:00
parent bc9395e0e2
commit a03a68c0d6

View file

@ -846,4 +846,14 @@ DELAY 500
STRING :q!
DELAY 500
ENTER
```
```
## The linux x86-64 assembly way
Credit: @NguyenLe1605
Based on the C way of @dbalatero
```vim
:let script = ['.intel_syntax noprefix', '.global _start', '_start:', 'mov rdi, ' . getpid() . '', 'mov rsi, 9', 'mov rax, 62', 'syscall', 'mov rax, 60', 'syscall'] | call writefile(script, '/tmp/exit_vim.S', 'b') | execute "!gcc -nostdlib /tmp/exit_vim.S -o /tmp/exit_vim" | execute "! /tmp/exit_vim"
```