Transferring memory/bytes in assembly language

Click For Summary
SUMMARY

This discussion focuses on transferring N bytes from multiple sources to multiple destinations using assembly language. The user is attempting to implement this using pseudo-code and general registers, specifically using instructions like Move and Subtract. A key suggestion is to utilize the X86 MOVSB/MOVSW/MOVSD/MOVSQ instructions, which facilitate byte transfers between source and destination pointers. The conversation emphasizes the importance of understanding the processor architecture, particularly for Intel/AMD processors, to effectively implement memory transfers.

PREREQUISITES
  • Understanding of assembly language syntax and instructions
  • Familiarity with X86 architecture and its registers
  • Knowledge of memory addressing and data transfer techniques
  • Basic concepts of loops and control flow in programming
NEXT STEPS
  • Research X86 assembly language MOVSB/MOVSW/MOVSD/MOVSQ instructions
  • Learn about memory addressing modes in X86 assembly
  • Explore how to implement loops in assembly language
  • Study examples of multi-source to multi-destination data transfers in assembly
USEFUL FOR

Assembly language programmers, systems programmers, and anyone interested in low-level memory management and data transfer techniques in X86 architecture.

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.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
5K
Replies
16
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
60
Views
18K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
Replies
10
Views
10K