From 63ba3e6da3c3b66bd42bfba51a0d789a3b9e2a69 Mon Sep 17 00:00:00 2001 From: winsdominoes Date: Wed, 12 Jun 2024 13:38:38 +0700 Subject: [PATCH] in out --- x86-64/in-out/in-out | Bin 0 -> 233 bytes x86-64/in-out/in-out.asm | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 x86-64/in-out/in-out diff --git a/x86-64/in-out/in-out b/x86-64/in-out/in-out new file mode 100755 index 0000000000000000000000000000000000000000..ae1067553bc7dae4044190e3d88afce9a655fc5b GIT binary patch literal 233 zcmX|3I}U@s$M>Q&erjOn83;NXqCl1Cs8_AH!2X`ztN_ieB3*u8UL&%+9$Za}r_ zRN4o^48G;k4LuQpO;yZI8NyTz*&E6?KToKEp^7q2BW;gjqWBTNQY3yP9|LicgT!3H JY-y%ND?iG68y5fo literal 0 HcmV?d00001 diff --git a/x86-64/in-out/in-out.asm b/x86-64/in-out/in-out.asm index d50875e..2ecf350 100644 --- a/x86-64/in-out/in-out.asm +++ b/x86-64/in-out/in-out.asm @@ -4,8 +4,22 @@ segment readable executable entry $ ; read from stdin - xor rax, rax + xor rax, rax ; is rax and rax equal to itself? yes? rax is set to 0 (for sys_read) + xor rdi, rdi ; same thing but rdi (for stdin) + mov rsi, buf ; direct addressing - move address of buf to rsi (buffer address) + mov rdx, 80 ; buffer size + syscall + ; write to stdout + mov rax, 1 ; sys_write + mov rdi, 1 ; stdout + mov rdx, 80 + syscall + + ; exit program + xor rdi, rdi ; exit code 0 + mov rax, 60 ; sys_exit + syscall segment readable writable buf rb 80