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 Code doesn't work here are the errors

syntax error

Even line 42

syntax error :: line47

invalid instruction opprands line 115

instruction opperands must be the same size line 118

undefined symbol DisplayWinner line 120

Please fix!

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

je Even

; If it's odd, call getTriple

call getTriple

jmp EndProc

Even:

; If it's even, call getDouble

call getDouble

EndProc:

ret

getoddeven ENDP

main PROC

;Get user's name

mov edx, OFFSET msg1

call WriteString

mov edx, OFFSET name1

mov ecx, SIZEOF name1

call ReadString

;Get 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

please make sure it runs!

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

LO6 Describe how individual pay rates are set.

Answered: 1 week ago