Skip to content

Instantly share code, notes, and snippets.

@inaz2
Last active December 26, 2015 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inaz2/7112896 to your computer and use it in GitHub Desktop.
Save inaz2/7112896 to your computer and use it in GitHub Desktop.
x86アセンブリでyesコマンドの実装
$ uname -a
Linux vm-ubuntu32 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:42:40 UTC 2014 i686 i686 i386 GNU/Linux
$ gcc -nostdlib -o yes yes.s
$ ./yes
y
y
y^C
$ ls -l yes
-rwxr-xr-x 1 user user 629 Mar 17 22:22 yes*
$ objdump -d yes
yes: file format elf32-i386
Disassembly of section .text:
08048098 <_start>:
8048098: 66 68 79 0a pushw 0xa79
804809c: 89 e1 mov ecx,esp
804809e: 31 db xor ebx,ebx
80480a0: 8d 53 02 lea edx,[ebx+0x2]
080480a3 <loop>:
80480a3: 8d 43 04 lea eax,[ebx+0x4]
80480a6: cd 80 int 0x80
80480a8: eb f9 jmp 80480a3 <loop>
.intel_syntax noprefix
.globl _start
_start:
pushw 0x0a79
mov ecx, esp
xor ebx, ebx
lea edx, [ebx+2]
loop:
lea eax, [ebx+4]
int 0x80
jmp loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment