mardi 24 février 2015

How I know how many times my second loops so I can set an ECX count? help me fix this code (reverse string)

So for this code I need to reverse a string in assembly language, but I need to set an ECX count for my second loop L2, but I don't know how many times I need to se it, so can someone help fix my code?



INCLUDE Irvine32.inc

.data
source BYTE "CIS 335/535 is a great course" ,0
revstr BYTE SIZEOF source DUP(0)
revwrd BYTE SIZEOF source DUP(0)
ecxbkkp DWORD ?
strSize = ($ - source) - 1

.code
main PROC
mov ecx, SIZEOF source
L1:

movzx eax, source[esi] ; get character
push eax ; push on stack
inc esi

Loop L1
mov ecx,strSize ; Pop the name from the stack, in reverse,
mov esi,0 ; and store in the StringReversed array.
L2:

pop eax ; get character
mov revstr[esi],al ; store in string
inc esi
Loop L2
mov edx, OFFSET revstr ; "Entered: "
call WriteString

mov edx, OFFSET source ; User Input
call WriteString
call CrLf

mov edx, OFFSET revwrd ; "Reversed: "
call WriteString
mov edx,OFFSET revstr ; Display the reversed string.
call WriteString
call Crlf

exit
main ENDP
END main

Aucun commentaire:

Enregistrer un commentaire