understanding copying a string using movsb?

[b]Edit, nevermind I figured out that movsb automatically adjusts ESI and EDI[/b]

Hi all,
I just started coding assembly so please excuse my ignorance.

Below is some sample code to copy "hello world" from one variable to another.

I have built and linked this code with no issues and checked that it is working in gdb and it works fine.

My question is, if movsb moves 1 byte at a time and it copies and does not remove the characters from the original HelloWorld buffer, how does this code know it should point to the next byte in the string, when it repeats the movsb?

Look forward to hearing your responses.


.section .data
.ascii "Hello World"
.section .bss
.lcomm Destination, 50
.section .text
.globl _start
movl $HelloWorld,%esi
movl $Destination, %edi
movl $11, %ecx
rep movsb
movl $1, %eax
movl $0, %ebx
int $0x80

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!