Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 2022 I nedd help code is below
INCLUDE asmlib.inc
.data
welcomeMsg BYTE "Welcome to the dice guess game. It costs $1.00 to play.", 0
continueMsg BYTE "Would you like to continue? (y/n)",0
guessMsg BYTE "Please enter your guess for the next roll. It only costs $1.00 to play", 0
winMsg BYTE "Winner!", 0
loseMsg BYTE "Sorry you lose. The dice rolled ",0
thanksMsg BYTE "Thanks for playing", 0
bankMsg BYTE "Your bank is now $",0
newline BYTE 0Dh,0Ah,0
.code
main PROC
; Initialize the bank
mov eax, 10 ; 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 al,'y'
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 1 and 6
mov ecx, 6
call RandomRange
inc eax ; random number in range 1 to 6
; 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, 10 ; add $10 to the bank
jmp printBank
notWinner:
; User guessed incorrectly
mov edx, OFFSET loseMsg
call writeString
call writeDec
sub eax, 1 ; subtract $1 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
image text in transcribed

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

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

Analyse the various techniques of training and learning.

Answered: 1 week ago