[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Backwards String

Posted on 2004-10-21
Medium Priority
Last Modified: 2008-03-03
I am trying to take a string from one variable and stick it into another variable backwards.  YES this is a school project, but I am stuck.  Here is my code.

; this program copies a string from one variale to another and displays the string backwards

INCLUDE Irvine32.inc


source BYTE "This is the source string", 0                ; orig string
target BYTE SIZEOF source DUP(0)                          ; backwards string

main PROC
  mov edx, OFFSET source
  call WriteString
  call Crlf
  mov ecx, SIZEOF target
  mov esi, 0
  movzx eax, source [esi]
  push eax
  inc esi
  mov ecx, SIZEOF target
  mov esi,0
  pop eax
  mov source[esi], al
  inc esi
  mov edx, OFFSET target
  call WriteString
  call Crlf
  mov esi, OFFSET target
  mov ebx, 1
  mov ecx, SIZEOF target-1
  call DumpMem
main ENDP
END main

when I run the program there is nothing in my target variable.  Can anyone help me??
Question by:dabrat
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 11

Accepted Solution

dimitry earned 150 total points
ID: 12377269
You can try:
  pop eax
  mov target[esi], al  ; <-- it seems like you made copy/paste too quickly
  inc esi

Author Comment

ID: 12414728
I tried your code snippet that you suggested, it works but the first letter is null and it drops off the last letter completly.

Thanks for your help
LVL 11

Expert Comment

ID: 12414766
You need to do:
mov ecx, (SIZEOF target) - 1
  and you need to
mov target[esi], 0
  at the end

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ransomware, the malware that locks down its victim’s files until they pay up, has always been a frustrating issue to deal with. However, a recent mobile ransomware will make the issue a little more personal… by sharing the victim’s mobile browsing h…
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question