Wednesday, 15 July 2015

stack - Copying string in reverse order using push and pop in Assembly,can't see output by calling writeString -



stack - Copying string in reverse order using push and pop in Assembly,can't see output by calling writeString -

only problem can't see output calling writestring create sure string copied destination or not

include irvine32.inc .data string byte "kashif",0 dest byte 0 .code main proc mov ecx,lengthof string mov esi,offset string k: mov al,[esi] force ax inc esi loop k mov ecx,lengthof string mov edi,offset dest a: pop ax mov [edi],al phone call writechar inc edi loop

by calling writechar can see output in reverse order i.e fihsak means push,pop working fine

mov edx,offset dest phone call writestring

but here can't see output calling writestring

exit main endp end main

reversing string not create longer or shorter. need initialize destination same way setup source.

string byte "kashif",0 dest byte "xxxxxx",0

here lengthof operator returns 7 because include terminating zero. terminating 0 not byte want include in reversing operation , must decrement count.

mov ecx,lengthof string dec ecx

assembly stack masm irvine32

No comments:

Post a Comment