Question: This is an assembly code using the ( INCLUDE asmlib.inc ) library I have a code but it doesin't work in visual studio 2 0
This is an assembly code using the INCLUDE asmlib.inc library I have a code but it doesin't work in visual studio I nedd help code is below
INCLUDE asmlib.inc
data
welcomeMsg BYTE "Welcome to the dice guess game. It costs $ to play.",
continueMsg BYTE "Would you like to continue? yn
guessMsg BYTE "Please enter your guess for the next roll. It only costs $ to play",
winMsg BYTE "Winner!",
loseMsg BYTE "Sorry you lose. The dice rolled
thanksMsg BYTE "Thanks for playing",
bankMsg BYTE "Your bank is now $
newline BYTE DhAh
code
main PROC
; Initialize the bank
mov eax, ; initial bank amount
call Randomize
; Game loop
gameLoop:
; Print welcome message
mov edx, OFFSET welcomeMsg
call writeString
mov edx, OFFSET newline
call writeString
; Ask if the user wants to continue
mov edx, OFFSET continueMsg
call writeString
call readChar
cmp aly
jne exitGame ; if not y exit the game
; Ask for the user's guess
mov edx, OFFSET guessMsg
call writeString
call readInt
; Store the user's guess in ebx
mov ebx, eax
; Generate a random number between and
mov ecx,
call RandomRange
inc eax ; random number in range to
; Compare the user's guess with the random number
cmp ebx, eax
jne notWinner
; User guessed correctly
mov edx, OFFSET winMsg
call writeString
add eax, ; add $ to the bank
jmp printBank
notWinner:
; User guessed incorrectly
mov edx, OFFSET loseMsg
call writeString
call writeDec
sub eax, ; subtract $ from the bank
printBank:
; Print the current bank amount
mov edx, OFFSET newline
call writeString
mov edx, OFFSET bankMsg
call writeString
call writeDec
mov edx, OFFSET newline
call writeString
; Loop back to the start
jmp gameLoop
exitGame:
; Thank the user for playing
mov edx, OFFSET thanksMsg
call writeString
mov edx, OFFSET newline
call writeString
; Print the final bank amount
mov edx, OFFSET bankMsg
call writeString
call writeDec
mov edx, OFFSET newline
call writeString
; Exit the program
exit
main endp
END main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
