Here is what I wrote, Its for linux systems
#A simple asm program for that copies a string onto another.
.data
EvilZone:
.asciz "I love EvilZone.org!\n"
Before_Copying:
.asciz "Before copying: "
After_Copying:
.asciz "After Copying: "
New_Line:
.asciz "\n"
.bss
.lcomm copied_string, 21
.text
.globl _start
_start:
#Function to print copied_string and EvilZone on the Screen
movl $4, %eax
movl $1, %ebx
movl $Before_Copying, %ecx
movl $16, %edx
int $0x80
movl $4, %eax
movl $1, %ebx
movl $copied_string, %ecx
movl $21, %edx
int $0x80
movl $4, %eax
movl $1, %ebx
movl $New_Line, %ecx
movl $21, %edx
int $0x80
#Function to copy string EvilZone to copied_string
movl $EvilZone, %esi #Copy the address of string EvilZone into register esi
movl $copied_string, %edi #Copy the address of copy_string into register edi
movl $21, %ecx #Copy the length of string EvilZone into register ecx for using REP
cld
rep movsb
std
movl $4, %eax
movl $1, %ebx
movl $After_Copying, %ecx
movl $15, %edx
int $0x80
movl $4, %eax
movl $1, %ebx
movl $EvilZone, %ecx
movl $21, %edx
int $0x80
#Function to exit the program
movl $1, %eax
movl $0, %ebx
int $0x80
Output:
root@bt:~# /root/Desktop/asm/CopyString
Before copying:
After Copying: I love EvilZone.org!
root@bt:~#
Feel free to criticise the code.
I will work upon if you think the code is not upto the mark.