Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There will be a function called getdouble . This function will simply double any number which is currently in eax and store the result in

There will be a function called getdouble. This function will simply double any number which is currently in eax and store the result in eax.

There will be a function called gettriple. This function will simply triple any number which is currently in eax and store the result in eax.

There will be a function called getoddeven. This function will check if the value in eax is even. IF it is even, it will call the getdouble function. IF it is odd, it will get the gettriple function. (Note: edx stores remainder after you divide)

Your main program should ask the first user for a name as well as for a number. You should then call the getoddeven function. That function will either double or triple the initial value entered by the user. Display the name and the final result for this first user.

Your program will then do the same for a second user for a name as well as for a number. You will again call the getoddeven function which will either double or triple the value. Display the name and final result for this second user.

Finally, you will compare the two final results of each user and display the name of the one with the bigger final number as well as the number they have.

TITLE MASM Template INCLUDE Irvine32.inc

.data msg1 db "Enter your name: ", 0 msg2 db "Enter a number: ", 0 msg3 db "Final result for ", 0 msg4 db " is: ", 0

.code main proc ; Ask for the first user's name and number mov edx, offset msg1 call WriteString call ReadString ; Convert the string to a number call atoi ; Call the getoddeven function call getoddeven ; Display the final result for the first user mov edx, offset msg3 call WriteString call WriteString call WriteInt mov edx, offset msg4 call WriteString call WriteInt

; Repeat the same process for the second user

; Compare the final results and display the name of the winner

; Exit the program call Crlf exit main endp

getdouble proc ; Double the value in EAX shl eax, 1 ret getdouble endp

gettriple proc ; Triple the value in EAX mov ecx, 3 imul ecx, eax mov eax, ecx ret gettriple endp

getoddeven proc ; Check if the value in EAX is even or odd mov edx, 0 mov ecx, eax mov ebx, 2 div ebx ; If it's even, call getdouble; otherwise, call gettriple cmp edx, 0 je call_getdouble call gettriple ret call_getdouble: call getdouble ret getoddeven endp

having little trouble getting my code to work

language is MASM Irvine32.inc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

Were the right people involved in the decision-making process?

Answered: 1 week ago

Question

Were they made on a timely basis?

Answered: 1 week ago