-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrps.asm
More file actions
66 lines (53 loc) · 1.3 KB
/
rps.asm
File metadata and controls
66 lines (53 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
rps_game:
; Clear screen
mov ah, 0x00
int 0x10
; Display game header
mov bx, rps_header
call print_msg
; Game loop
rps_loop:
mov bx, rps_prompt
call print_msg
; Read user choice
mov ah, 0x00
int 0x16
mov bl, al
; Generate computer choice (random)
call random_choice
mov bh, al
; Determine winner
call determine_winner
; Display result
mov bx, result_message
call print_msg
; Ask to play again
mov bx, play_again_prompt
call print_msg
mov ah, 0x00
int 0x16
cmp al, 'y'
je rps_loop
rps_exit:
ret
random_choice:
; Generate a random choice (1-3)
; 1 = Rock, 2 = Paper, 3 = Scissors
mov al, 3
ret
determine_winner:
; Compare user choice (bl) and computer choice (bh)
; Set result_message accordingly
; ...implementation...
ret
rps_header:
db "Rock-Paper-Scissors", 0x0A, 0
rps_prompt:
db "Choose (r)ock, (p)aper, or (s)cissors: ", 0
result_message:
db "Result: ", 0
play_again_prompt:
db "Play again? (y/n): ", 0
rps_message:
db "Rock-Paper-Scissors Game", 0x0A
db "Press any key to return to the main menu...", 0