Transferring memory/bytes in assembly language

In summary, the conversation discusses the process of writing assembly code to transfer N bytes from multiple sources to multiple destinations. The individual is trying to simplify the process and asks for suggestions on how to implement it. They mention using the MOVSB / MOVSW / MOVSD / MOVSQ instructions for X86 processors.
  • #1
Twoacross
9
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
  • #2
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.
 

1. How do you transfer a single byte of memory in assembly language?

In assembly language, a single byte of memory can be transferred using the MOV (move) instruction. This instruction takes two operands - the source and the destination - and copies the value of the source operand into the destination operand. For example, MOV AL, BL will transfer the value of the BL register into the AL register.

2. Can you transfer multiple bytes of memory in assembly language?

Yes, it is possible to transfer multiple bytes of memory in assembly language. This can be done using a combination of instructions such as MOV, LEA (load effective address), and LOOP (loop). These instructions allow for the transfer of blocks of memory by specifying the starting address and the number of bytes to be transferred.

3. How do you transfer data between different memory segments in assembly language?

To transfer data between different memory segments in assembly language, the MOV instruction can be used along with the DS (data segment) and ES (extra segment) registers. These registers store the starting addresses of the data segments and can be used to specify the source and destination segments in the MOV instruction. For example, MOV AX, DS:[BX] will transfer the value stored at the memory location specified by the BX register in the data segment pointed to by the DS register into the AX register.

4. Can memory be transferred between different types of data in assembly language?

Yes, memory can be transferred between different types of data in assembly language. This can be done using type conversion instructions such as CBW (convert byte to word), CWD (convert word to doubleword), and CBTD (convert byte to doubleword). These instructions allow for the conversion of data from one type to another before transferring it to a different memory location.

5. Are there any limitations or considerations when transferring memory in assembly language?

Yes, there are some limitations and considerations to keep in mind when transferring memory in assembly language. These include the size of the memory being transferred, the availability of registers and instructions, and the potential for data loss or overflow. It is important to carefully plan and test memory transfers to ensure they are executed correctly and efficiently.

Similar threads

  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
16
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Programming and Computer Science
Replies
5
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Programming and Computer Science
2
Replies
60
Views
16K
  • Programming and Computer Science
Replies
2
Views
3K
Back
Top