.section .data
value1:
.ascii "This is a test string.\n"
.section .bss
.lcomm output, 23
.section .text
.global _start
_start:
nop
leal value1, %esi
leal output, %edi
movl $23, %ecx
cld
rep movsb
movl $1, %eax
movl $0, %ebx
int $0x80
$ gdb -q rep
Reading symbols from /home/beyes/Programming/Assembly/rep...done.
15 movl $23, %ecx
(gdb) s
16 cld
(gdb) s
17 rep movsb
(gdb) s
19 movl $1, %eax
(gdb) x/s &output
0x80490b0 <output>: "This is a test string.\n"
.section .data
value1:
.ascii "This is a test string.\n"
value2:
.ascii "Oops"
.section .bss
.lcomm output, 23
.section .text
.global _start
_start:
nop
leal value1, %esi
leal output, %edi
movl $6, %ecx
cld
rep movsl
movl $1, %eax
movl $0, %ebx
int $0x80
Breakpoint 1 at 0x8048089: file rep2.s, line 22.
(gdb) r
Starting program: /home/beyes/Programming/Assembly/rep2
Breakpoint 1, _start () at rep2.s:22
22 movl $1, %eax
(gdb) x/s &output
0x80490b8 <output>: "This is a test string.\nO"
.section .data
string1:
.asciz "This is a test of the conversion program!\n"
length:
.int 43
.section .bss
.lcomm buffer, 43
.section .text
.global _start
_start:
nop
leal string1, %esi
leal buffer, %edi
movl length, %ecx
shrl $2, %ecx # 43/4=10
cld
rep movsl
movl length, %ecx
andl $3, %ecx #求余下的字节,此处应为3
rep movsb
movl $1, %eax
movl $0, %ebx
int $0x80
(gdb) x/s &buffer
0x80490d8 <buffer>: "This is a test of the conversion program"
(gdb) n
26 movl $1, %eax
(gdb) x/s &buffer
0x80490d8 <buffer>: "This is a test of the conversion program!\n"
指令 | 描述 |
REPE | 等于时重复 |
REPNE | 不等于时重复 |
REPNZ | 不为零时重复 |
REPZ | 为零时重复 |
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |