MASM reverse string ( pop push )
- include Irvine32.inc
- .data
- aName byte "reversing a string : ", 0dh, 0ah, 0
- nameSize = ($ - aName) - 1 ; length of aName
- .code
- main proc
- mov ecx, nameSize
- mov esi, 0
- L1:
- movzx eax, aName[esi] ; put the index into eax
- push eax ; push into stack
- inc esi ; next element
- loop L1
- mov esi, 0
- mov ecx, nameSize
- L2:
- pop eax ; pop out of stack
- mov aName[esi], al
- inc esi
- loop L2
- mov edx, offset aName
- call writestring
- main endp
- end main
before and after
留言
張貼留言