-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.asm
More file actions
158 lines (97 loc) · 2.61 KB
/
main.asm
File metadata and controls
158 lines (97 loc) · 2.61 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
.MODEL SMALL
.STACK 2048
.386 ; sets the instruction set of 80386 processor
PUBLIC NamePlayer1
PUBLIC NamePlayer2
PUBLIC displayReadNameHeader
PUBLIC readSinglePlayerName
PUBLIC readTwoPlayersNames
; This are external Procedures defined in other Assembly files
; The linker will join them
EXTRN displayWelcomeScreen:NEAR
EXTRN MenuScreen:NEAR
INCLUDE inout.inc
.DATA
NamePlayer1_length DB 7 , ?
NamePlayer1 DB 7 DUP('$')
NamePlayer2_length DB 7 , ?
NamePlayer2 DB 7 DUP('$')
errorMessage DB "Please start your name with a letter",'$'
enterMessage DB "Please enter your name (Max of 6 Characters)",'$'
player1Message DB "Player 1 Name :" , '$'
player2Message DB "Player 2 Name :" , '$'
playerMessage DB "Player Name :" , '$'
.CODE
Main PROC FAR
CALL initializeDataSegment
CALL displayWelcomeScreen
CALL MenuScreen
callSwitchToTextMode
CALL exitProgram
Main ENDP
initializeDataSegment PROC
MOV AX , @DATA
MOV DS , AX
RET
initializeDataSegment ENDP
; return control to operating system
exitProgram PROC
MOV AH , 4Ch
INT 21H
exitProgram ENDP
displayReadNameHeader PROC
PUSHA
callSwitchToTextMode
callSetCursorPosition 18 , 5
callPrintString enterMessage
POPA
RET
displayReadNameHeader ENDP
readSinglePlayerName PROC
PUSHA
callSetCursorPosition 33 , 10
callPrintString playerMessage
_label_readSinglePlayerName_loop:
callSetCursorPosition 36 , 12
callClearCharacters NamePlayer1_length
callReadString NamePlayer1
callIsLetter NamePlayer1[0]
JC _label_readSinglePlayerName_finish
callSetCursorPosition 22 , 15
callPrintString errorMessage
JMP _label_readSinglePlayerName_loop
_label_readSinglePlayerName_finish:
POPA
RET
readSinglePlayerName ENDP
readTwoPlayersNames PROC
PUSHA
_label_read_Player1_Name:
callSetCursorPosition 50 , 10
callPrintString player1Message
_label_Player1_verify_name_loop:
callSetCursorPosition 53 , 12
callClearCharacters NamePlayer1_length
callReadString NamePlayer1
callIsLetter NamePlayer1[0]
JC _label_read_Player2_Name
callSetCursorPosition 22 , 20
callPrintString errorMessage
JMP _label_Player1_verify_name_loop
_label_read_Player2_Name:
callSetCursorPosition 10 , 10
callPrintString player2Message
_label_Player2_verify_name_loop:
callSetCursorPosition 13 , 12
callClearCharacters NamePlayer2_length
callReadString NamePlayer2
callIsLetter NamePlayer2[0]
JC _label_readTwoPlayersNames_finish
callSetCursorPosition 22 , 20
callPrintString errorMessage
JMP _label_Player2_verify_name_loop
_label_readTwoPlayersNames_finish:
POPA
RET
readTwoPlayersNames ENDP
END Main