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.

this does not run in visual studio with MSAM

here's the code

TITLE MASM template

INCLUDE Irvine32.inc

.data

msg1 BYTE "Please Enter your name: ",0dh,0ah, 0 msg2 BYTE "Please Enter a number: ",0dh,0ah, 0 msg3 BYTE "Your Number is: ",0dh,0ah, 0 msg4 BYTE "The final result for ",0dh,0ah, 0 msg5 BYTE " is: ",0dh,0ah, 0 name1 BYTE 30 DUP (?) num1 DWORD ? num2 DWORD ? remainder DWORD ? result1 DWORD ? result2 DWORD ? winnerName BYTE 30 DUP (?)

.code getDouble PROC ; Double the value in eax mov ebx, 2 mul ebx ret getDouble ENDP

getTriple PROC ; Triple the value in eax mov ebx, 3 mul ebx ret getTriple ENDP

getoddeven PROC ; Check if the value in eax is even mov edx, 0 mov ebx, 2 div ebx mov remainder, edx cmp remainder, 0 call getTriple je Even ; If it's odd, call jmp endProc Even: ; If it's even, call getDouble call getDouble

EndProc: ret getoddeven ENDP

main PROC ;Get first user's name mov edx, OFFSET msg1 call WriteString mov edx, OFFSET name1 mov ecx, SIZEOF name1 call ReadString

;Get first user's number mov edx, OFFSET msg2 call WriteString call ReadInt mov num1, eax

; Call getoddeven function with first number mov eax, num1 call getoddeven mov result1, eax

; Display result for first user mov edx, OFFSET msg4 call WriteString mov edx, OFFSET name1 call WriteString mov edx, OFFSET msg5 call WriteString mov eax, result1 call WriteInt call Crlf

; Get second user's name mov edx, OFFSET msg1 call WriteString mov edx, OFFSET name1 mov ecx, SIZEOF name1 call ReadString

; Get second user's number mov edx, OFFSET msg2 call WriteString call ReadInt mov num2, eax

; Call getoddeven function with second number mov eax, num2 call getoddeven mov result2, eax

; Display result for second user mov edx, OFFSET msg4 call WriteString mov edx, OFFSET name1 call WriteString mov edx, OFFSET msg5 call WriteString mov eax, result2 call WriteInt call Crlf

; Compare results and determine winner cmp result1, result2 jg FirstWinner mov edx, OFFSET name1 mov winnerName, edx mov eax, result2 jmp DisplayWinner FirstWinner: mov edx, OFFSET name1 mov winnerName, edx mov eax, result1 DisplayWinner: ; Display the name and result of the winnerexit main endp end main

here's a screenshot

image text in transcribed

and yes msam is set up

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

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

Students also viewed these Databases questions

Question

What are the determinants of cash cycle ? Explain

Answered: 1 week ago

Question

Recognize the four core purposes service environments fulfill.

Answered: 1 week ago

Question

Know the three main dimensions of the service environment.

Answered: 1 week ago