Transferring memory/bytes in assembly language

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
Twoacross
Messages
8
Reaction score
0
Hi Everyone,

Trying to write some assembly code by just first working out some pseudo to get a basis down for a program which transfers N bytes from m amount different sources, whose sizes are N bytes to m amount different destinations.

So far, I've been trying to simplify what it wants and so far I've come up with:

Move R2, #TEMP // Load TEMP into R2 (R2 being a general register)
Move R3, N // What this line and the subtract line does is that it initializes the outer loop index R3 to j = n-1
Subtract R3, #1

Outer: Move R4,R3
Subtract R4,#1
MoveByte R5, (R2, R3)

From here I'm kinda lost at how to implement a way to do it for different sources going to different registers. If anyone could provide a means how I can achieve this or propose a different method which would be easier, it would be greatly appreciated!

Thank you
 
Physics news on Phys.org
It's not clear to me what the actual moves are. Are you stating that there are m different source arrays, m different destination arrays, and that all arrays are N bytes long?

What processor are you using? For X86 (Intel / AMD) processors, there is a move string instruction (MOVSB / MOVSW / MOVSD / MOVSQ) (8 / 16 / 32 / 64 bits), that uses ds:si / ds:esi / rsi as source ptr, es:di / es:edi / rdi as destination pointer, and cx / ecx / rcx as repeat count.