News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Loops

Started by tootoo, October 10, 2006, 01:08:08 PM

Previous topic - Next topic

tootoo

Can anyone  help me with the code to write a loop backwards, I have the loop printing hexidecimals, but I need the loop to also print the srting backwards.

Thanks for any assistance.

This is the code to print the loop, I need a way to make it backwards too.

.data
source  BYTE  "This is the source string",0
target  BYTE  SIZEOF source DUP('#')

.code
main PROC

   mov  esi,0      ; index register
   mov  ecx, SIZEOF source   ; loop counter
      
L1:
   
   mov  al,source[esi]      ; get a character from source
   mov  target[esi],al      ; store it in the target   
   inc  esi
   loop L1         ; repeat for entire string
   
   mov esi,OFFSET target                   ; offset of variable
   mov ebx,1         ; byte format
   mov ecx,SIZEOF target   ; counter
   call DumpMem

   exit
main ENDP
END main

Shantanu Gadgil

Although everyone here loves to hear their own voice  :green2 :green2 please do not make us say the same thing again and again. This looks like homework and so you are requested to read the rules of the forum.

They (the rules) are for OUR (you and us) own good.

We help you with your homework now, you don't learn it on your own and _we_ would be responsible for eventually creating an average assembly programmer as opposed to an excellent one.  :bg :bg

So, I would suggest you try this one on your own.

Here's what you can do...come up with an algorithm, a proper algorithm-algorithm (not some C/C++ code which needs to be translated) and we can see it from there on!

Say what?

Regards,
Shantanu
To ret is human, to jmp divine!