assembly - Jump not working -


i'm busy making small (with far fixed questions) quiz in assembly (at&t).

i designed small menu asks input either 1 2 or 3
problem cmpl doesn't it's job, , cant figure out why. quits, no matter input is.

below of code:

.text  menu: .asciz "please select option: 1 - start quiz! 2 - highscores 3 - quit\n" input: .asciz "%i"  .global main  main:     call menushow  menushow:     push $menu     call printf     addl $4,(%esp)      leal -4(%ebp), %eax      pushl %eax     pushl $input      call scanf            popl %eax     popl %eax       # number has been entered in eax      cmpl $1,%eax        #1 entered?      je qone         #show question 1      cmpl $2,%eax        #2 entered??     je showhighscores   #show current highscores      call quit       #something else? (3, 99 w/e) quit 

  • you not allocating space on stack result scanf. need either push dword value stack before push arguments scanf, or delete addl $4,(%esp) , use space occupied argument printf. address of space -12(%ebp) on windows system. instead of using ebp operating system, i'd suggest set in start of program know points to.

  • you pop off 2 values stack, scanf has 2 arguments, value you're after third value, need pop once more.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -