# stos.s
.section .data
space:
.ascii " "
.section .bss
.lcomm buffer, 256
.section .text
.globl _start
_start:
nop
leal space, %esi
leal buffer, %edi
movl $256, %ecx
cld
lodsb
rep stosb
movl $1, %eax
movl $0, %ebx
int $0x80
Breakpoint 1, _start () at stos.s:11 11 nop (gdb) print/x $eax $1 = 0x0 (gdb) x/16b &buffer 0x80490a0 <buffer>: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80490a8 <buffer+8>: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 (gdb) s 12 leal space, %esi (gdb) s 13 leal buffer, %edi (gdb) s 14 movl $256, %ecx (gdb) s 16 cld (gdb) s 17 lodsb (gdb) s 18 rep stosb (gdb) print/x $eax $4 = 0x20 (gdb) s 20 movl $1, %eax (gdb) s 21 movl $0, %ebx (gdb) x/16b &buffer 0x80490a0 <buffer>: 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x80490a8 <buffer+8>: 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 (gdb)
原文:http://blog.csdn.net/shallnet/article/details/45602245