# movs.s
.section .data
val:
.ascii "Hello, as world!\n"
.section .bss
.lcomm output, 17
.section .text
.globl _start
_start:
nop
leal val, %esi
leal output, %edi
movsb
movsw
movsl
movl $1, %eax
movl $0, %ebx
int $0x80
10 nop (gdb) s 11 leal val, %esi (gdb) 12 leal output, %edi (gdb) s 13 movsb (gdb) s 14 movsw (gdb) x/s &output 0x80490a8 <output>: "H" (gdb) s 15 movsl (gdb) x/s &output 0x80490a8 <output>: "Hel" (gdb) s 17 movl $1, %eax (gdb) x/s &output 0x80490a8 <output>: "Hello, " (gdb)
# movs.s
.section .data
val:
.ascii "Hello, as world!\n"
.section .bss
.lcomm output, 17
.section .text
.globl _start
_start:
nop
leal val, %esi
leal output, %edi
movl $17, %ecx
loop_strcpy:
movsb
loop loop_strcpy
movl $1, %eax
movl $0, %ebx
int $0x80
# rep.s
.section .data
val:
.ascii "Hello, as world!\n"
.section .bss
.lcomm output, 17
.section .text
.globl _start
_start:
nop
leal val, %esi
leal output, %edi
movl $17, %ecx
cld
rep movsb
movl $1, %eax
movl $0, %ebx
int $0x80
13 movl $17, %ecx (gdb) 15 cld (gdb) 16 rep movsb (gdb) 18 movl $1, %eax (gdb) x/s &output 0x80490b0 <output>: "Hello, as world!\n" (gdb)
原文:http://blog.csdn.net/shallnet/article/details/45602199