Question
This doesn't work running in visual studio TITLE MASM template INCLUDE Irvine32.inc data. msg1 BYTE Please Enter your name: ,0dh,0ah, 0 msg2 BYTE Please Enter
This doesn't work running in visual studio
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
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 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 winner
Please make sure works in visual studio and show output!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started