简体   繁体   中英

Assembly: copy contents of string into another register

I'm having trouble figuring out how to copy the contents of one string into another. Here's what I'm working with: Given an address of a string in a register rbx , I need to copy the contents of that address of a string into another register(argument 4) rdx .

Here's what I'm currently doing

mov rbx, qword[rsi+16] ; rbx = some string address
; performs checks on string
; etc..
; string passes tests so
mov rbx, qword[rbx]
mov qword[rdx], rbx

the problem is that qword will only allow me to store 8 characters into rdx, while the actual maximum is 80(just an arbitrary maximum I defined in the start of my program). I could of course change qword to dqword but this doesn't sovle my problem as it would go from 8 character to 16. If I pass the string Arguments into the function above I would be returned Argument , since the copy assignment only handles 8 characters.

I apologize in advance as this is probably a really simple solution, but I'm very new to assembly. How can I move the contents of one string to another?

Why don't you write a loop to transfer 80 bytes?

 mov rcx,10
again:
 mov rax, qword[rbx+rcx*8-8]
 mov qword[rdx+rcx*8-8], rax
 loop again

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM