x86 - print string in assembly -


section .text org 100h push selected call output mov ah,4ch int 21h  output: push ebp mov ebp, esp sub esp, 4 push ebx mov ah,0x9 mov dx,[ebp+8] int 21h pop ebx mov esp, ebp pop ebp ret section .data selected db "i selected random number between 0 , 99",0xd,0xa,'$' 

i must pass parameters stack.

the expected output is:

"i selected random number between 0 , 99"  

, real output is:

" ═  Я ЪЁ■↔Ё▐☺▲♦k☺▲♦v☺▲♦▲♦☺☺☺ ☻               #♣╓ p♣¶ ↑ p♣        ♣                                                  h(☺ш♦ ┤l═!fufЙхfГь♦fs┤      gЛu ═!f[fЙьf]├   selected random number between 0 , 99" 

why happening?

the problem here:

mov dx,[ebp+8] 

it ok, pushed ebx few lines above, [ebp+8] isn't first parameter anymore, returning address (which follows parameter). output seeing "ascii translation" of program. ;)
try [ebp+0ch].


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -