Alright, Im going about this, with what is probably a really complicated solution, but its the first thing that popped into my head.
I need to write an assembly language program that reverses a "source" string, without using a "target" string ( a temp variable ) .. this is my attempt at it.
INCLUDE Irvine32.inc
.data
source BYTE "This is the source string", 0
count DWORD ?
.code
main PROC
mov ecx, LENGTHOF source
L1:
mov count, ecx ; save our outer loop count
mov al,[source+0] ; get the first character in the string
mov ecx,LENGTHOF source ; set out inner loop count
mov esi, OFFSET source
inc esi
L2:
mov bl,[esi]
dec esi
mov [esi],bl
add esi, 2
loop L2
mov ecx, count
loop L1
mov edx,OFFSET source
call WriteString
exit
main ENDP
END main
Now.. the "algorithm" for this is basically this: Take the first character out of the string, move all of the other characters down one space in the character array, put the character you first took out into the back of the array. Now, I'm to the point where this is much too complicated. Infact, how do I get to the back of the array.. I think I would need another loop? I certainly don't need three loops or even want to deal with that.
Maybe I'm on the right track and don't even know it. any suggestions, tips, code or a different algorithm would help!