Transferring memory/bytes in assembly language

AI Thread Summary
The discussion revolves around writing assembly code to transfer N bytes from multiple sources to multiple destinations. The user has initiated the process by establishing a pseudo-code structure, utilizing registers R2, R3, and R4 for managing the transfer. The current implementation initializes the outer loop and attempts to move bytes from a source to a destination. However, the user expresses confusion about handling multiple sources and destinations effectively. A participant clarifies the setup, confirming that there are m different source and destination arrays, each of size N bytes. They also suggest using specific move string instructions available in x86 architecture, such as MOVSB, MOVSW, MOVSD, and MOVSQ, which can facilitate the transfer process by utilizing designated registers for source and destination pointers along with a repeat count. This insight aims to simplify the user's approach to the assembly code.
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
 
Technology 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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top