How
How

Reputation: 1

How do you convert a string to an integer in MASM32 Assembly language?

I am having trouble showing if the number is odd or even. Is there a better way to get user input? It looks like I am getting a string from the user input.

.data
     num1 dw 70 dup(?)
     prompt db "Enter the number: ",0
     result db "This is your value: ",0
     evenmsg db "This is an even number",0
     oddmsg db "This is an odd number",0

.code
    start:
       push offset prompt
       call StdOut

       push 70
       push offset num1
       call StdIn


       mov ax, num1
       and ax, 1
       jz even_num
       jnz odd_num

    even_num:
       push offset evenmsg
       call StdOut
       jmp exitx
   odd_num:
       push offset oddmsg
       call StdOut
       jmp exitx
exitx:
    

end start

Upvotes: 0

Views: 228

Answers (0)

Related Questions