# A minimal Linux i386 "cat" program in assembly. 16 instructions. # This is 59 bytes of machine code, but 348 of executable, # after `strip cat` and `objcopy -R .note.gnu.build-id cat`. .equiv __NR_exit, 1 # linux/arch/x86/include/asm/unistd_32.h:9 .equiv __NR_read, 3 .equiv __NR_write, 4 .equiv stdin, 0 .equiv stdout, 1 .globl _start _start: mov $__NR_read, %eax mov $stdin, %ebx mov %esp, %ecx # use an on-stack buffer, probably overwriting something mov $1, %edx int $0x80 test %eax, %eax jz exit mov $__NR_write, %eax mov $stdout, %ebx mov %esp, %ecx mov $1, %edx int $0x80 jmp _start exit: mov $__NR_exit, %eax mov $0, %ebx int $0x80