Programming with FASM – copy memory.

By | 02/02/2019

The goal of this tutorial is to show how to copy memory using the destination source and registers.
The copy memory is a complex issue and depends by the rule of addressing.
In this case I used the registers: edi, esi, ecx.
My example use also a structure to understand another step into assembly programming with fasm the structure area.
This structure named MY_STRUC starts with this template:

I create a procedure named copy_memory to copy memory.
The source code has commented lines that let you to see how this working.
Some parts of this comments let you to create an executable to test with the debugger.
The base of this copy memory issue is the assembly instruction named movsb.
The movsb moves only a single byte from the source string to the destination.
To move the entire string, first initialize ecx to the number N of bytes in the source string and execute rep movsb.
As you know the ecx is an 32-bit register.
Let’s see the example:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.