This is the requirement of the problem
The first player is asked from the keyboard for a decimal number from
0 to 9 without being displayed on the screen. The second player must
guess the number that the first player thought of by entering it on
the keyboard. After input, a message will always be printed indicating
to the player if the number is too high, too low or the correct one.
The player must enter numbers until he guesses the correct one. If the
figure is correct, this is indicated and the game is stopped.Hint: see function 8 of INT 21h”
This is what I tried.. It works fine, but shows me double when the number is less “numarul este mic”, and grater “numarul este mare”, what should I do?
.model small
.stack 100h
.data
prompt db 'Introduceti o valoare intre 0 si 9:' ,0DH,0AH,'$'
mesaj_1 db 'Numarul este mic' ,0DH,0AH,'$'
mesaj_2 db 'Numarul este mare' ,0DH,0AH,'$'
mesaj_3 db 'Numarul este corect!' ,0DH,0AH,'$'
mesaj_4 db 'Player introdu' ,0DH,0AH,'$'
.code
start:
Mov ax, @data
Mov ds, ax
mov dx, offset mesaj_4
mov ah, 9h
int 21h
mov ah, 8h
int 21h
mov cl, al
mov dx, offset prompt
bucla:
mov ah, 9h
int 21h
mov ah, 01h
int 21h
mov ch, al
cmp ch, cl
jl maiMic
jg maiMare
je corect
maiMic:
mov dx, offset mesaj_1
mov ah, 9h
int 21h
jl bucla
maiMare:
mov dx, offset mesaj_2
mov ah, 9h
int 21h
jmp bucla
corect:
mov dx, offset mesaj_3
mov ah, 9h
int 21h
jmp tipareste
tipareste:
mov ah, 9
int 21h
mov ax, 4c00h
int 21h
Emanuel2003 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2