Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
What is wrong with my code?
Hi everyone!!! I have a question how do you copy a string backwards?
I'm using the following code:
source BYTE "This is the source string",0
target Byte SIZEOF source DUP(0)
mov esi,0 ; index register
mov ecx,SIZEOF source ; loop counter
mov al, source[esi] ; get a character from source
mov target[esi],al ; store it in the target
inc esi ; move to next character
mov esi,OFFSET target
mov ecx,SIZEOF target-1
So then my output is:
Dump of offset 0040401A
54 68 69 73 20 69 73 20 74 68 65 20 73 6F 75 72
63 65 20 73 74 72 69 6E 67
Press any key to continue
Which is wrong it should be backwards starts at 67 and ends at 54
Thanks in advance, bye.....