-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindChars.asm
149 lines (101 loc) · 2.71 KB
/
FindChars.asm
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
TITLE FIND_CHAR
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
MAIN PROC
MOV AX,DATA
MOV DS,AX
LEA DX,WELCOME
MOV AH,9
INT 21H
LEA DX,MESSAGE
MOV AH,9
INT 21H
MOV SI,0
INPUT:
MOV AH,01
INT 21H
CMP AL,'!'
JE PRINT
STORE:
MOV BUFFER[SI],AL
INC SI
CMP SI,60
JB INPUT
PRINT:
LEA DX,CHAR
MOV AH,09
INT 21H
MOV AH,01
INT 21H
MOV CL,AL ;perna me timi
CALL FIND_CHAR
LEA DX,EXISTS
MOV AH,09
INT 21H
MOV DL,BL ;poses fores iparxei
ADD DL,48
MOV AH,02
INT 21H
LEA DX,NEWLINE
MOV AH,09
INT 21H
MOV CX,DI ;o deuteros pinakas
MOV SI,0
FOR2:
MOV DL,BUFFERPOS[SI]
CMP DL,',' ;an einai koma tote emfaniseto opos ine
JNE NUMBER
JMP SEPERATOR
NUMBER: ;alios kanton arithmo
ADD DL,48
SEPERATOR:
MOV AH,02
INT 21H
INC SI
LOOP FOR2:
JMP FINISH
NOINPUT:
LEA DX,NOINPUTMIN
MOV AH,09
INT 21H
FINISH:
MOV AH,4CH
INT 21H
MAIN ENDP
FIND_CHAR PROC
MOV BH,CL ;O CHAR POU 4AXNO
MOV CX,SI
MOV SI,0
MOV BL,0 ;PLITHOS
MOV DI,0 ;COUNTER GIA TON PINAKA BUFFERPOS
JCXZ NOINPUT
FOR:
CMP BUFFER[SI],BH ;elekse an einai auto pou psaxnoume
JNE NEXT
INC BL ;auksise tis fores pou to vrikame
MOV AX,SI ;vres thesi apo ton si
MOV DH,10
DIV DH
MOV BUFFERPOS[DI],AL ;vale dekada
INC DI
MOV BUFFERPOS[DI],AH ;vale monada
INC DI
MOV BUFFERPOS[DI],',' ;vale komma
INC DI
NEXT:
INC SI
LOOP FOR
RET
FIND_CHAR ENDP
DATA SEGMENT
WELCOME DB " --== WELCOME ==--$"
MESSAGE DB 10,13,"Please type a setnence (to finish type '!'): $"
NEWLINE DB 10,13,"$"
CHAR DB 10,13,"Give the char you want to find out: $"
EXISTS DB 10,13,"EXISTS $"
POSITION DB 10,13,"STIS THESEIS $"
NOINPUTMIN DB "NO INPUT!!!$"
BUFFERPOS DB 180 DUP(0)
BUFFER DB 60 DUP(0)
DATA ENDS
END CODE