linux平台学x86汇编(十一):字符串的传送
# 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)
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。